xref: /freebsd/contrib/dialog/samples/editbox4 (revision a96ef4501919d7ac08e94e98dc34b0bdd744802b)
14c8945a0SNathan Whitehorn#!/bin/sh
2*a96ef450SBaptiste Daroussin# $Id: editbox4,v 1.2 2020/11/26 00:03:58 tom Exp $
34c8945a0SNathan Whitehorn
44c8945a0SNathan Whitehorn. ./setup-vars
54c8945a0SNathan Whitehorn
64c8945a0SNathan WhitehornDIALOG_ERROR=254
74c8945a0SNathan Whitehornexport DIALOG_ERROR
84c8945a0SNathan Whitehorn
94c8945a0SNathan Whitehorn. ./setup-edit
104c8945a0SNathan Whitehorn
114c8945a0SNathan Whitehorncat << EOF > $input
124c8945a0SNathan WhitehornHi, this is an edit box. It can be used to edit text from a file.
134c8945a0SNathan Whitehorn
144c8945a0SNathan WhitehornIt's like a simple text editor, with these keys implemented:
154c8945a0SNathan Whitehorn
164c8945a0SNathan WhitehornPGDN	- Move down one page
174c8945a0SNathan WhitehornPGUP	- Move up one page
184c8945a0SNathan WhitehornDOWN	- Move down one line
194c8945a0SNathan WhitehornUP	- Move up one line
204c8945a0SNathan WhitehornDELETE	- Delete the current character
214c8945a0SNathan WhitehornBACKSPC	- Delete the previous character
224c8945a0SNathan Whitehorn
234c8945a0SNathan WhitehornUnlike Xdialog, it does not do these:
244c8945a0SNathan Whitehorn
254c8945a0SNathan WhitehornCTRL C	- Copy text
264c8945a0SNathan WhitehornCTRL V	- Paste text
274c8945a0SNathan Whitehorn
284c8945a0SNathan WhitehornBecause dialog normally uses TAB for moving between fields,
294c8945a0SNathan Whitehornthis editbox uses CTRL/V as a literal-next character.  You
304c8945a0SNathan Whitehorncan enter TAB characters by first pressing CTRL/V.  This
314c8945a0SNathan Whitehornexample contains a few tab characters.
324c8945a0SNathan Whitehorn
334c8945a0SNathan WhitehornIt supports the mouse - but only for positioning in the editbox,
344c8945a0SNathan Whitehornor for clicking on buttons.  Your terminal (emulator) may support
354c8945a0SNathan Whitehorncut/paste.
364c8945a0SNathan Whitehorn
374c8945a0SNathan WhitehornTry to input some text below:
384c8945a0SNathan Whitehorn
394c8945a0SNathan WhitehornEOF
404c8945a0SNathan Whitehorn
414c8945a0SNathan Whitehorn$DIALOG --title "EDIT BOX" \
424c8945a0SNathan Whitehorn	--fixed-font "$@" --editbox $input 20 40 2>$output
43*a96ef450SBaptiste Daroussinreturncode=$?
444c8945a0SNathan Whitehorn
454c8945a0SNathan Whitehorn. ./report-edit
46