7

Cygwinターミナルで実行され、フォーマットされたテーブルを出力する小さなperlスクリプトがあります。デフォルトのウィンドウ サイズでは、テキストが長くなりすぎると cygwin が改行を挿入し、それによってテーブルのフォーマットが破壊されます。そのような問題を回避するために、私の perl スクリプトから cygwin ウィンドウをより大きなサイズに設定する方法はありますか?

4

3 に答える 3

9

minttyコマンドにフラグを追加できるショートカットからこれを実行している場合は、サイズを設定できます。利点は、ぎくしゃくしたサイズ変更なしでよりスムーズに見えることです.

$ /cygdrive/c/tools/cygwin/bin/mintty.exe --help
Usage: mintty [OPTION]... [ PROGRAM [ARG]... | - ]

Start a new terminal session running the specified program or the user's shell.
If a dash is given instead of a program, invoke the shell as a login shell.

Options:
  -c, --config FILE     Load specified config file (cf. -C or -o ThemeFile)
  -e, --exec ...        Treat remaining arguments as the command to execute
  -h, --hold never|start|error|always  Keep window open after command finishes
  -p, --position X,Y    Open window at specified coordinates
  -p, --position center|left|right|top|bottom  Open window at special position
  -p, --position @N     Open window on monitor N
  -s, --size COLS,ROWS  Set screen size in characters (also COLSxROWS)
  -s, --size maxwidth|maxheight  Set max screen size in given dimension
  -t, --title TITLE     Set window title (default: the invoked command) (cf. -T)
  -w, --window normal|min|max|full|hide  Set initial window state
  -i, --icon FILE[,IX]  Load window icon from file, optionally with index
  -l, --log FILE|-      Log output to file or stdout
      --nobidi|--nortl  Disable bidi (right-to-left support)
  -o, --option OPT=VAL  Set/Override config file option with given value
  -B, --Border frame|void  Use thin/no window border
  -R, --Reportpos s|o   Report window position (short/long) after exit
      --nopin           Make this instance not pinnable to taskbar
  -D, --daemon          Start new instance with Windows shortcut key
  -H, --help            Display help and exit
  -V, --version         Print version information and exit
See manual page for further command line options and configuration.
于 2016-12-19T03:18:00.280 に答える
5

ターミナル エミュレータとして mintty を使用している場合 (ここ数年、Cygwin のデフォルトのターミナル エミュレータとなっています)、ANSI エスケープ コードを使用してターミナルを操作できます。

これをテストするには、次の Perl コードのスニペットを実行して、ターミナル エミュレータ ウィンドウのサイズを変更します。

# If terminal supports ANSI escape sequences
$lines = 80;
$columns = 100;
print "\e[8;$lines;${columns}t";

注:screenウィンドウ内で実行すると機能しません。理由はわかりません。man ページによるとscreen、このエスケープ シーケンスはサポートされているはずです。

説明

ANSI エスケープ シーケンスの構文は読みやすいものではありませんが、上記のシーケンスの基礎を提供するドキュメントを次に示します。

\e、ANSI エスケープ シーケンスを開始するエスケープ文字を出力します。これは、 Control Sequence Introducer (CSI)とも呼ばれます。

で終わる特定のシーケンスtは、このxterm 制御シーケンスのリストから取得されます

CSI Ps ; Ps ; Ps t
          Window manipulation (from dtterm, as well as extensions).
          These controls may be disabled using the allowWindowOps
          resource.  Valid values for the first (and any additional
          parameters) are:
…
Ps = 8  ;  height ;  width -> Resize the text area to given
          height and width in characters.  Omitted parameters reuse the
          current height or width.  Zero parameters use the display's
          height or width.
于 2015-02-27T15:34:23.507 に答える
4

Perl も必要ありません。Bash でも同じことができます。

echo -en "\e[8;35;100t";

または、スクリプトではない理由:

#!/bin/bash
# minsize - A TTY re-size escape sequence for use with mintty Cygwin
# Usage: minsize <width> <height>
WIDTH=$1
HEIGHT=$2
echo -en "\e[8;${HEIGHT};${WIDTH}t";

他の *nix ではttysize利用可能であることに注意してください。

于 2015-03-07T15:34:21.253 に答える