It is currently Thu Mar 28, 2024 2:04 am


All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Determining terminal dimensions in GT.M
PostPosted: Thu Nov 04, 2010 9:35 pm 
User avatar

Joined: Mon Nov 01, 2010 1:39 pm
Posts: 51
Real Name: John Willis
Began Programming in MUMPS: 01 Apr 2010
Hello all,

I am wondering if anyone can point me in the right direction...
I'm looking to be able to determine the number of rows and
columns in the terminal connected to $PRINCIPAL in GT.M.
Specifically, I would like for my code to be able to respond to
an xterm/rxvt/etc. window being resized.

The approach I'm currently taking is below (the PDOC
stuff is for a texinfo documentation generator I've built):

Code:
;;PDOC
;;SUMMARY Get terminal height in lines
;;DEFFNC
TRMLINES()
;;PDOC/
 Q $ZTRNLNM("LINES")

;;PDOC
;;SUMMARY Get terminal width in columns
;;DEFFNC
TRMCOLS()
;;PDOC/
 Q $ZTRNLNM("COLUMNS")


However, the LINES and COLUMNS environment variables don't
seem to be updated when the terminal window resizes.

Any ideas?

Thanks much,

_________________
John Willis, Founder
Coherent Logic Development
http://youngmumpster.wordpress.com/
jwillis@coherent-logic.com


Top
Offline Profile  
 
 Post subject: Re: Determining terminal dimensions in GT.M
PostPosted: Fri Nov 05, 2010 10:01 am 
Site Admin
User avatar

Joined: Mon Nov 01, 2010 1:58 pm
Posts: 205
Location: Seattle, Washington
Real Name: Frederick D. S. "Rick" Marshall
Began Programming in MUMPS: 15 Jun 1984
The MUMPS standard is silent on the issue of maximum screen height and width, which is the standard's terse way of saying it imposes no limits. By the same token, though, it doesn't help standardize how the current range is set or adjusted, which means that's vendor specific. This is a question we'll need to answer vendor by vendor. I don't know any of the answers off the top of my head, so let's explore the manuals and post what we find.

_________________
Frederick D. S. "Rick" Marshall, VISTA Expertise Network, 819 North 49th Street, Suite 203, Seattle, Washington 98103, (206) 465-5765, rick dot marshall at vistaexpertise dot net
"The hidden harmony is best." - Heraclitus of Ephesus


Top
Offline Profile  
 
 Post subject: Re: Determining terminal dimensions in GT.M
PostPosted: Sat Nov 06, 2010 11:00 am 
Site Admin
User avatar

Joined: Mon Nov 01, 2010 1:39 pm
Posts: 16
Real Name: DL Wicksell
Began Programming in MUMPS: 15 Mar 2008
John, LINES and COLUMNS are shell variables, not environment variables. They don't get exported to child processes. That's why your code won't work that way.

You can use tput and put the output into a temporary file, and then open it and read the answer into a variable for use in your code. The easiest thing to do is to leverage the kernel API for returning the output of shell commands in your mumps code. Here is your code reworked with my example:

Code:
;;PDOC
;;SUMMARY Get terminal height in lines
;;DEFFNC
TRMLINES()
;;PDOC/
Q $$RETURN^%ZOSV("tput lines")

;;PDOC
;;SUMMARY Get terminal width in columns
;;DEFFNC
TRMCOLS()
;;PDOC/
Q $$RETURN^%ZOSV("tput cols")


I hope this helps you John. :)

_________________
"If a thing is worth doing, it is worth doing badly." ~GK Chesterton

DL Wicksell
President / CEO
Fourth Watch Software, LC


Top
Offline Profile  
 
 Post subject: Re: Determining terminal dimensions in GT.M
PostPosted: Sat Nov 06, 2010 6:11 pm 
User avatar

Joined: Mon Nov 01, 2010 1:39 pm
Posts: 51
Real Name: John Willis
Began Programming in MUMPS: 01 Apr 2010
Works great! Thanks much!

_________________
John Willis, Founder
Coherent Logic Development
http://youngmumpster.wordpress.com/
jwillis@coherent-logic.com


Top
Offline Profile  
 
 Post subject: Re: Determining terminal dimensions in GT.M
PostPosted: Mon Nov 08, 2010 5:13 pm 
Site Admin

Joined: Mon Nov 01, 2010 1:31 pm
Posts: 10
Location: Las Cruces, NM 88012 USA
Real Name: LD "Gus" Landis
Began Programming in MUMPS: 15 Aug 1991
Another option you can use in a newer (don't recall which) version of GT.M:

GTM>o "tput":(SHELL="/bin/sh":COMMAND="tput lines":READONLY)::"PIPE"

GTM>u "tput" r lines c "tput" u 0 w lines
24
GTM>

Confirmed to work on Linux and AIX.

BUT for VISTA systems, David's approach is far superior!

_________________
3960 Schooner Loop 651-340-4007
Las Cruces, NM 88012-6067


Top
Offline Profile  
 
 Post subject: Re: Determining terminal dimensions in GT.M
PostPosted: Tue Nov 23, 2010 10:59 am 
User avatar

Joined: Wed Nov 17, 2010 4:02 pm
Posts: 71
Location: Houston TX
Real Name: David Whitten
Began Programming in MUMPS: 06 Jan 1982
It would probably be useful to at least mention the $KEY and $DEVICE special variables in this thread, since they are the "Standard" way of getting information about the current I/O device.

The 1995 standard mentions the X3.64 Controlmnemonics in Annex G (informative) on the web here:

http://71.174.62.16/Demo/AnnoStd?Frame= ... ition=1995

The note about the effect on $KEY and $DEVICE on that website might be useful, especially as it interacts with the /DSR controlmnemonic. (it basically gives you information about the current $X and $Y position, not the maximum values )

Best Regards,
David Whitten


Top
Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 23 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net