2016-06-14 10 views
2

vimのような端末でカーソルの色がどのようなものかを判断する方法はありますか? tput colstput rowsを使用して、端末の高さと幅を判断することができます。現在の端末の文字位置のansi標準フォアグラウンド/バックグラウンドカラーを取得するための同様のツールがありますか?ターミナルでカーソルの色を取得する

答えて

1

あなたの質問に対する答えは「いいえ、それを行う標準的な方法はありません」です。

端末が、シリアルポートまたはモデムを介してサーバーと通信した古代のテキスト端末(DEC VT100など)をモデルにしていることを考慮してください。そして、これらの端末は、1960年代にコンピュータに接続されたTeleTYpe(tty)デバイスの後でモデル化されました。

テレタイプのマシン(「ダム」端末)は、キーボードに入力されていないデータをサーバーに返しませんでした。 VT100のようなデバイス(「スマート」端末)は、サーバに非常に軽く提供されましたが、何が利用可能かのリストは何年も変わっていません。

その他のリソース:

すべての端末がVT100/VT220であるわけではなく、システムに非標準的な方法で必要なものを提供するロケック拡張があることに注意してください。

追加の読書については、man termcapman terminfoをご覧ください。これらのページの「参照」セクションの参考文献を参照してください。

+0

これらの匿名ダウンワードが大好きです。 :-Pもし誰かがこの答えが誤解を招く、または間違っていると思うなら、私はその理由を知りたいです。 – ghoti

1

短い答え:いいえ

長い答え:機能、広く利用可能なスクリプト作成のために、端末の機能のいずれかを取得することができますtputの他の機能、になります。これらはterminfo manualページに記載されています。カーソル色を扱うものはありませんが、(あまりにも曖昧な)cvvis(非常に目に見える)、cnorm(正常)、civis(見えない)のカーソル属性のみを扱います。ある

は、ほとんどの端末は

xtermがあるカーソルの色を取得

  • への道を提供カーソルの色や
  • を設定する方法を提供していませんまれな例外で、両方を提供します。しかし、この機能は、xtermを模倣する端末ではしばしばサポートされていません。それはdynamic colors機能の一部としてXTerm Control Sequencesに記載されています:

    OSC Ps ; Pt ST 
    OSC Ps ; Pt BEL 
         Set Text Parameters. For colors and font, if Pt is a "?", the 
         control sequence elicits a response which consists of the con- 
         trol sequence which would set the corresponding value. The 
         dtterm control sequences allow you to determine the icon name 
         and window title. 
    
         The 10 colors (below) which may be set or queried using 1 0 
         through 1 9 are denoted dynamic colors, since the correspond- 
         ing control sequences were the first means for setting xterm's 
         colors dynamically, i.e., after it was started. They are not 
         the same as the ANSI colors. These controls may be disabled 
         using the allowColorOps resource. At least one parameter is 
         expected for Pt. Each successive parameter changes the next 
         color in the list. The value of Ps tells the starting point 
         in the list. The colors are specified by name or RGB specifi- 
         cation as per XParseColor. 
    
         If a "?" is given rather than a name or RGB specification, 
         xterm replies with a control sequence of the same form which 
         can be used to set the corresponding dynamic color. Because 
         more than one pair of color number and specification can be 
         given in one control sequence, xterm can make more than one 
         reply. 
    
         Ps = 1 2 -> Change text cursor color to Pt. 
    

    プログラムxtermcontrolが設定され、カーソルの色を取得するために、これらのエスケープシーケンスを使用して、コマンドライン:たとえば

    --cursor=COLOR 
        Set cursor color to COLOR. 
    
    --get-cursor 
        Report cursor color. 
    

    $ xtermcontrol --get-cursor 
    rgb:0000/0000/0000 
    $ xtermcontrol --cursor limegreen 
    $ xtermcontrol --get-cursor 
    rgb:3232/cdcd/3232 
    

    これは価値があるため、VTEによってサポートされています(例:gnome-terminal)。

関連する問題