doucao1066 2012-10-29 23:30
浏览 1419

xterm中的换行问题

I am writing a program that prints colored lines, and the more I do with it the more I find myself working around line wrapping issues that come up.

It is a sort of terminal written in php, here is the prompt:

$return = readline("\033[44m\033[1;37m{$this->text}>>\033[0m ");

and scrolling through history, the non-printing characters play havoc on everything.

If I try to add escapes

$return = readline("\[\033[44m\033[1;37m\]{$this->text}>>\[\033[0m\] ");

then it prints the brackets...even if I add double backslashes.

\[\][timer]>>\[\] 

I find the same thing for echo -e, I am really not sure whats going on.

Lastly, if I modify PS1 it works just fine.

[mike@crest ~]$ export PS1="\[\033[44m\033[1;37m\][timer]>>\[\033[0m\] "
[timer]>>

What am I missing here?

Edit: the coloring/display is not the problem. The problem is that bash will have line wrapping issues when invisible characters are printed without escapes...and when I add the escapes they are printed in plain text under all circumstances but PS1, and I'm not sure what the difference is, how to get it working in PHP.

  • 写回答

1条回答 默认 最新

  • douqianzha6213 2012-10-30 10:54
    关注

    php 1.php

    [TIMER]>>

    <?php
    
    $return = readline("\033[44m\033[1;37m[TIMER]>>\033[0m ");
    
    ?>
    

    Here is dialog example added

    dialog --title "Welcome" --msgbox "
    MY TEST DIALOG 
    
    Press <Enter> to continue or <Esc> to cancel." 10 50
    
    评论

报告相同问题?

悬赏问题

  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch