LIBRARY rexxgui
guierr = "SYNTAX"
guiheading = 1
fn = ''
text = ''
guicreatewindow('NORMAL')
guigetctlplacement(, , , 'Width', 'Height')
guisetctlplacement('TEXT', , , width, height)
again:
DO FOREVER
guigetmsg()
CATCH SYNTAX
CONDITION('M')
SIGNAL again
CATCH HALT
FINALLY
guidestroywindow()
END
RETURN
checkifsaved:
guisendmsg('TEXT', 'GETMODIFY')
IF guisignal == 1 THEN DO
err = guisay('Save the current changes?', 'YESCANCEL|INFO')
IF err == 'CANCEL' THEN RETURN -1
IF err == 'YES' THEN RETURN filesave()
END
RETURN 0
filenew:
IF checkifsaved() \== 0 THEN RETURN
guiaddctltext(guiwindow)
text.0 = 0
guisetctlvalue('TEXT')
guisendmsg('TEXT', 'SETMODIFY', 0)
RETURN
fileopen:
IF checkifsaved() \== 0 THEN RETURN
DO
extensions = 'REXX scripts (*.rex) | *.rex | Text files (*.txt) | *.txt | All files (*.*) | *.*'
guifile('FN', 'HIDEREADONLY|PATH|DIR', 'Pick out a text file', extensions)
CATCH SYNTAX
RETURN
END
DO
LOADTEXT('TEXT', fn)
guisetctlvalue('TEXT')
DROP text.
guiaddctltext(guiwindow, TRANSLATE(fn, '/', '\'))
CATCH NOTREADY
CONDITION('M')
END
guisendmsg('TEXT', 'SETMODIFY', 0)
RETURN
filesaveas:
DO
extensions = 'REXX scripts (*.rex) | *.rex | Text files (*.txt) | *.txt | All files (*.*) | *.*'
guifile('FN', 'HIDEREADONLY|OVERWRITE|SAVE|PATH|DIR', 'Save a text file', extensions)
CATCH SYNTAX
RETURN -1
END
filesave:
IF fn = "" THEN SIGNAL filesaveas
guisendmsg('TEXT', 'GETTEXT')
DO
STREAM(fn, 'C', 'OPEN WRITE REPLACE')
CHAROUT(fn, guisignal)
CATCH NOTREADY
CONDITION('M')
FINALLY
STREAM(fn, 'C', 'CLOSE')
END
RETURN 0
fileexit:
guisendmsg(, 'POST CLOSE')
RETURN
editcut:
guiremovectltext('TEXT')
RETURN
editcopy:
guisendmsg('TEXT', 'COPY')
RETURN
editpaste:
guiaddctltext("TEXT")
RETURN
rexxrunasscript: PROCEDURE
guisendmsg('TEXT', 'GETMODIFY')
flag = guisignal
guisendmsg('TEXT', 'GETTEXT')
INTERPRET guisignal
guisendmsg('TEXT', 'SETMODIFY', flag)
RETURN
wm_size:
DO
guisetctlplacement('TEXT', , , ARG(3), ARG(4))
CATCH SYNTAX
END
RETURN ""
wm_close:
RETURN |