tpw@cbnewsj.att.com (thomas.p.walsh) (06/19/91)
I'm running OpenWindows2.0 under SunOS 4.0.3. I need to get the number of lines/columns in a OpenwWindows 'cmdtool' window when scrolling is enabled. I've tried the \E[18t --> \E[8;ROWS;COLSt sequence as specified in the OpenWindows 'shelltool' manual page. This works fine if scrolling is disabled, but fails if scrolling is enabled. Anyone have any ideas how I can get the window size?
barnett@grymoire.crd.ge.com (Bruce Barnett) (06/19/91)
In article <1991Jun18.182843.1922@cbnewsj.att.com> tpw@cbnewsj.att.com (thomas.p.walsh) writes: > I've tried the \E[18t --> \E[8;ROWS;COLSt sequence as specified in > the OpenWindows 'shelltool' manual page. This works fine > if scrolling is disabled, but fails if scrolling is enabled. > > Anyone have any ideas how I can get the window size? I believe you cannot execute any escape sequences that read data if the window is in cmdtool mode. You could turn off Scroll (cmdtool) mode, get the values, and enable scroll mode. Using the GetSunParms script and the csh aliases included, you can type ScrollOff GetRowCol >/tmp/a ScrollOn set rc=(`cat /tmp/a`) echo "row is $rc[1], column is $rc[2]" or more simply ScrollOff set rc=(`GetSunParms rc`) ScrollOn echo "row is $rc[1], column is $rc[2]" It does work. ---- start of GetSunParms ----- #!/bin/sh # set path - just in case PATH=/usr/bin:/usr/5bin:/bin:/usr/ucb; export PATH # only one argument allowed case $# in 1) ;; *) echo 'Usage: GetSunParms [rc|wh|icon|pos|label|ilabel|page]'; exit 1;; esac # and that argument must be one of these: case $1 in icon) esc="\033[11t\c";; pos) esc="\033[13t\c";; wh) esc="\033[14t\c";; rc) esc="\033[18t\c";; ilabel) esc="\033[20t\c";; label) esc="\033[21t\c";; page) esc="\033[>1;k\c";; *) echo 'Unknown parameter';exit 1;; esac ECHO="/usr/5bin/echo" #turn off line mode and echo stty raw -echo >/dev/tty # send escape sequence to the SunView window $ECHO $esc >/dev/tty # use dd to get one line, then use tr to delete octal 33 (escape) # and set $@ to be the results set `dd </dev/tty count=1 2>/dev/null | tr -d '\033'` # Out the terminal back the way it was stty -raw echo >/dev/tty # Now output just the numberic values case $1 in \[1t) echo Open;; \[2t) echo Closed;; \[3*) echo "$@" |sed 's/^\[3;\([0-9]*\);\([0-9]*\)t/\1 \2/';; \[4*) echo "$@" |sed 's/^\[4;\([0-9]*\);\([0-9]*\)t/\1 \2/';; \[8*) echo "$@" |sed 's/^\[8;\([0-9]*\);\([0-9]*\)t/\1 \2/';; \]L*) echo "$@" |sed 's/^\]L\(.*\).$/\1/';; \]l*) echo "$@" |sed 's/^\]l\(.*\).$/\1/';; \[\>1*) echo "$@" |sed 's/^\[>1//';; *) echo "don't understand $@";; esac ---- end of GetSunParms ----- # smarter handling of echo's if ( -f /usr/5bin/echo ) then set ech = "/usr/5bin/echo" set E = "\033" set N = "\c" else set ech = "echo -n" set E = `$ech a | tr a '\033'` set N = "" endif # Sun Aliases alias Open '$ech "${E}[1t${N}"' alias Close '${ech} "${E}[2t${N}"' alias IMove '${ech} "${E}[3t${N}"' alias Move '${ech} "${E}[3;\!:1;\!:2t${N}"' alias Stretch '${ech} "${E}[4t${N}"' alias Resize '${ech} "${E}[4;\!:1;\!:2t${N}"' alias Front '${ech} "${E}[5t${N}"' alias Back '${ech} "${E}[6t${N}"' alias Refresh '${ech} "${E}[7t${N}"' alias RowCol '${ech} "${E}[8;\!:1;\!:2t${N}"' alias Header '${ech} "${E}]l\!*${E}\\${N}"' alias IHeader '${ech} "${E}]L\!*${E}\\${N}"' alias Icon '${ech} "${E}]\!\1:1${E}\\${N}"' alias PageOn '${ech} "${E}[>1h${N}"' alias PageOff '${ech} "${E}[>1l${N}"' alias IsOpen 'GetSunParms icon' alias GetPos 'GetSunParms pos' alias GetWidthHeight 'GetSunParms wh' alias GetRowCol 'GetSunParms rc' alias GetILabel 'GetSunParms ilabel' alias GetLabel 'GetSunParms label' alias GetPage 'GetSunParms page' alias 24x80 "RowCol 24 80" alias 34x80 "RowCol 34 80" alias Pos1 "Move 320 0;Resize 508 659" alias UL "Move 0 0; Resize 450 576" alias UR "Move 0 576; Resize 450 576" alias LL "Move 450 0; Resize 450 576" alias LR "Move 450 576 ; Resize 450 576" -- Bruce G. Barnett barnett@crdgw1.ge.com uunet!crdgw1!barnett