UniVerse has a little used function for inline field-level editing and
keyboard function trapping, provided by !EDIT.INPUT (and !PACK.FNKEYS)
which can do what you want.
Probably 'cause it's poorly documented and a little hard to use, which
is why it's little known or used (also 'cause it is very UV specific).
Prior releases of it didn't see to actually work (well or at all). :)
See an example below - for UniVerse 10.1.x and above only. See warnings
about it's use.
It has some very handy inline editing features, but alas they're not
documented well or clearly enough.
Regards,
David
* Simple example of trapping UP and DOWN keys
* David Hona, Feb 2007
$INCLUDE UNIVERSE.INCLUDE GTI.FNKEYS.IH
CRT @(-1):"!EDIT.INPUT - example usage - ":TIMEDATE()
CRT
CRT "***** IMPORTANT: READ THIS! *****"
CRT "If this example does NOT work, check your emulators UP/DOWN
key and ensure:"
CRT "1) they match *exactly* with the UV terminfo database
definition for your term-type "
CRT "2) your emulator is actually sending the keystrokes to your
host"
CRT "3) Turn off COMMAND.EDITOR, if it is in ALL mode."
CRT
CRT "NOTE: You need to fix these issues first, for this example to
work."
CRT
CRT "You can optionally use KEYEDIT to modify the default edit key
mappings or"
CRT "use KEYEXIT map function keys to cause !EDIT.INPUT to exit
(see UV BASIC manual)."
CRT
PROMPT '' ;* Suppres default prompt
Ftable = '' ;* Keytable map of keys to be trapped (returned)
*
* Set up a dynamic array of Function keys to be trapped and to cause
!EDIT.INPUT
* to immediately exit. As defined in UNIVERSE.INCLUDE GTI.FNKEYS.IH
*
TRAP.LIST = FK$UP ;* Cursor Up key
TRAP.LIST = @FM:FK$DOWN ;* Cursor Down key
CALL !PACK.FNKEYS(TRAP.LIST, Ftable)
*
* If TextBuffer size is > MaxBufferSize: it will get truncated, you
can't insert characters without
* deleting some first (using BACKSPACE key).
*
InputOverlayMode = IK$INS ;* + IK$DIS ;* Force INSERT edit mode
Row = 15 ;* Row to place cursor
Column = 0 ;* Column to place cursor
WindowSize = 60 ;* Max characters display for this field
TextBuffer = 'This the text to edit. You can change it. If you
press a key trapped, the value will NOT change.'
MaxBufferSize = 80 ;* Max field size. Truncates if TextBuffer is
large.
OrigTextBuffer = TextBuffer[1,MaxBufferSize]
IF LEN(TextBuffer) GT MaxBufferSize THEN CRT "Warning: truncated
size of TextBuffer to ":MaxBufferSize:" chars"
CursorPos = '' ;* Where to place the cursor, upon entry
CALL !EDIT.INPUT(InputOverlayMode, Column, Row, WindowSize,
TextBuffer, CursorPos, MaxBufferSize, Ftable, ReturnCode)
CRT @(0,20):
BEGIN CASE
CASE ReturnCode = FK$UP ; PRINTERR "User pressed the defined
UPCURSOR key"
CASE ReturnCode = FK$DOWN ; PRINTERR "User pressed the defined
DOWNCURSOR key"
END CASE
CRT
IF TextBuffer NE OrigTextBuffer THEN
CRT "The TextBuffer did change"
CRT "TextBuffer is now:"
CRT TextBuffer
END ELSE
CRT "The TextBuffer did NOT change"
END
END
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Brutzman, Bill
Sent: Tuesday, February 12, 2008 4:28 AM
To: '[email protected]'
Subject: [U2] [UB] Arrow Keys FollowUp
A snag with the last go-around was that it did not handle end-users with
caps-lock ON.
The following code snippet handles this problem.
Thanks also to Keith Johnson for his off-list mention of an alternative
technique at http://www.pickwiki.com/cgi-bin/wiki.pl?GetKey.
I like the code below better since it works right now...
--Bill
Ctrl.Chars.Seen = false
loop
AsciiChar = keyin()
DecimalChar = seq(AsciiChar)
input Ctrl.Char.Present, -1
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/