/usr/share/doc/xviewg/examples/textsw/xv_termsw.c is in xview-examples 3.2p1.4-28.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | /*
* xv_termsw.c
* Demonstrate incorporation of a Term subwindow in an application;
* keyboard input to the termsw can come either directly to the
* termsw or from an adjoining panel text item.
*/
#include <stdio.h>
#include <xview/xview.h>
#include <xview/panel.h>
/* #include <xview/tty.h> */
#include <xview/termsw.h>
Termsw term;
Panel_item text_item;
main(argc,argv)
int argc;
char *argv[];
{
Frame frame;
Panel panel;
int notify_proc();
xv_init(XV_INIT_ARGS, argc, argv, NULL);
frame = (Frame)xv_create(NULL, FRAME, NULL);
panel = (Panel)xv_create(frame, PANEL, NULL);
text_item = (Panel_item)xv_create(panel, PANEL_TEXT,
PANEL_LABEL_STRING, "Command:",
PANEL_NOTIFY_PROC, notify_proc,
PANEL_VALUE_DISPLAY_LENGTH, 20,
NULL);
(void) xv_create(panel, PANEL_BUTTON,
PANEL_LABEL_STRING, "Apply",
PANEL_NOTIFY_PROC, notify_proc,
NULL);
window_fit_height(panel);
term = (Termsw)xv_create(frame, TERMSW, NULL);
window_fit(frame);
xv_main_loop(frame);
}
/*
* This procedure is called when the user this return on the
* panel text item or clicking on the <apply> button.
* Use ttysw_input() to feed the string to the termal window.
*/
int
notify_proc(item,event)
Panel_item item;
Event *event;
{
char str[81];
sprintf(str, "%.81s\n", (char *)xv_get(text_item, PANEL_VALUE));
ttysw_input(term, str, strlen(str));
xv_set(text_item, PANEL_VALUE, "", NULL);
return XV_OK;
}
|