aboutsummaryrefslogtreecommitdiff
path: root/payloads/libpayload/curses/PDCurses-3.4/x11
diff options
context:
space:
mode:
Diffstat (limited to 'payloads/libpayload/curses/PDCurses-3.4/x11')
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.aix.in234
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.in572
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/README64
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.c321
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.h53
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBoxP.h72
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/big_icon.xbm46
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/compose.h203
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/little_icon.xbm14
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/ncurses_cfg.h47
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcclip.c170
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcdisp.c132
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcgetsc.c30
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdckbd.c102
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcscrn.c150
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcsetsc.c74
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcutil.c39
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.c317
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.h188
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/sb.c153
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/x11.c3229
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/xcurses-config.in76
22 files changed, 6286 insertions, 0 deletions
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.aix.in b/payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.aix.in
new file mode 100644
index 0000000000..0fe5db78ed
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.aix.in
@@ -0,0 +1,234 @@
+# Makefile for PDCurses library for AIX/X11
+
+SHELL = @SHELL@
+THIS = Makefile
+
+@SET_MAKE@
+
+PDCURSES_SRCDIR = ..
+
+osdir = .
+srcdir = $(PDCURSES_SRCDIR)/pdcurses
+
+PDCURSES_CONFIG_H =$(PDCURSES_SRCDIR)/config.h
+PDCURSES_CURSES_H =$(PDCURSES_SRCDIR)/curses.h
+PDCURSES_CURSPRIV_H =$(PDCURSES_SRCDIR)/curspriv.h
+PDCURSES_HEADERS =$(PDCURSES_CONFIG_H) $(PDCURSES_CURSES_H) \
+$(PDCURSES_CURSPRIV_H)
+PDCURSES_X11_H =$(osdir)/pdcx11.h
+
+MH_EXTRA_LIBS = @MH_EXTRA_LIBS@
+
+CFLAGS = @CFLAGS@ @DYN_COMP@
+
+CPPFLAGS = @DEFS@ -DXCURSES @SYS_DEFS@ -I$(PDCURSES_SRCDIR)
+
+BUILD = @CC@ -c $(CFLAGS) $(CPPFLAGS) @MH_XINC_DIR@
+
+LINK = @CC@
+LDFLAGS =
+
+LIBCURSES = libXCurses.a
+
+all : $(LIBCURSES)
+
+install :
+ echo Does nothing at the moment
+
+clean :
+ -rm -rf *.o *.sho trace $(LIBCURSES)
+
+distclean: clean
+ -rm -f Makefile
+
+mostlyclean: clean
+
+realclean: distclean
+
+LIBOBJS = addch.o addchstr.o addstr.o attr.o beep.o bkgd.o border.o \
+clear.o color.o delch.o deleteln.o deprec.o getch.o getstr.o getyx.o \
+inch.o inchstr.o initscr.o inopts.o insch.o insstr.o instr.o kernel.o \
+keyname.o mouse.o move.o outopts.o overlay.o pad.o panel.o printw.o \
+refresh.o scanw.o scr_dump.o scroll.o slk.o termattr.o terminfo.o \
+touch.o util.o window.o debug.o
+
+PDCOBJS = pdcclip.o pdcdisp.o pdcgetsc.o pdckbd.o pdcscrn.o pdcsetsc.o \
+pdcutil.o pdcx11.o x11.o sb.o ScrollBox.o
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS) curses.exp
+ ld -bnoentry -bM:SRE -bE:curses.exp $(MH_LIBS) $(MH_EXTRA_LIBS) \
+$(LIBOBJS) $(PDCOBJS) -o $@
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_X11_H)
+terminfo.o: $(TERM_HEADER)
+
+curses.exp: ../exp-base.def
+ cat ../exp-base.def > curses.exp
+ echo Xinitscr >> curses.exp
+ echo XCursesExit >> curses.exp
+ echo sb_init >> curses.exp
+ echo sb_set_horz >> curses.exp
+ echo sb_set_vert >> curses.exp
+ echo sb_get_horz >> curses.exp
+ echo sb_get_vert >> curses.exp
+ echo sb_refresh >> curses.exp
+
+addch.o: $(srcdir)/addch.c
+ $(BUILD) $(srcdir)/addch.c
+
+addchstr.o: $(srcdir)/addchstr.c
+ $(BUILD) $(srcdir)/addchstr.c
+
+addstr.o: $(srcdir)/addstr.c
+ $(BUILD) $(srcdir)/addstr.c
+
+attr.o: $(srcdir)/attr.c
+ $(BUILD) $(srcdir)/attr.c
+
+beep.o: $(srcdir)/beep.c
+ $(BUILD) $(srcdir)/beep.c
+
+bkgd.o: $(srcdir)/bkgd.c
+ $(BUILD) $(srcdir)/bkgd.c
+
+border.o: $(srcdir)/border.c
+ $(BUILD) $(srcdir)/border.c
+
+clear.o: $(srcdir)/clear.c
+ $(BUILD) $(srcdir)/clear.c
+
+color.o: $(srcdir)/color.c
+ $(BUILD) $(srcdir)/color.c
+
+delch.o: $(srcdir)/delch.c
+ $(BUILD) $(srcdir)/delch.c
+
+deleteln.o: $(srcdir)/deleteln.c
+ $(BUILD) $(srcdir)/deleteln.c
+
+deprec.o: $(srcdir)/deprec.c
+ $(BUILD) $(srcdir)/deprec.c
+
+getch.o: $(srcdir)/getch.c
+ $(BUILD) $(srcdir)/getch.c
+
+getstr.o: $(srcdir)/getstr.c
+ $(BUILD) $(srcdir)/getstr.c
+
+getyx.o: $(srcdir)/getyx.c
+ $(BUILD) $(srcdir)/getyx.c
+
+inch.o: $(srcdir)/inch.c
+ $(BUILD) $(srcdir)/inch.c
+
+inchstr.o: $(srcdir)/inchstr.c
+ $(BUILD) $(srcdir)/inchstr.c
+
+initscr.o: $(srcdir)/initscr.c
+ $(BUILD) $(srcdir)/initscr.c
+
+inopts.o: $(srcdir)/inopts.c
+ $(BUILD) $(srcdir)/inopts.c
+
+insch.o: $(srcdir)/insch.c
+ $(BUILD) $(srcdir)/insch.c
+
+insstr.o: $(srcdir)/insstr.c
+ $(BUILD) $(srcdir)/insstr.c
+
+instr.o: $(srcdir)/instr.c
+ $(BUILD) $(srcdir)/instr.c
+
+kernel.o: $(srcdir)/kernel.c
+ $(BUILD) $(srcdir)/kernel.c
+
+keyname.o: $(srcdir)/keyname.c
+ $(BUILD) $(srcdir)/keyname.c
+
+mouse.o: $(srcdir)/mouse.c
+ $(BUILD) $(srcdir)/mouse.c
+
+move.o: $(srcdir)/move.c
+ $(BUILD) $(srcdir)/move.c
+
+outopts.o: $(srcdir)/outopts.c
+ $(BUILD) $(srcdir)/outopts.c
+
+overlay.o: $(srcdir)/overlay.c
+ $(BUILD) $(srcdir)/overlay.c
+
+pad.o: $(srcdir)/pad.c
+ $(BUILD) $(srcdir)/pad.c
+
+panel.o: $(srcdir)/panel.c $(PDCURSES_SRCDIR)/panel.h
+ $(BUILD) $(srcdir)/panel.c
+
+printw.o: $(srcdir)/printw.c
+ $(BUILD) $(srcdir)/printw.c
+
+refresh.o: $(srcdir)/refresh.c
+ $(BUILD) $(srcdir)/refresh.c
+
+scanw.o: $(srcdir)/scanw.c
+ $(BUILD) $(srcdir)/scanw.c
+
+scr_dump.o: $(srcdir)/scr_dump.c
+ $(BUILD) $(srcdir)/scr_dump.c
+
+scroll.o: $(srcdir)/scroll.c
+ $(BUILD) $(srcdir)/scroll.c
+
+slk.o: $(srcdir)/slk.c
+ $(BUILD) $(srcdir)/slk.c
+
+termattr.o: $(srcdir)/termattr.c
+ $(BUILD) $(srcdir)/termattr.c
+
+terminfo.o: $(srcdir)/terminfo.c
+ $(BUILD) $(srcdir)/terminfo.c
+
+touch.o: $(srcdir)/touch.c
+ $(BUILD) $(srcdir)/touch.c
+
+util.o: $(srcdir)/util.c
+ $(BUILD) $(srcdir)/util.c
+
+window.o: $(srcdir)/window.c
+ $(BUILD) $(srcdir)/window.c
+
+debug.o: $(srcdir)/debug.c
+ $(BUILD) $(srcdir)/debug.c
+
+pdcclip.o: $(osdir)/pdcclip.c
+ $(BUILD) $(osdir)/pdcclip.c
+
+pdcdisp.o: $(osdir)/pdcdisp.c
+ $(BUILD) $(osdir)/pdcdisp.c
+
+pdcgetsc.o: $(osdir)/pdcgetsc.c
+ $(BUILD) $(osdir)/pdcgetsc.c
+
+pdckbd.o: $(osdir)/pdckbd.c
+ $(BUILD) $(osdir)/pdckbd.c
+
+pdcscrn.o: $(osdir)/pdcscrn.c
+ $(BUILD) $(osdir)/pdcscrn.c
+
+pdcsetsc.o: $(osdir)/pdcsetsc.c
+ $(BUILD) $(osdir)/pdcsetsc.c
+
+pdcutil.o: $(osdir)/pdcutil.c
+ $(BUILD) $(osdir)/pdcutil.c
+
+pdcx11.o: $(osdir)/pdcx11.c
+ $(BUILD) $(osdir)/pdcx11.c
+
+ScrollBox.o: $(osdir)/ScrollBox.c
+ $(BUILD) $(osdir)/ScrollBox.c
+
+sb.o: $(osdir)/sb.c
+ $(BUILD) $(osdir)/sb.c
+
+x11.o: $(osdir)/x11.c
+ $(BUILD) $(osdir)/x11.c
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.in b/payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.in
new file mode 100644
index 0000000000..d23a214fb3
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.in
@@ -0,0 +1,572 @@
+# Makefile for PDCurses library for X11
+
+SHELL = @SHELL@
+THIS = Makefile
+
+@SET_MAKE@
+
+PDCURSES_SRCDIR = ..
+
+osdir = .
+srcdir = $(PDCURSES_SRCDIR)/pdcurses
+demodir = $(PDCURSES_SRCDIR)/demos
+
+PDCURSES_CONFIG_H =$(PDCURSES_SRCDIR)/config.h
+PDCURSES_CURSES_H =$(PDCURSES_SRCDIR)/curses.h
+PDCURSES_CURSPRIV_H =$(PDCURSES_SRCDIR)/curspriv.h
+PDCURSES_HEADERS =$(PDCURSES_CONFIG_H) $(PDCURSES_CURSES_H) \
+$(PDCURSES_CURSPRIV_H)
+PDCURSES_X11_H =$(osdir)/pdcx11.h
+
+SHLPRE = @SHLPRE@
+SHLPST = @SHLPST@
+LD_RXLIB1 = @LD_RXLIB1@
+LD_RXLIB2 = @MH_XLIBS@ @MH_EXTRA_LIBS@ -lc
+
+CFLAGS = @CFLAGS@
+
+CPPFLAGS = @DEFS@ -DXCURSES @SYS_DEFS@ -I$(PDCURSES_SRCDIR)
+
+BUILD = @CC@ -c $(CFLAGS) $(CPPFLAGS) @MH_XINC_DIR@
+DYN_BUILD = @O2SAVE@ $(BUILD) @DYN_COMP@ @CC2O@
+
+LINK = @PURIFY@ @CC@
+#LDFLAGS = $(LIB_DEPS) @LDFLAGS@ @LIBS@ @MH_XLIBS@ @MH_EXTRA_LIBS@
+LDFLAGS = $(LIBCURSES) @LDFLAGS@ @LIBS@ @MH_XLIBS@ @MH_EXTRA_LIBS@
+
+RANLIB = @RANLIB@
+
+LIBCURSES = libXCurses.a
+
+LIB_DEPS = -L$(PDCURSES_SRCDIR)/x11 -lXCurses
+
+PDCLIBS = $(LIBCURSES) @SHL_TARGETS@
+
+DEMOS = firework newdemo ptest rain testcurs tuidemo worm xmas
+DEMOOBJS = firework.o newdemo.o ptest.o rain.o testcurs.o tui.o \
+tuidemo.o worm.o xmas.o
+
+SHLFILE = XCurses
+
+all: $(PDCLIBS) $(DEMOS)
+
+install:
+ echo Does nothing at the moment
+
+clean:
+ -rm -rf *.o *.sho trace $(PDCLIBS) $(DEMOS)
+
+demos: $(DEMOS)
+
+distclean: clean
+ -rm -f Makefile
+
+mostlyclean: clean
+
+realclean: distclean
+
+LIBOBJS = addch.o addchstr.o addstr.o attr.o beep.o bkgd.o border.o \
+clear.o color.o delch.o deleteln.o deprec.o getch.o getstr.o getyx.o \
+inch.o inchstr.o initscr.o inopts.o insch.o insstr.o instr.o kernel.o \
+keyname.o mouse.o move.o outopts.o overlay.o pad.o panel.o printw.o \
+refresh.o scanw.o scr_dump.o scroll.o slk.o termattr.o terminfo.o \
+touch.o util.o window.o debug.o
+
+PDCOBJS = pdcclip.o pdcdisp.o pdcgetsc.o pdckbd.o pdcscrn.o pdcsetsc.o \
+pdcutil.o pdcx11.o x11.o sb.o ScrollBox.o
+
+LIBSHOBJS = $(LIBOBJS:.o=.sho)
+PDCSHOBJS = $(PDCOBJS:.o=.sho)
+
+SHOFILES = $(LIBSHOBJS) $(PDCSHOBJS)
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ ar rv $@ $?
+ -$(RANLIB) $@
+
+$(SHLPRE)$(SHLFILE)$(SHLPST) : $(SHOFILES)
+ $(LD_RXLIB1) -o $@ $(SHOFILES) $(LD_RXLIB2)
+
+$(LIBOBJS) $(PDCOBJS) $(SHOFILES) : $(PDCURSES_HEADERS)
+$(PDCOBJS) $(PDCSHOBJS) : $(PDCURSES_X11_H)
+$(DEMOOBJS) : $(PDCURSES_CURSES_H)
+$(DEMOS) : $(LIBCURSES)
+terminfo.o terminfo.sho: $(TERM_HEADER)
+
+addch.o: $(srcdir)/addch.c
+ $(BUILD) $(srcdir)/addch.c
+
+addchstr.o: $(srcdir)/addchstr.c
+ $(BUILD) $(srcdir)/addchstr.c
+
+addstr.o: $(srcdir)/addstr.c
+ $(BUILD) $(srcdir)/addstr.c
+
+attr.o: $(srcdir)/attr.c
+ $(BUILD) $(srcdir)/attr.c
+
+beep.o: $(srcdir)/beep.c
+ $(BUILD) $(srcdir)/beep.c
+
+bkgd.o: $(srcdir)/bkgd.c
+ $(BUILD) $(srcdir)/bkgd.c
+
+border.o: $(srcdir)/border.c
+ $(BUILD) $(srcdir)/border.c
+
+clear.o: $(srcdir)/clear.c
+ $(BUILD) $(srcdir)/clear.c
+
+color.o: $(srcdir)/color.c
+ $(BUILD) $(srcdir)/color.c
+
+delch.o: $(srcdir)/delch.c
+ $(BUILD) $(srcdir)/delch.c
+
+deleteln.o: $(srcdir)/deleteln.c
+ $(BUILD) $(srcdir)/deleteln.c
+
+deprec.o: $(srcdir)/deprec.c
+ $(BUILD) $(srcdir)/deprec.c
+
+getch.o: $(srcdir)/getch.c
+ $(BUILD) $(srcdir)/getch.c
+
+getstr.o: $(srcdir)/getstr.c
+ $(BUILD) $(srcdir)/getstr.c
+
+getyx.o: $(srcdir)/getyx.c
+ $(BUILD) $(srcdir)/getyx.c
+
+inch.o: $(srcdir)/inch.c
+ $(BUILD) $(srcdir)/inch.c
+
+inchstr.o: $(srcdir)/inchstr.c
+ $(BUILD) $(srcdir)/inchstr.c
+
+initscr.o: $(srcdir)/initscr.c
+ $(BUILD) $(srcdir)/initscr.c
+
+inopts.o: $(srcdir)/inopts.c
+ $(BUILD) $(srcdir)/inopts.c
+
+insch.o: $(srcdir)/insch.c
+ $(BUILD) $(srcdir)/insch.c
+
+insstr.o: $(srcdir)/insstr.c
+ $(BUILD) $(srcdir)/insstr.c
+
+instr.o: $(srcdir)/instr.c
+ $(BUILD) $(srcdir)/instr.c
+
+kernel.o: $(srcdir)/kernel.c
+ $(BUILD) $(srcdir)/kernel.c
+
+keyname.o: $(srcdir)/keyname.c
+ $(BUILD) $(srcdir)/keyname.c
+
+mouse.o: $(srcdir)/mouse.c
+ $(BUILD) $(srcdir)/mouse.c
+
+move.o: $(srcdir)/move.c
+ $(BUILD) $(srcdir)/move.c
+
+outopts.o: $(srcdir)/outopts.c
+ $(BUILD) $(srcdir)/outopts.c
+
+overlay.o: $(srcdir)/overlay.c
+ $(BUILD) $(srcdir)/overlay.c
+
+pad.o: $(srcdir)/pad.c
+ $(BUILD) $(srcdir)/pad.c
+
+panel.o: $(srcdir)/panel.c $(PDCURSES_SRCDIR)/panel.h
+ $(BUILD) $(srcdir)/panel.c
+
+printw.o: $(srcdir)/printw.c
+ $(BUILD) $(srcdir)/printw.c
+
+refresh.o: $(srcdir)/refresh.c
+ $(BUILD) $(srcdir)/refresh.c
+
+scanw.o: $(srcdir)/scanw.c
+ $(BUILD) $(srcdir)/scanw.c
+
+scr_dump.o: $(srcdir)/scr_dump.c
+ $(BUILD) $(srcdir)/scr_dump.c
+
+scroll.o: $(srcdir)/scroll.c
+ $(BUILD) $(srcdir)/scroll.c
+
+slk.o: $(srcdir)/slk.c
+ $(BUILD) $(srcdir)/slk.c
+
+termattr.o: $(srcdir)/termattr.c
+ $(BUILD) $(srcdir)/termattr.c
+
+terminfo.o: $(srcdir)/terminfo.c
+ $(BUILD) $(srcdir)/terminfo.c
+
+touch.o: $(srcdir)/touch.c
+ $(BUILD) $(srcdir)/touch.c
+
+util.o: $(srcdir)/util.c
+ $(BUILD) $(srcdir)/util.c
+
+window.o: $(srcdir)/window.c
+ $(BUILD) $(srcdir)/window.c
+
+debug.o: $(srcdir)/debug.c
+ $(BUILD) $(srcdir)/debug.c
+
+pdcclip.o: $(osdir)/pdcclip.c
+ $(BUILD) $(osdir)/pdcclip.c
+
+pdcdisp.o: $(osdir)/pdcdisp.c
+ $(BUILD) $(osdir)/pdcdisp.c
+
+pdcgetsc.o: $(osdir)/pdcgetsc.c
+ $(BUILD) $(osdir)/pdcgetsc.c
+
+pdckbd.o: $(osdir)/pdckbd.c
+ $(BUILD) $(osdir)/pdckbd.c
+
+pdcscrn.o: $(osdir)/pdcscrn.c
+ $(BUILD) $(osdir)/pdcscrn.c
+
+pdcsetsc.o: $(osdir)/pdcsetsc.c
+ $(BUILD) $(osdir)/pdcsetsc.c
+
+pdcutil.o: $(osdir)/pdcutil.c
+ $(BUILD) $(osdir)/pdcutil.c
+
+pdcx11.o: $(osdir)/pdcx11.c
+ $(BUILD) $(osdir)/pdcx11.c
+
+ScrollBox.o: $(osdir)/ScrollBox.c
+ $(BUILD) $(osdir)/ScrollBox.c
+
+sb.o: $(osdir)/sb.c
+ $(BUILD) $(osdir)/sb.c
+
+x11.o: $(osdir)/x11.c
+ $(BUILD) $(osdir)/x11.c
+
+addch.sho: $(srcdir)/addch.c
+ $(DYN_BUILD) $(srcdir)/addch.c
+ @SAVE2O@
+
+addchstr.sho: $(srcdir)/addchstr.c
+ $(DYN_BUILD) $(srcdir)/addchstr.c
+ @SAVE2O@
+
+addstr.sho: $(srcdir)/addstr.c
+ $(DYN_BUILD) $(srcdir)/addstr.c
+ @SAVE2O@
+
+attr.sho: $(srcdir)/attr.c
+ $(DYN_BUILD) $(srcdir)/attr.c
+ @SAVE2O@
+
+beep.sho: $(srcdir)/beep.c
+ $(DYN_BUILD) $(srcdir)/beep.c
+ @SAVE2O@
+
+bkgd.sho: $(srcdir)/bkgd.c
+ $(DYN_BUILD) $(srcdir)/bkgd.c
+ @SAVE2O@
+
+border.sho: $(srcdir)/border.c
+ $(DYN_BUILD) $(srcdir)/border.c
+ @SAVE2O@
+
+clear.sho: $(srcdir)/clear.c
+ $(DYN_BUILD) $(srcdir)/clear.c
+ @SAVE2O@
+
+color.sho: $(srcdir)/color.c
+ $(DYN_BUILD) $(srcdir)/color.c
+ @SAVE2O@
+
+delch.sho: $(srcdir)/delch.c
+ $(DYN_BUILD) $(srcdir)/delch.c
+ @SAVE2O@
+
+deleteln.sho: $(srcdir)/deleteln.c
+ $(DYN_BUILD) $(srcdir)/deleteln.c
+ @SAVE2O@
+
+deprec.sho: $(srcdir)/deprec.c
+ $(DYN_BUILD) $(srcdir)/deprec.c
+ @SAVE2O@
+
+getch.sho: $(srcdir)/getch.c
+ $(DYN_BUILD) $(srcdir)/getch.c
+ @SAVE2O@
+
+getstr.sho: $(srcdir)/getstr.c
+ $(DYN_BUILD) $(srcdir)/getstr.c
+ @SAVE2O@
+
+getyx.sho: $(srcdir)/getyx.c
+ $(DYN_BUILD) $(srcdir)/getyx.c
+ @SAVE2O@
+
+inch.sho: $(srcdir)/inch.c
+ $(DYN_BUILD) $(srcdir)/inch.c
+ @SAVE2O@
+
+inchstr.sho: $(srcdir)/inchstr.c
+ $(DYN_BUILD) $(srcdir)/inchstr.c
+ @SAVE2O@
+
+initscr.sho: $(srcdir)/initscr.c
+ $(DYN_BUILD) $(srcdir)/initscr.c
+ @SAVE2O@
+
+inopts.sho: $(srcdir)/inopts.c
+ $(DYN_BUILD) $(srcdir)/inopts.c
+ @SAVE2O@
+
+insch.sho: $(srcdir)/insch.c
+ $(DYN_BUILD) $(srcdir)/insch.c
+ @SAVE2O@
+
+insstr.sho: $(srcdir)/insstr.c
+ $(DYN_BUILD) $(srcdir)/insstr.c
+ @SAVE2O@
+
+instr.sho: $(srcdir)/instr.c
+ $(DYN_BUILD) $(srcdir)/instr.c
+ @SAVE2O@
+
+kernel.sho: $(srcdir)/kernel.c
+ $(DYN_BUILD) $(srcdir)/kernel.c
+ @SAVE2O@
+
+keyname.sho: $(srcdir)/keyname.c
+ $(DYN_BUILD) $(srcdir)/keyname.c
+ @SAVE2O@
+
+mouse.sho: $(srcdir)/mouse.c
+ $(DYN_BUILD) $(srcdir)/mouse.c
+ @SAVE2O@
+
+move.sho: $(srcdir)/move.c
+ $(DYN_BUILD) $(srcdir)/move.c
+ @SAVE2O@
+
+outopts.sho: $(srcdir)/outopts.c
+ $(DYN_BUILD) $(srcdir)/outopts.c
+ @SAVE2O@
+
+overlay.sho: $(srcdir)/overlay.c
+ $(DYN_BUILD) $(srcdir)/overlay.c
+ @SAVE2O@
+
+pad.sho: $(srcdir)/pad.c
+ $(DYN_BUILD) $(srcdir)/pad.c
+ @SAVE2O@
+
+panel.sho: $(srcdir)/panel.c $(PDCURSES_SRCDIR)/panel.h
+ $(DYN_BUILD) $(srcdir)/panel.c
+ @SAVE2O@
+
+printw.sho: $(srcdir)/printw.c
+ $(DYN_BUILD) $(srcdir)/printw.c
+ @SAVE2O@
+
+refresh.sho: $(srcdir)/refresh.c
+ $(DYN_BUILD) $(srcdir)/refresh.c
+ @SAVE2O@
+
+scanw.sho: $(srcdir)/scanw.c
+ $(DYN_BUILD) $(srcdir)/scanw.c
+ @SAVE2O@
+
+scr_dump.sho: $(srcdir)/scr_dump.c
+ $(DYN_BUILD) $(srcdir)/scr_dump.c
+ @SAVE2O@
+
+scroll.sho: $(srcdir)/scroll.c
+ $(DYN_BUILD) $(srcdir)/scroll.c
+ @SAVE2O@
+
+slk.sho: $(srcdir)/slk.c
+ $(DYN_BUILD) $(srcdir)/slk.c
+ @SAVE2O@
+
+termattr.sho: $(srcdir)/termattr.c
+ $(DYN_BUILD) $(srcdir)/termattr.c
+ @SAVE2O@
+
+terminfo.sho: $(srcdir)/terminfo.c
+ $(DYN_BUILD) $(srcdir)/terminfo.c
+ @SAVE2O@
+
+touch.sho: $(srcdir)/touch.c
+ $(DYN_BUILD) $(srcdir)/touch.c
+ @SAVE2O@
+
+util.sho: $(srcdir)/util.c
+ $(DYN_BUILD) $(srcdir)/util.c
+ @SAVE2O@
+
+window.sho: $(srcdir)/window.c
+ $(DYN_BUILD) $(srcdir)/window.c
+ @SAVE2O@
+
+debug.sho: $(srcdir)/debug.c
+ $(DYN_BUILD) $(srcdir)/debug.c
+ @SAVE2O@
+
+pdcclip.sho: $(osdir)/pdcclip.c
+ $(DYN_BUILD) $(osdir)/pdcclip.c
+ @SAVE2O@
+
+pdcdisp.sho: $(osdir)/pdcdisp.c
+ $(DYN_BUILD) $(osdir)/pdcdisp.c
+ @SAVE2O@
+
+pdcgetsc.sho: $(osdir)/pdcgetsc.c
+ $(DYN_BUILD) $(osdir)/pdcgetsc.c
+ @SAVE2O@
+
+pdckbd.sho: $(osdir)/pdckbd.c
+ $(DYN_BUILD) $(osdir)/pdckbd.c
+ @SAVE2O@
+
+pdcscrn.sho: $(osdir)/pdcscrn.c
+ $(DYN_BUILD) $(osdir)/pdcscrn.c
+ @SAVE2O@
+
+pdcsetsc.sho: $(osdir)/pdcsetsc.c
+ $(DYN_BUILD) $(osdir)/pdcsetsc.c
+ @SAVE2O@
+
+pdcutil.sho: $(osdir)/pdcutil.c
+ $(DYN_BUILD) $(osdir)/pdcutil.c
+ @SAVE2O@
+
+pdcx11.sho: $(osdir)/pdcx11.c
+ $(DYN_BUILD) $(osdir)/pdcx11.c
+ @SAVE2O@
+
+ScrollBox.sho: $(osdir)/ScrollBox.c
+ $(DYN_BUILD) $(osdir)/ScrollBox.c
+ @SAVE2O@
+
+sb.sho: $(osdir)/sb.c
+ $(DYN_BUILD) $(osdir)/sb.c
+ @SAVE2O@
+
+x11.sho: $(osdir)/x11.c
+ $(DYN_BUILD) $(osdir)/x11.c
+ @SAVE2O@
+
+firework: firework.o
+ $(LINK) firework.o -o $@ $(LDFLAGS)
+
+newdemo: newdemo.o
+ $(LINK) newdemo.o -o $@ $(LDFLAGS)
+
+ptest: ptest.o
+ $(LINK) ptest.o -o $@ $(LDFLAGS)
+
+rain: rain.o
+ $(LINK) rain.o -o $@ $(LDFLAGS)
+
+testcurs: testcurs.o
+ $(LINK) testcurs.o -o $@ $(LDFLAGS)
+
+tuidemo: tuidemo.o tui.o
+ $(LINK) tui.o tuidemo.o -o $@ $(LDFLAGS)
+
+worm: worm.o
+ $(LINK) worm.o -o $@ $(LDFLAGS)
+
+xmas: xmas.o
+ $(LINK) xmas.o -o $@ $(LDFLAGS)
+
+firework.o: $(demodir)/firework.c
+ $(BUILD) $(demodir)/firework.c
+
+newdemo.o: $(demodir)/newdemo.c
+ $(BUILD) $(demodir)/newdemo.c
+
+ptest.o: $(demodir)/ptest.c $(PDCURSES_SRCDIR)/panel.h
+ $(BUILD) $(demodir)/ptest.c
+
+rain.o: $(demodir)/rain.c
+ $(BUILD) $(demodir)/rain.c
+
+testcurs.o: $(demodir)/testcurs.c
+ $(BUILD) $(demodir)/testcurs.c
+
+tui.o: $(demodir)/tui.c $(demodir)/tui.h
+ $(BUILD) $(demodir)/tui.c
+
+tuidemo.o: $(demodir)/tuidemo.c
+ $(BUILD) $(demodir)/tuidemo.c
+
+worm.o: $(demodir)/worm.c
+ $(BUILD) $(demodir)/worm.c
+
+xmas.o: $(demodir)/xmas.c
+ $(BUILD) $(demodir)/xmas.c
+
+# This section provides for compiling and linking the
+# ncurses test programs.
+
+ncurses_testdir = $(HOME)/ncurses-5.6/test
+
+NCURSES_TESTS = bs gdc hanoi knight tclock ncurses
+
+ncurses_tests: $(NCURSES_TESTS)
+
+ncurses_clean:
+ -rm -f *.o trace $(NCURSES_TESTS)
+
+NCFLAGS = -I. -I$(ncurses_testdir)
+
+bs: bs.o $(LIBCURSES)
+ $(LINK) bs.o -o $@ $(LDFLAGS)
+
+gdc: gdc.o $(LIBCURSES)
+ $(LINK) gdc.o -o $@ $(LDFLAGS)
+
+hanoi: hanoi.o $(LIBCURSES)
+ $(LINK) hanoi.o -o $@ $(LDFLAGS)
+
+knight: knight.o $(LIBCURSES)
+ $(LINK) knight.o -o $@ $(LDFLAGS)
+
+tclock: tclock.o $(LIBCURSES)
+ $(LINK) tclock.o -o $@ $(LDFLAGS) -lm
+
+view: view.o $(LIBCURSES)
+ $(LINK) view.o -o $@ $(LDFLAGS)
+
+ncurses: ncurses.o $(LIBCURSES)
+ $(LINK) ncurses.o -o $@ $(LDFLAGS)
+
+bs.o: $(ncurses_testdir)/bs.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(NCFLAGS) $(ncurses_testdir)/bs.c
+
+gdc.o: $(ncurses_testdir)/gdc.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(NCFLAGS) $(ncurses_testdir)/gdc.c
+
+hanoi.o: $(ncurses_testdir)/hanoi.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(NCFLAGS) $(ncurses_testdir)/hanoi.c
+
+knight.o: $(ncurses_testdir)/knight.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(NCFLAGS) $(ncurses_testdir)/knight.c
+
+tclock.o: $(ncurses_testdir)/tclock.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(NCFLAGS) $(ncurses_testdir)/tclock.c
+
+view.o: $(ncurses_testdir)/view.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(NCFLAGS) $(ncurses_testdir)/view.c
+
+ncurses.o: $(ncurses_testdir)/ncurses.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(NCFLAGS) $(ncurses_testdir)/ncurses.c
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/README b/payloads/libpayload/curses/PDCurses-3.4/x11/README
new file mode 100644
index 0000000000..37b45d06e7
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/README
@@ -0,0 +1,64 @@
+PDCurses for X11
+================
+
+This is a port of PDCurses for X11, aka XCurses. It is designed to
+allow existing curses programs to be re-compiled with PDCurses,
+resulting in native X11 programs.
+
+
+Building
+--------
+
+. Run "./configure" in the top-level directory.
+
+ To build the wide-character version of the library, specify
+ "--enable-widec" as a parameter. To use X Input Methods, add
+ "--enable-xim". I recommend these options, but I haven't yet made
+ them the defaults, for the sake of backwards compatibility and due to
+ their new and relatively untested status.
+
+ If your system is lacking in UTF-8 support, you can force the use of
+ UTF-8 instead of the system locale via "--enable-force-utf8". This is
+ generally more useful in Windows.
+
+ If configure can't find your X include files or X libraries, you can
+ specify the paths with the arguments "--x-includes=inc_path" and/or
+ "--x-libraries=lib_path".
+
+ By default, the library and demo programs are built with the optimizer
+ switch -O2. You can turn this off, and turn on debugging (-g), by
+ adding "--with-debug" to the configure command.
+
+. Run "make". This should build libXCurses and all the demo programs.
+
+. Optionally, run "make install". curses.h and panel.h will be renamed
+ when installed (to xcurses.h and xpanel.h), to avoid conflicts with
+ any existing curses installations. Unrenamed copies of curses.h and
+ panel.h are installed in (by default) /usr/local/include/xcurses.
+
+ libXpanel is just a symlink to libXCurses. Both curses and panel
+ functions are in the main library.
+
+
+Distribution Status
+-------------------
+
+As of April 13, 2006, the files in this directory are released to the
+Public Domain, except for ScrollBox*, which are under essentially the
+MIT X License.
+
+
+To be Done
+----------
+
+- have newterm() create a new X window
+
+- provide a command line parsing function to enable X command line
+ arguments to be parsed and stripped from the arguments passed back
+ to the calling procedure.
+
+
+Acknowledgements
+----------------
+
+X11 port was provided by Mark Hessling <mark@rexx.org>
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.c b/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.c
new file mode 100644
index 0000000000..48ea38fd6c
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.c
@@ -0,0 +1,321 @@
+/*
+ * Copyright 1989 O'Reilly and Associates, Inc.
+
+ The X Consortium, and any party obtaining a copy of these files from
+ the X Consortium, directly or indirectly, is granted, free of charge, a
+ full and unrestricted irrevocable, world-wide, paid up, royalty-free,
+ nonexclusive right and license to deal in this software and
+ documentation files (the "Software"), including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons who receive
+ copies from any such party to do so. This license includes without
+ limitation a license to do the foregoing actions under any patents of
+ the party supplying this software to the X Consortium.
+
+ $Id: ScrollBox.c,v 1.15 2008/07/14 04:24:52 wmcbrine Exp $
+ */
+
+/* ScrollBox.c - scrollBox composite widget */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+
+#include "x11/ScrollBoxP.h"
+
+#include <stdio.h>
+
+#define INITIAL_WIDTH 300
+#define INITIAL_HEIGHT 300
+
+/************************************************************************
+ * *
+ * scrollBox Resources *
+ * *
+ ************************************************************************/
+
+static XtResource resources[] =
+{
+ { XtNhSpace, XtCHSpace, XtRDimension, sizeof(Dimension),
+ XtOffset(ScrollBoxWidget, scrollBox.h_space),
+ XtRImmediate, (XtPointer)4 },
+ { XtNvSpace, XtCVSpace, XtRDimension, sizeof(Dimension),
+ XtOffset(ScrollBoxWidget, scrollBox.v_space),
+ XtRImmediate, (XtPointer)4 },
+ { XtNheightInc, XtCHeightInc, XtRDimension, sizeof(Dimension),
+ XtOffset(ScrollBoxWidget, scrollBox.increment_height),
+ XtRImmediate, (XtPointer)13 },
+ { XtNwidthInc, XtCWidthInc, XtRDimension, sizeof(Dimension),
+ XtOffset(ScrollBoxWidget, scrollBox.increment_width),
+ XtRImmediate, (XtPointer)7 },
+};
+
+/************************************************************************
+ * *
+ * Full class record constant *
+ * *
+ ************************************************************************/
+
+static void Initialize(Widget, Widget, ArgList, Cardinal *);
+static void Resize(Widget);
+static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal *);
+static void ChangeManaged(Widget);
+static XtGeometryResult QueryGeometry(Widget, XtWidgetGeometry *,
+ XtWidgetGeometry *);
+static XtGeometryResult GeometryManager(Widget, XtWidgetGeometry *,
+ XtWidgetGeometry *);
+static void RefigureLocations(Widget);
+
+ScrollBoxClassRec scrollBoxClassRec = {
+ {
+ /* core_class fields */
+ /* superclass */ (WidgetClass) &compositeClassRec,
+ /* class_name */ "scrollBox",
+ /* widget_size */ sizeof(ScrollBoxRec),
+ /* class_initialize */ NULL,
+ /* class_part_init */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ Resize,
+ /* expose */ NULL,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ QueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },{
+ /* composite_class fields */
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },{
+ /* scrollBox class fields */
+ /* empty */ 0,
+ }
+};
+
+WidgetClass scrollBoxWidgetClass = (WidgetClass)&scrollBoxClassRec;
+
+
+/************************************************************************
+ * *
+ * Private Routines *
+ * *
+ ************************************************************************/
+
+/* Do a layout, either actually assigning positions, or just
+ calculating size. */
+
+static void DoLayout(Widget w, Boolean doit)
+{
+ ScrollBoxWidget sbw = (ScrollBoxWidget)w;
+ Widget wmain, vscroll, hscroll, child;
+ Dimension mw, mh; /* main window */
+ Dimension vh; /* vertical scrollbar length (height) */
+ Dimension hw; /* horizontal scrollbar length (width) */
+ Position vx;
+ Position hy;
+ Cardinal i;
+
+ if (sbw->composite.num_children != 3)
+ XtAppError(XtWidgetToApplicationContext(w),
+ "ScrollBox: must manage exactly three widgets.");
+
+ for (i = 0; i < sbw->composite.num_children; i++)
+ {
+ child = sbw->composite.children[i];
+
+ if (!XtIsManaged(child))
+ XtAppError(XtWidgetToApplicationContext(w),
+ "ScrollBox: all three widgets must be managed.");
+ }
+
+ /* Child one is the main window, two is the vertical scrollbar,
+ and three is the horizontal scrollbar. */
+
+ wmain = sbw->composite.children[0];
+ vscroll = sbw->composite.children[1];
+ hscroll = sbw->composite.children[2];
+
+ /* Size all three widgets so that space is fully utilized. */
+
+ mw = sbw->core.width - (2 * sbw->scrollBox.h_space) -
+ vscroll->core.width - (2 * vscroll->core.border_width) -
+ (2 * wmain->core.border_width);
+
+ mh = sbw->core.height - (2 * sbw->scrollBox.v_space) -
+ hscroll->core.height - (2 * hscroll->core.border_width) -
+ (2 * wmain->core.border_width);
+
+ /* Force the main window to be sized to the appropriate increment. */
+
+ mw = (mw / sbw->scrollBox.increment_width) *
+ sbw->scrollBox.increment_width;
+
+ mh = ((mh / sbw->scrollBox.increment_height) *
+ sbw->scrollBox.increment_height) +
+ sbw->scrollBox.increment_height;
+
+ vx = wmain->core.x + mw + sbw->scrollBox.h_space +
+ wmain->core.border_width + vscroll->core.border_width;
+
+ hy = wmain->core.y + mh + sbw->scrollBox.v_space +
+ wmain->core.border_width + hscroll->core.border_width;
+
+ vh = mh; /* scrollbars are always same length as main window */
+ hw = mw;
+
+ if (doit)
+ {
+ XtResizeWidget(wmain, mw, mh, 1);
+
+ XtResizeWidget(vscroll, vscroll->core.width, vh, 1);
+ XtMoveWidget(vscroll, vx, vscroll->core.y);
+
+ XtResizeWidget(hscroll, hw, hscroll->core.height, 1);
+ XtMoveWidget(hscroll, hscroll->core.x, hy);
+ }
+}
+
+static XtGeometryResult GeometryManager(Widget w, XtWidgetGeometry *request,
+ XtWidgetGeometry *reply)
+{
+ XtWidgetGeometry allowed;
+
+ if (request->request_mode & ~(XtCWQueryOnly | CWWidth | CWHeight))
+ return XtGeometryNo;
+
+ if (request->request_mode & CWWidth)
+ allowed.width = request->width;
+ else
+ allowed.width = w->core.width;
+
+ if (request->request_mode & CWHeight)
+ allowed.height = request->height;
+ else
+ allowed.height = w->core.height;
+
+ if (allowed.width == w->core.width && allowed.height == w->core.height)
+ return XtGeometryNo;
+
+ if (!(request->request_mode & XtCWQueryOnly))
+ RefigureLocations(w);
+
+ return XtGeometryYes;
+}
+
+static void RefigureLocations(Widget w)
+{
+ DoLayout(w, False);
+}
+
+/* Calculate preferred size. We can't just use the current sizes
+ of the children, because that calculation would always end up with
+ our current size. Could query each child, and use that size to
+ recalculate a size for us, then if it ends up being larger than width
+ and height passed in, accept bounding box. However, we know our
+ children and they don't have any particular preferred geometry,
+ except the bigger the better. Therefore, if the parent suggested a
+ size, we'll take it. */
+
+static XtGeometryResult QueryGeometry(Widget w, XtWidgetGeometry *request,
+ XtWidgetGeometry *reply_return)
+{
+ XtGeometryResult result=XtGeometryNo;
+
+ request->request_mode &= CWWidth | CWHeight;
+
+ /* parent isn't going to change w or h, so nothing to re-compute */
+
+ if (request->request_mode == 0)
+ return XtGeometryYes;
+
+ /* if proposed size is large enough, accept it. Otherwise, suggest
+ our arbitrary initial size. */
+
+ if (request->request_mode & CWHeight)
+ {
+ if (request->height < INITIAL_HEIGHT)
+ {
+ result = XtGeometryAlmost;
+ reply_return->height = INITIAL_HEIGHT;
+ reply_return->request_mode &= CWHeight;
+ }
+ else
+ result = XtGeometryYes;
+ }
+
+ if (request->request_mode & CWWidth)
+ {
+ if (request->width < INITIAL_WIDTH)
+ {
+ result = XtGeometryAlmost;
+ reply_return->width = INITIAL_WIDTH;
+ reply_return->request_mode &= CWWidth;
+ }
+ else
+ result = XtGeometryYes;
+ }
+
+ return result;
+}
+
+/* Actually layout the scrollBox */
+
+static void Resize(Widget w)
+{
+ DoLayout(w, True);
+}
+
+static void ChangeManaged(Widget w)
+{
+ DoLayout(w, True);
+}
+
+static void Initialize(Widget request, Widget new,
+ ArgList args, Cardinal *num_args)
+{
+ ScrollBoxWidget newsbw = (ScrollBoxWidget)new;
+
+ if (newsbw->core.width == 0)
+ newsbw->core.width = INITIAL_WIDTH;
+
+ if (newsbw->core.height == 0)
+ newsbw->core.height = INITIAL_HEIGHT;
+
+}
+
+static Boolean SetValues(Widget current, Widget request, Widget new,
+ ArgList args, Cardinal *num_args)
+{
+ ScrollBoxWidget sbwcurrent = (ScrollBoxWidget)current;
+ ScrollBoxWidget sbwnew = (ScrollBoxWidget)new;
+
+ /* need to relayout if h_space or v_space change */
+
+ if ((sbwnew->scrollBox.h_space != sbwcurrent->scrollBox.h_space) ||
+ (sbwnew->scrollBox.v_space != sbwcurrent->scrollBox.v_space))
+ DoLayout(new, True);
+
+ return False;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.h b/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.h
new file mode 100644
index 0000000000..5825862744
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 1989 O'Reilly and Associates, Inc.
+
+ The X Consortium, and any party obtaining a copy of these files from
+ the X Consortium, directly or indirectly, is granted, free of charge, a
+ full and unrestricted irrevocable, world-wide, paid up, royalty-free,
+ nonexclusive right and license to deal in this software and
+ documentation files (the "Software"), including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons who receive
+ copies from any such party to do so. This license includes without
+ limitation a license to do the foregoing actions under any patents of
+ the party supplying this software to the X Consortium.
+
+ $Id: ScrollBox.h,v 1.4 2008/07/14 04:24:52 wmcbrine Exp $
+ */
+
+#ifndef _XORAscrollBox_h
+#define _XORAscrollBox_h
+
+/************************************************************************
+ * *
+ * scrollBox Widget (subclass of CompositeClass) *
+ * *
+ ************************************************************************/
+
+/* Parameters:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ destroyCallback Callback Pointer NULL
+ hSpace HSpace Dimension 4
+ height Height Dimension 0
+ mappedWhenManaged MappedWhenManaged Boolean True
+ vSpace VSpace Dimension 4
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+
+/* Class record constants */
+
+extern WidgetClass scrollBoxWidgetClass;
+
+typedef struct _ScrollBoxClassRec *ScrollBoxWidgetClass;
+typedef struct _ScrollBoxRec *ScrollBoxWidget;
+
+#endif /* _XORAscrollBox_h */
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBoxP.h b/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBoxP.h
new file mode 100644
index 0000000000..069666da2f
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBoxP.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright 1989 O'Reilly and Associates, Inc.
+
+ The X Consortium, and any party obtaining a copy of these files from
+ the X Consortium, directly or indirectly, is granted, free of charge, a
+ full and unrestricted irrevocable, world-wide, paid up, royalty-free,
+ nonexclusive right and license to deal in this software and
+ documentation files (the "Software"), including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons who receive
+ copies from any such party to do so. This license includes without
+ limitation a license to do the foregoing actions under any patents of
+ the party supplying this software to the X Consortium.
+
+ $Id: ScrollBoxP.h,v 1.5 2008/07/14 04:24:52 wmcbrine Exp $
+ */
+
+/*
+ * scrollBoxP.h - Private definitions for scrollBox widget
+ *
+ */
+
+#ifndef _XORAscrollBoxP_h
+#define _XORAscrollBoxP_h
+
+/************************************************************************
+ * *
+ * scrollBox Widget Private Data *
+ * *
+ ************************************************************************/
+
+#include "x11/ScrollBox.h"
+
+#include <X11/CompositeP.h>
+
+/* New fields for the scrollBox widget class record */
+typedef struct _ScrollBoxClass {
+ int empty;
+} ScrollBoxClassPart;
+
+/* Full class record declaration */
+typedef struct _ScrollBoxClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ScrollBoxClassPart scrollBox_class;
+} ScrollBoxClassRec;
+
+extern ScrollBoxClassRec scrollBoxClassRec;
+
+/* New fields for the scrollBox widget record */
+typedef struct {
+ Dimension h_space, v_space;
+ Dimension preferred_width, preferred_height;
+ Dimension last_query_width, last_query_height;
+ Dimension increment_width, increment_height;
+ XtGeometryMask last_query_mode;
+} ScrollBoxPart;
+
+
+/************************************************************************
+ * *
+ * Full instance record declaration *
+ * *
+ ************************************************************************/
+
+typedef struct _ScrollBoxRec {
+ CorePart core;
+ CompositePart composite;
+ ScrollBoxPart scrollBox;
+} ScrollBoxRec;
+
+#endif /* _XORAscrollBoxP_h */
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/big_icon.xbm b/payloads/libpayload/curses/PDCurses-3.4/x11/big_icon.xbm
new file mode 100644
index 0000000000..04b98a5bf5
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/big_icon.xbm
@@ -0,0 +1,46 @@
+#define big_icon_width 64
+#define big_icon_height 64
+static unsigned char big_icon_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
+ 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xc1, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0xff, 0xc3, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
+ 0xc3, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc0, 0xc7, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x80, 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x80,
+ 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x80, 0xc7, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x80, 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc0,
+ 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xe0, 0xc3, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0xf0, 0xe3, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf8,
+ 0xf1, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xfc, 0xf8, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x7e, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f,
+ 0xfe, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0xff, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x8f, 0xdf, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc7,
+ 0xcf, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xe3, 0xc7, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0xf1, 0xc3, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0,
+ 0xc1, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf8, 0xc0, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x78, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x78,
+ 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x78, 0xc0, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x78, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf8,
+ 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xff, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0xf0, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xe0,
+ 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc0, 0xff, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x23, 0x50, 0x1e,
+ 0x7c, 0xf0, 0xe0, 0x03, 0x60, 0x26, 0x50, 0x33, 0xc6, 0x98, 0x31, 0x06,
+ 0x30, 0x2c, 0xd0, 0x61, 0x83, 0x0d, 0x1b, 0x0c, 0x10, 0x28, 0xd0, 0x40,
+ 0x01, 0x05, 0x0a, 0x08, 0x10, 0x20, 0x50, 0x00, 0x01, 0x05, 0x0a, 0x08,
+ 0x10, 0x20, 0x50, 0x00, 0x03, 0x04, 0x1a, 0x00, 0x10, 0x20, 0x50, 0x00,
+ 0x06, 0x04, 0x32, 0x00, 0x10, 0x20, 0x50, 0x00, 0x7c, 0xfc, 0xe3, 0x03,
+ 0x10, 0x20, 0x50, 0x00, 0xc0, 0x04, 0x00, 0x06, 0x10, 0x20, 0x50, 0x00,
+ 0x80, 0x05, 0x00, 0x0c, 0x10, 0x20, 0x50, 0x00, 0x01, 0x05, 0x0a, 0x08,
+ 0x10, 0x28, 0x50, 0x00, 0x01, 0x05, 0x0a, 0x08, 0x30, 0x6c, 0x58, 0x00,
+ 0x83, 0x0d, 0x1b, 0x0c, 0x60, 0xc6, 0x4c, 0x00, 0xc6, 0x98, 0x31, 0x06,
+ 0xc0, 0x83, 0x47, 0x00, 0x7c, 0xf0, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/compose.h b/payloads/libpayload/curses/PDCurses-3.4/x11/compose.h
new file mode 100644
index 0000000000..12b85fa133
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/compose.h
@@ -0,0 +1,203 @@
+/* Public Domain Curses */
+
+/* $Id: compose.h,v 1.3 2008/07/14 04:24:52 wmcbrine Exp $ */
+
+/* Tables and variables for the built-in compose key system. This file
+ is not included when PDCurses is built with XIM support. */
+
+#define MAX_COMPOSE_CHARS 14
+#define MAX_COMPOSE_PRE 60
+
+static const char *compose_chars =
+ "`'~^,/\"AaPpSs!?0123CcRr-_<>Xx.=Yy |EeIiOoUu+NnLlgDd:*TtMmVv";
+
+/*
+ ` : À È Ì Ò Ù à è ì ò ù
+ ' : ´ Á É Í Ó Ú Ý á é í ó ú ý ´
+ ~ : Ã Ñ Õ ã ñ õ
+ ^ : Â Ê Î Ô Û â ê î ô û ° ¹ ² ³
+ , : ¸ Ç ç ¸
+ / : Ø ø µ µ
+ " : ¨ Ä Ë Ï Ö Ü ä ë ï ö ü ÿ ¨
+ A : Æ À Á Ã Â Å Å Ã Â ª
+ a : æ à á ã â å å ã â ª
+ P : Þ ¶ ¶
+ p : þ ¶ ¶
+ S : § § § º ª
+ s : ß § ª ¹ ² ³ º §
+ ! : ¡ ¡
+ ? : ¿ ¿
+ 0 : ° °
+ 1 : ¹ ½ ¼ ¹
+ 2 : ² ²
+ 3 : ³ ¾ ³
+ C : © Ç ¢ ¢
+ c : ¢ © ç ¢ ¢
+ R : ®
+ r : ®
+ - : ­ ± ¬ ­ ¯ ÷
+ _ : ¯ ¯
+ < : «
+ > : «
+ X : ¤ ×
+ x : × ¤ ×
+ . : · · ·
+ = : ¥ ¥
+ Y : ¥ Ý ¥
+ y : ¥ ý ÿ ¥ ¥
+ :
+ | : ¦ ¢ ¦ Þ þ ¦ £
+ E : È É Ê Ë Ê
+ e : è é ê ë ê
+ I : Ì Í Î Ï Î
+ i : ì í î ï î
+ O : Ò Ó Ô Õ Ö Ø © ® Õ Ô Å å
+ o : ° Å å ¤ õ ò ó ô õ ö ø ô º
+ U : Ù Ú Û Ü Û
+ u : ù ú û ü µ û
+ + : ±
+ N : Ñ Ñ ¬
+ n : ñ ñ ¬
+ L : £ £ £
+ l : £ £ £
+ g : ¤
+ D : ° Ð
+ d : ° ð
+ : : ÷
+ * : µ µ å Å
+ T : Þ
+ t : þ
+ M : ×
+ m : ×
+ V : ¦
+ v : ¦
+*/
+
+static const char compose_lookups[MAX_COMPOSE_PRE][MAX_COMPOSE_CHARS] =
+{
+/* ` */ {'A','E','I','O','U','a','e','i','o','u', 0, 0, 0, 0},
+/* ' */ {' ','A','E','I','O','U','Y','a','e','i','o','u','y', 39},
+/* ~ */ {'A','N','O','a','n','o', 0, 0, 0, 0, 0, 0, 0, 0},
+/* ^ */ {'A','E','I','O','U','a','e','i','o','u','0','1','2','3'},
+/* , */ {' ','C','c',',', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* / */ {'O','o','u','U', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* " */ {' ','A','E','I','O','U','a','e','i','o','u','y','\"', 0},
+/* A */ {'E','`', 39,'~','^','"','o','*','-','>','_', 0, 0, 0},
+/* a */ {'e','`', 39,'~','^','"','o','*','-','>','_', 0, 0, 0},
+/* P */ {' ','G','!', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* p */ {' ','g','!', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* S */ {'S','!','O','0','A', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* s */ {'s','!','a','1','2','3','0','o', 0, 0, 0, 0, 0, 0},
+/* ! */ {' ','!', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* ? */ {' ','?', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 0 */ {'^','*', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 1 */ {' ','2','4','^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 2 */ {' ','^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 3 */ {' ','4','^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* C */ {'O',',','$','|', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* c */ {'|','o',',','/','$', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* R */ {'O', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* r */ {'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* - */ {' ','+',',','-','^',':', 0, 0, 0, 0, 0, 0, 0, 0},
+/* _ */ {'_','^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* < */ {'<', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* > */ {'>', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* X */ {'O','X', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* x */ {' ','o','x', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* . */ {' ','^','.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* = */ {'Y','y', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* Y */ {'=', 39,'-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* y */ {'=', 39,'"','$','-', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* */ {' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* | */ {' ','c','|','P','p','^','-', 0, 0, 0, 0, 0, 0, 0},
+/* E */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* e */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* I */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* i */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* O */ {'`', 39,'^','~','"','/','C','R','-','>','A','a', 0, 0},
+/* o */ {' ','A','a','x','-','`', 39,'^','~','"','/','>','_', 0},
+/* U */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* u */ {'`', 39,'^','"',' ','>', 0, 0, 0, 0, 0, 0, 0, 0},
+/* + */ {'-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* N */ {'~','-','O', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* n */ {'~','-','o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* L */ {'$','=','-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* l */ {'$','=','-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* g */ {'$', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* D */ {'E','-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* d */ {'e','-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* : */ {'-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* * */ {'m','M','a','A', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* T */ {'H', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* t */ {'h', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* M */ {'U', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* m */ {'u', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* V */ {'B', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* v */ {'b', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+};
+
+static const unsigned char compose_keys[MAX_COMPOSE_PRE][MAX_COMPOSE_CHARS] =
+{
+/* ` */ {192,200,204,210,217,224,232,236,242,249, 0, 0, 0, 0},
+/* ' */ {180,193,201,205,211,218,221,225,233,237,243,250,253,180},
+/* ~ */ {195,209,213,227,241,245, 0, 0, 0, 0, 0, 0, 0, 0},
+/* ^ */ {194,202,206,212,219,226,234,238,244,251,176,185,178,179},
+/* , */ {184,199,231,184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* / */ {216,248,181,181, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* " */ {168,196,203,207,214,220,228,235,239,246,252,255,168, 0},
+/* A */ {198,192,193,195,194,196,197,197,195,194,170, 0, 0, 0},
+/* a */ {230,224,225,227,226,228,229,229,227,226,170, 0, 0, 0},
+/* P */ {222,182,182, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* p */ {254,182,182, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* S */ {167,167,167,186,170, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* s */ {223,167,170,185,178,179,186,167, 0, 0, 0, 0, 0, 0},
+/* ! */ {161,161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* ? */ {191,191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 0 */ {176,176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 1 */ {185,189,188,185, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 2 */ {178,178, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 3 */ {179,190,179, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* C */ {169,199,162,162, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* c */ {162,169,231,162,162, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* R */ {174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* r */ {174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* - */ {173,177,172,173,175,247, 0, 0, 0, 0, 0, 0, 0, 0},
+/* _ */ {175,175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* < */ {171, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* > */ {187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* X */ {164,215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* x */ {215,164,215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* . */ {183,183,183, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* = */ {165,165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* Y */ {165,221,165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* y */ {165,253,255,165,165, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* */ {160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* | */ {166,162,166,222,254,166,163, 0, 0, 0, 0, 0, 0, 0},
+/* E */ {200,201,202,203,202, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* e */ {232,233,234,235,234, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* I */ {204,205,206,207,206, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* i */ {236,237,238,239,238, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* O */ {210,211,212,213,214,216,169,174,213,212,197,229, 0, 0},
+/* o */ {176,197,229,164,245,242,243,244,245,246,248,244,186, 0},
+/* U */ {217,218,219,220,219, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* u */ {249,250,251,252,181,251, 0, 0, 0, 0, 0, 0, 0, 0},
+/* + */ {177, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* N */ {209,209,172, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* n */ {241,241,172, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* L */ {163,163,163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* l */ {163,163,163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* g */ {164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* D */ {176,208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* d */ {176,240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* : */ {247, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* * */ {181,181,229,197, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* T */ {222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* t */ {254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* M */ {215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* u */ {215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* V */ {166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* v */ {166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+};
+
+static KeySym compose_key = 0;
+static int compose_mask = 0;
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/little_icon.xbm b/payloads/libpayload/curses/PDCurses-3.4/x11/little_icon.xbm
new file mode 100644
index 0000000000..d3e777e8df
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/little_icon.xbm
@@ -0,0 +1,14 @@
+#define little_icon_width 32
+#define little_icon_height 32
+static unsigned char little_icon_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfc, 0x30, 0x00, 0x00, 0xfc, 0x31, 0x00, 0x00, 0x8c, 0x33, 0x00,
+ 0x00, 0x0c, 0x33, 0x00, 0x00, 0x0c, 0x33, 0x00, 0x00, 0x8c, 0x33, 0x00,
+ 0x00, 0xcc, 0x39, 0x00, 0x00, 0xec, 0x3c, 0x00, 0x00, 0x7c, 0x3e, 0x00,
+ 0x00, 0x3c, 0x37, 0x00, 0x00, 0x9c, 0x33, 0x00, 0x00, 0xcc, 0x31, 0x00,
+ 0x00, 0xcc, 0x30, 0x00, 0x00, 0xcc, 0x30, 0x00, 0x00, 0xcc, 0x31, 0x00,
+ 0x00, 0x8c, 0x3f, 0x00, 0x00, 0x0c, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x4c, 0x2a, 0xc6, 0x18, 0x52, 0x5a, 0x29, 0x25,
+ 0x42, 0x0a, 0x21, 0x05, 0x42, 0x0a, 0xe6, 0x18, 0x42, 0x0a, 0x28, 0x20,
+ 0x52, 0x0a, 0x29, 0x25, 0x8c, 0x09, 0xc6, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/ncurses_cfg.h b/payloads/libpayload/curses/PDCurses-3.4/x11/ncurses_cfg.h
new file mode 100644
index 0000000000..42571180b2
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/ncurses_cfg.h
@@ -0,0 +1,47 @@
+/* $Id: ncurses_cfg.h,v 1.8 2006/12/28 01:02:03 wmcbrine Exp $
+ *
+ * This file is only used with the ncurses test programs.
+ *
+ * Have ncurses-5.6 unpacked in your $(HOME) (you don't need to build
+ * it), or edit ncurses_testdir appropriately in the Makefile. Configure
+ * and build PDCurses for X11. (Sorry, other ports won't work yet.)
+ * Change to this directory, and:
+ *
+ * "make ncurses_tests" to start.
+ * "make ncurses_clean" when you're done.
+ *
+ * Builds: bs gdc hanoi knight tclock ncurses
+ */
+
+#define NCURSES_MOUSE_VERSION 2
+
+#include "../config.h"
+#include <curses.h>
+
+#define ExitProgram exit
+
+#define HAVE_CURSES_VERSION 1
+#define HAVE_GETBEGX 1
+#define HAVE_GETCURX 1
+#define HAVE_GETMAXX 1
+#define HAVE_GETNSTR 1
+#define HAVE_GETTIMEOFDAY 1
+#define HAVE_GETWIN 1
+#define HAVE_LIBPANEL 1
+#define HAVE_LOCALE_H 1
+#define HAVE_NAPMS 1
+#define HAVE_PANEL_H 1
+#define HAVE_PUTWIN 1
+#define HAVE_SLK_COLOR 1
+#define HAVE_SLK_INIT 1
+#define HAVE_WRESIZE 1
+
+#ifdef PDC_WIDE
+# define USE_WIDEC_SUPPORT 1
+#endif
+
+/* Fool ncurses.c so it gives us all the tests, and doesn't redefine
+ ACS_ chars
+*/
+
+#define NCURSES_VERSION PDCURSES
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcclip.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcclip.c
new file mode 100644
index 0000000000..1a3ce92a2d
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcclip.c
@@ -0,0 +1,170 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdcclip.c,v 1.35 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#include <stdlib.h>
+
+/*man-start**************************************************************
+
+ Name: clipboard
+
+ Synopsis:
+ int PDC_getclipboard(char **contents, long *length);
+ int PDC_setclipboard(const char *contents, long length);
+ int PDC_freeclipboard(char *contents);
+ int PDC_clearclipboard(void);
+
+ Description:
+ PDC_getclipboard() gets the textual contents of the system's
+ clipboard. This function returns the contents of the clipboard
+ in the contents argument. It is the responsibilitiy of the
+ caller to free the memory returned, via PDC_freeclipboard().
+ The length of the clipboard contents is returned in the length
+ argument.
+
+ PDC_setclipboard copies the supplied text into the system's
+ clipboard, emptying the clipboard prior to the copy.
+
+ PDC_clearclipboard() clears the internal clipboard.
+
+ Return Values:
+ indicator of success/failure of call.
+ PDC_CLIP_SUCCESS the call was successful
+ PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
+ the clipboard contents
+ PDC_CLIP_EMPTY the clipboard contains no text
+ PDC_CLIP_ACCESS_ERROR no clipboard support
+
+ Portability X/Open BSD SYS V
+ PDC_getclipboard - - -
+ PDC_setclipboard - - -
+ PDC_freeclipboard - - -
+ PDC_clearclipboard - - -
+
+**man-end****************************************************************/
+
+int PDC_getclipboard(char **contents, long *length)
+{
+#ifdef PDC_WIDE
+ wchar_t *wcontents;
+#endif
+ int result = 0;
+ int len;
+
+ PDC_LOG(("PDC_getclipboard() - called\n"));
+
+ XCursesInstructAndWait(CURSES_GET_SELECTION);
+
+ if (XC_read_socket(xc_display_sock, &result, sizeof(int)) < 0)
+ XCursesExitCursesProcess(5, "exiting from PDC_getclipboard");
+
+ if (result == PDC_CLIP_SUCCESS)
+ {
+ if (XC_read_socket(xc_display_sock, &len, sizeof(int)) < 0)
+ XCursesExitCursesProcess(5, "exiting from PDC_getclipboard");
+#ifdef PDC_WIDE
+ wcontents = malloc((len + 1) * sizeof(wchar_t));
+ *contents = malloc(len * 3 + 1);
+
+ if (!wcontents || !*contents)
+#else
+ *contents = malloc(len + 1);
+
+ if (!*contents)
+#endif
+ XCursesExitCursesProcess(6, "exiting from PDC_getclipboard - "
+ "synchronization error");
+
+ if (len)
+ {
+ if (XC_read_socket(xc_display_sock,
+#ifdef PDC_WIDE
+ wcontents, len * sizeof(wchar_t)) < 0)
+#else
+ *contents, len) < 0)
+#endif
+ XCursesExitCursesProcess(5, "exiting from PDC_getclipboard");
+ }
+
+#ifdef PDC_WIDE
+ wcontents[len] = 0;
+ len = PDC_wcstombs(*contents, wcontents, len * 3);
+ free(wcontents);
+#endif
+ (*contents)[len] = '\0';
+ *length = len;
+ }
+
+ return result;
+}
+
+int PDC_setclipboard(const char *contents, long length)
+{
+#ifdef PDC_WIDE
+ wchar_t *wcontents;
+#endif
+ int rc;
+
+ PDC_LOG(("PDC_setclipboard() - called\n"));
+
+#ifdef PDC_WIDE
+ wcontents = malloc((length + 1) * sizeof(wchar_t));
+ if (!wcontents)
+ return PDC_CLIP_MEMORY_ERROR;
+
+ length = PDC_mbstowcs(wcontents, contents, length);
+#endif
+ XCursesInstruct(CURSES_SET_SELECTION);
+
+ /* Write, then wait for X to do its stuff; expect return code. */
+
+ if (XC_write_socket(xc_display_sock, &length, sizeof(long)) >= 0)
+ {
+ if (XC_write_socket(xc_display_sock,
+#ifdef PDC_WIDE
+ wcontents, length * sizeof(wchar_t)) >= 0)
+ {
+ free(wcontents);
+#else
+ contents, length) >= 0)
+ {
+#endif
+ if (XC_read_socket(xc_display_sock, &rc, sizeof(int)) >= 0)
+ return rc;
+ }
+ }
+
+ XCursesExitCursesProcess(5, "exiting from PDC_setclipboard");
+
+ return PDC_CLIP_ACCESS_ERROR; /* not reached */
+}
+
+int PDC_freeclipboard(char *contents)
+{
+ PDC_LOG(("PDC_freeclipboard() - called\n"));
+
+ free(contents);
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_clearclipboard(void)
+{
+ int rc;
+ long len = 0;
+
+ PDC_LOG(("PDC_clearclipboard() - called\n"));
+
+ XCursesInstruct(CURSES_CLEAR_SELECTION);
+
+ /* Write, then wait for X to do its stuff; expect return code. */
+
+ if (XC_write_socket(xc_display_sock, &len, sizeof(long)) >= 0)
+ if (XC_read_socket(xc_display_sock, &rc, sizeof(int)) >= 0)
+ return rc;
+
+ XCursesExitCursesProcess(5, "exiting from PDC_clearclipboard");
+
+ return PDC_CLIP_ACCESS_ERROR; /* not reached */
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcdisp.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcdisp.c
new file mode 100644
index 0000000000..3700edb558
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcdisp.c
@@ -0,0 +1,132 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdcdisp.c,v 1.46 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#include <string.h>
+
+#ifdef CHTYPE_LONG
+
+# define A(x) ((chtype)x | A_ALTCHARSET)
+
+chtype acs_map[128] =
+{
+ A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), A(10),
+ A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18), A(19),
+ A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27), A(28),
+ A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&', '\'', '(',
+ ')', '*',
+
+# ifdef PDC_WIDE
+ 0x2192, 0x2190, 0x2191, 0x2193,
+# else
+ '>', '<', '^', 'v',
+# endif
+
+ '/',
+
+# ifdef PDC_WIDE
+ 0x2588,
+# else
+ A(0),
+# endif
+
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
+ '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+ 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+
+# ifdef PDC_WIDE
+ 0x2666, 0x2592,
+# else
+ A(1), A(2),
+# endif
+
+ 'b', 'c', 'd', 'e',
+
+# ifdef PDC_WIDE
+ 0x00b0, 0x00b1, 0x2591, 0x00a4, 0x2518, 0x2510, 0x250c, 0x2514,
+ 0x253c, 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524,
+ 0x2534, 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3,
+ 0x00b7,
+# else
+ A(7), A(8), '#', 0xa4, A(11), A(12), A(13), A(14), A(15), A(16),
+ A(17), A(18), A(19), A(20), A(21), A(22), A(23), A(24), A(25),
+ A(26), A(27), A(28), A(29), A(30), 0xb7,
+# endif
+
+ A(127)
+};
+
+# undef A
+
+#endif
+
+int PDC_display_cursor(int oldrow, int oldcol, int newrow, int newcol,
+ int visibility)
+{
+ char buf[30];
+ int idx, pos;
+
+ PDC_LOG(("%s:PDC_display_cursor() - called: NEW row %d col %d, vis %d\n",
+ XCLOGMSG, newrow, newcol, visibility));
+
+ if (visibility == -1)
+ {
+ /* Only send the CURSES_DISPLAY_CURSOR message, no data */
+
+ idx = CURSES_DISPLAY_CURSOR;
+ memcpy(buf, &idx, sizeof(int));
+ idx = sizeof(int);
+ }
+ else
+ {
+ idx = CURSES_CURSOR;
+ memcpy(buf, &idx, sizeof(int));
+
+ idx = sizeof(int);
+ pos = oldrow + (oldcol << 8);
+ memcpy(buf + idx, &pos, sizeof(int));
+
+ idx += sizeof(int);
+ pos = newrow + (newcol << 8);
+ memcpy(buf + idx, &pos, sizeof(int));
+
+ idx += sizeof(int);
+ }
+
+ if (XC_write_socket(xc_display_sock, buf, idx) < 0)
+ XCursesExitCursesProcess(1, "exiting from PDC_display_cursor");
+
+ return OK;
+}
+
+/* position hardware cursor at (y, x) */
+
+void PDC_gotoyx(int row, int col)
+{
+ PDC_LOG(("PDC_gotoyx() - called: row %d col %d\n", row, col));
+
+ PDC_display_cursor(SP->cursrow, SP->curscol, row, col, SP->visibility);
+}
+
+/* update the given physical line to look like the corresponding line in
+ curscr */
+
+void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
+{
+ PDC_LOG(("PDC_transform_line() - called: line %d\n", lineno));
+
+ XC_get_line_lock(lineno);
+
+ memcpy(Xcurscr + XCURSCR_Y_OFF(lineno) + (x * sizeof(chtype)), srcp,
+ len * sizeof(chtype));
+
+ *(Xcurscr + XCURSCR_START_OFF + lineno) = x;
+ *(Xcurscr + XCURSCR_LENGTH_OFF + lineno) = len;
+
+ XC_release_line_lock(lineno);
+
+ XCursesInstructAndWait(CURSES_REFRESH);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcgetsc.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcgetsc.c
new file mode 100644
index 0000000000..8f7c0ad91f
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcgetsc.c
@@ -0,0 +1,30 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdcgetsc.c,v 1.26 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/* return width of screen/viewport */
+
+int PDC_get_columns(void)
+{
+ PDC_LOG(("PDC_get_columns() - called\n"));
+
+ return XCursesCOLS;
+}
+
+/* get the cursor size/shape */
+
+int PDC_get_cursor_mode(void)
+{
+ return 0;
+}
+
+/* return number of screen rows */
+
+int PDC_get_rows(void)
+{
+ PDC_LOG(("PDC_get_rows() - called\n"));
+
+ return XCursesLINES;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdckbd.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdckbd.c
new file mode 100644
index 0000000000..30c37a87c1
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdckbd.c
@@ -0,0 +1,102 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdckbd.c,v 1.62 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: pdckbd
+
+ Synopsis:
+ unsigned long PDC_get_input_fd(void);
+
+ Description:
+ PDC_get_input_fd() returns the file descriptor that PDCurses
+ reads its input from. It can be used for select().
+
+ Portability X/Open BSD SYS V
+ PDC_get_input_fd - - -
+
+**man-end****************************************************************/
+
+/* check if a key or mouse event is waiting */
+
+bool PDC_check_key(void)
+{
+ struct timeval socket_timeout = {0};
+ int s;
+
+ /* Is something ready to be read on the socket ? Must be a key. */
+
+ FD_ZERO(&xc_readfds);
+ FD_SET(xc_key_sock, &xc_readfds);
+
+ if ((s = select(FD_SETSIZE, (FD_SET_CAST)&xc_readfds, NULL,
+ NULL, &socket_timeout)) < 0)
+ XCursesExitCursesProcess(3, "child - exiting from "
+ "PDC_check_key select failed");
+
+ PDC_LOG(("%s:PDC_check_key() - returning %s\n", XCLOGMSG,
+ s ? "TRUE" : "FALSE"));
+
+ return !!s;
+}
+
+/* return the next available key or mouse event */
+
+int PDC_get_key(void)
+{
+ unsigned long newkey = 0;
+ int key = 0;
+
+ if (XC_read_socket(xc_key_sock, &newkey, sizeof(unsigned long)) < 0)
+ XCursesExitCursesProcess(2, "exiting from PDC_get_key");
+
+ pdc_key_modifiers = (newkey >> 24) & 0xFF;
+ key = (int)(newkey & 0x00FFFFFF);
+
+ if (key == KEY_MOUSE && SP->key_code)
+ {
+ if (XC_read_socket(xc_key_sock, &pdc_mouse_status,
+ sizeof(MOUSE_STATUS)) < 0)
+ XCursesExitCursesProcess(2, "exiting from PDC_get_key");
+ }
+
+ PDC_LOG(("%s:PDC_get_key() - key %d returned\n", XCLOGMSG, key));
+
+ return key;
+}
+
+unsigned long PDC_get_input_fd(void)
+{
+ PDC_LOG(("PDC_get_input_fd() - called\n"));
+
+ return xc_key_sock;
+}
+
+void PDC_set_keyboard_binary(bool on)
+{
+ PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
+}
+
+/* discard any pending keyboard or mouse input -- this is the core
+ routine for flushinp() */
+
+void PDC_flushinp(void)
+{
+ PDC_LOG(("PDC_flushinp() - called\n"));
+
+ while (PDC_check_key())
+ PDC_get_key();
+}
+
+int PDC_mouse_set(void)
+{
+ return OK;
+}
+
+int PDC_modifiers_set(void)
+{
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcscrn.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcscrn.c
new file mode 100644
index 0000000000..07b1a042ce
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcscrn.c
@@ -0,0 +1,150 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdcscrn.c,v 1.55 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/* COLOR_PAIR to attribute encoding table. */
+
+short *xc_atrtab = (short *)NULL;
+
+/* close the physical screen */
+
+void PDC_scr_close(void)
+{
+ PDC_LOG(("PDC_scr_close() - called\n"));
+}
+
+void PDC_scr_free(void)
+{
+ XCursesExit();
+
+ xc_atrtab = (short *)NULL;
+}
+
+/* open the physical screen -- allocate SP, miscellaneous intialization */
+
+int PDC_scr_open(int argc, char **argv)
+{
+ extern bool sb_started;
+
+ PDC_LOG(("PDC_scr_open() - called\n"));
+
+ if ((XCursesInitscr(argc, argv) == ERR) || !SP)
+ return ERR;
+
+ SP->cursrow = SP->curscol = 0;
+ SP->orig_attr = FALSE;
+ SP->sb_on = sb_started;
+ SP->sb_total_y = 0;
+ SP->sb_viewport_y = 0;
+ SP->sb_cur_y = 0;
+ SP->sb_total_x = 0;
+ SP->sb_viewport_x = 0;
+ SP->sb_cur_x = 0;
+
+ return OK;
+}
+
+/* the core of resize_term() */
+
+int PDC_resize_screen(int nlines, int ncols)
+{
+ PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n",
+ nlines, ncols));
+
+ if (nlines || ncols || !SP->resized)
+ return ERR;
+
+ shmdt((char *)Xcurscr);
+ XCursesInstructAndWait(CURSES_RESIZE);
+
+ if ((shmid_Xcurscr = shmget(shmkey_Xcurscr,
+ SP->XcurscrSize + XCURSESSHMMIN, 0700)) < 0)
+ {
+ perror("Cannot allocate shared memory for curscr");
+ kill(xc_otherpid, SIGKILL);
+ return ERR;
+ }
+
+ XCursesLINES = SP->lines;
+ XCursesCOLS = SP->cols;
+
+ PDC_LOG(("%s:shmid_Xcurscr %d shmkey_Xcurscr %d SP->lines %d "
+ "SP->cols %d\n", XCLOGMSG, shmid_Xcurscr,
+ shmkey_Xcurscr, SP->lines, SP->cols));
+
+ Xcurscr = (unsigned char*)shmat(shmid_Xcurscr, 0, 0);
+ xc_atrtab = (short *)(Xcurscr + XCURSCR_ATRTAB_OFF);
+
+ SP->resized = FALSE;
+
+ return OK;
+}
+
+void PDC_reset_prog_mode(void)
+{
+ PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
+}
+
+void PDC_reset_shell_mode(void)
+{
+ PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
+}
+
+void PDC_restore_screen_mode(int i)
+{
+}
+
+void PDC_save_screen_mode(int i)
+{
+}
+
+void PDC_init_pair(short pair, short fg, short bg)
+{
+ xc_atrtab[pair * 2] = fg;
+ xc_atrtab[pair * 2 + 1] = bg;
+}
+
+int PDC_pair_content(short pair, short *fg, short *bg)
+{
+ *fg = xc_atrtab[pair * 2];
+ *bg = xc_atrtab[pair * 2 + 1];
+
+ return OK;
+}
+
+bool PDC_can_change_color(void)
+{
+ return TRUE;
+}
+
+int PDC_color_content(short color, short *red, short *green, short *blue)
+{
+ XColor *tmp = (XColor *)(Xcurscr + XCURSCR_XCOLOR_OFF);
+
+ tmp->pixel = color;
+
+ XCursesInstructAndWait(CURSES_GET_COLOR);
+
+ *red = ((double)(tmp->red) * 1000 / 65535) + 0.5;
+ *green = ((double)(tmp->green) * 1000 / 65535) + 0.5;
+ *blue = ((double)(tmp->blue) * 1000 / 65535) + 0.5;
+
+ return OK;
+}
+
+int PDC_init_color(short color, short red, short green, short blue)
+{
+ XColor *tmp = (XColor *)(Xcurscr + XCURSCR_XCOLOR_OFF);
+
+ tmp->pixel = color;
+
+ tmp->red = ((double)red * 65535 / 1000) + 0.5;
+ tmp->green = ((double)green * 65535 / 1000) + 0.5;
+ tmp->blue = ((double)blue * 65535 / 1000) + 0.5;
+
+ XCursesInstructAndWait(CURSES_SET_COLOR);
+
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcsetsc.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcsetsc.c
new file mode 100644
index 0000000000..395060e867
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcsetsc.c
@@ -0,0 +1,74 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdcsetsc.c,v 1.33 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#include <string.h>
+
+/*man-start**************************************************************
+
+ Name: pdcsetsc
+
+ Synopsis:
+ int PDC_set_blink(bool blinkon);
+ void PDC_set_title(const char *title);
+
+ Description:
+ PDC_set_blink() toggles whether the A_BLINK attribute sets an
+ actual blink mode (TRUE), or sets the background color to high
+ intensity (FALSE). The default is platform-dependent (FALSE in
+ most cases). It returns OK if it could set the state to match
+ the given parameter, ERR otherwise. Current platforms also
+ adjust the value of COLORS according to this function -- 16 for
+ FALSE, and 8 for TRUE.
+
+ PDC_set_title() sets the title of the window in which the curses
+ program is running. This function may not do anything on some
+ platforms. (Currently it only works in Win32 and X11.)
+
+ Portability X/Open BSD SYS V
+ PDC_set_blink - - -
+ PDC_set_title - - -
+
+**man-end****************************************************************/
+
+int PDC_curs_set(int visibility)
+{
+ int ret_vis = SP->visibility;
+
+ PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
+
+ if (visibility != -1)
+ SP->visibility = visibility;
+
+ PDC_display_cursor(SP->cursrow, SP->curscol, SP->cursrow,
+ SP->curscol, visibility);
+
+ return ret_vis;
+}
+
+void PDC_set_title(const char *title)
+{
+ int len;
+
+ PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
+
+ len = strlen(title) + 1; /* write nul character */
+
+ XCursesInstruct(CURSES_TITLE);
+
+ if (XC_write_display_socket_int(len) >= 0)
+ if (XC_write_socket(xc_display_sock, title, len) >= 0)
+ return;
+
+ XCursesExitCursesProcess(1, "exiting from PDC_set_title");
+}
+
+int PDC_set_blink(bool blinkon)
+{
+ if (pdc_color_started)
+ COLORS = 16;
+
+ return blinkon ? ERR : OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcutil.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcutil.c
new file mode 100644
index 0000000000..5b5109f84e
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcutil.c
@@ -0,0 +1,39 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdcutil.c,v 1.10 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#if defined(HAVE_POLL) && !defined(HAVE_USLEEP)
+# include <poll.h>
+#endif
+
+void PDC_beep(void)
+{
+ PDC_LOG(("PDC_beep() - called\n"));
+
+ XCursesInstruct(CURSES_BELL);
+}
+
+void PDC_napms(int ms)
+{
+ PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
+
+#if defined(HAVE_USLEEP)
+
+ usleep(1000 * ms);
+
+#elif defined(HAVE_POLL)
+ {
+ struct pollfd fd;
+ fd.fd = -1;
+ fd.events = 0;
+ poll(&fd, 1, ms);
+ }
+#endif
+}
+
+const char *PDC_sysname(void)
+{
+ return "X11";
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.c
new file mode 100644
index 0000000000..1e8d0d163c
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.c
@@ -0,0 +1,317 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdcx11.c,v 1.96 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#include <errno.h>
+#include <stdlib.h>
+
+/*** Functions that are called by both processes ***/
+
+unsigned char *Xcurscr;
+
+int XCursesProcess = 1;
+int shmidSP;
+int shmid_Xcurscr;
+int shmkeySP;
+int shmkey_Xcurscr;
+int xc_otherpid;
+int XCursesLINES = 24;
+int XCursesCOLS = 80;
+int xc_display_sock;
+int xc_key_sock;
+int xc_display_sockets[2];
+int xc_key_sockets[2];
+int xc_exit_sock;
+
+fd_set xc_readfds;
+
+static void _dummy_function(void)
+{
+}
+
+void XC_get_line_lock(int row)
+{
+ /* loop until we can write to the line -- Patch by:
+ Georg Fuchs, georg.fuchs@rz.uni-regensburg.de */
+
+ while (*(Xcurscr + XCURSCR_FLAG_OFF + row))
+ _dummy_function();
+
+ *(Xcurscr + XCURSCR_FLAG_OFF + row) = 1;
+}
+
+void XC_release_line_lock(int row)
+{
+ *(Xcurscr + XCURSCR_FLAG_OFF + row) = 0;
+}
+
+int XC_write_socket(int sock_num, const void *buf, int len)
+{
+ int start = 0, rc;
+
+ PDC_LOG(("%s:XC_write_socket called: sock_num %d len %d\n",
+ XCLOGMSG, sock_num, len));
+
+#ifdef MOUSE_DEBUG
+ if (sock_num == xc_key_sock)
+ printf("%s:XC_write_socket(key) len: %d\n", XCLOGMSG, len);
+#endif
+ while (1)
+ {
+ rc = write(sock_num, buf + start, len);
+
+ if (rc < 0 || rc == len)
+ return rc;
+
+ len -= rc;
+ start = rc;
+ }
+}
+
+int XC_read_socket(int sock_num, void *buf, int len)
+{
+ int start = 0, length = len, rc;
+
+ PDC_LOG(("%s:XC_read_socket called: sock_num %d len %d\n",
+ XCLOGMSG, sock_num, len));
+
+ while (1)
+ {
+ rc = read(sock_num, buf + start, length);
+
+#ifdef MOUSE_DEBUG
+ if (sock_num == xc_key_sock)
+ printf("%s:XC_read_socket(key) rc %d errno %d "
+ "resized: %d\n", XCLOGMSG, rc, errno, SP->resized);
+#endif
+ if (rc < 0 && sock_num == xc_key_sock && errno == EINTR
+ && SP->resized != FALSE)
+ {
+ MOUSE_LOG(("%s:continuing\n", XCLOGMSG));
+
+ rc = 0;
+
+ if (SP->resized > 1)
+ SP->resized = TRUE;
+ else
+ SP->resized = FALSE;
+
+ memcpy(buf, &rc, sizeof(int));
+
+ return 0;
+ }
+
+ if (rc <= 0 || rc == length)
+ return rc;
+
+ length -= rc;
+ start = rc;
+ }
+}
+
+int XC_write_display_socket_int(int x)
+{
+ return XC_write_socket(xc_display_sock, &x, sizeof(int));
+}
+
+#ifdef PDCDEBUG
+void XC_say(const char *msg)
+{
+ PDC_LOG(("%s:%s", XCLOGMSG, msg));
+}
+#endif
+
+/*** Functions that are called by the "curses" process ***/
+
+int XCursesInstruct(int flag)
+{
+ PDC_LOG(("%s:XCursesInstruct() - called flag %d\n", XCLOGMSG, flag));
+
+ /* Send a request to X */
+
+ if (XC_write_display_socket_int(flag) < 0)
+ XCursesExitCursesProcess(4, "exiting from XCursesInstruct");
+
+ return OK;
+}
+
+int XCursesInstructAndWait(int flag)
+{
+ int result;
+
+ XC_LOG(("XCursesInstructAndWait() - called\n"));
+
+ /* tell X we want to do something */
+
+ XCursesInstruct(flag);
+
+ /* wait for X to say the refresh has occurred*/
+
+ if (XC_read_socket(xc_display_sock, &result, sizeof(int)) < 0)
+ XCursesExitCursesProcess(5, "exiting from XCursesInstructAndWait");
+
+ if (result != CURSES_CONTINUE)
+ XCursesExitCursesProcess(6, "exiting from XCursesInstructAndWait"
+ " - synchronization error");
+
+ return OK;
+}
+
+static int _setup_curses(void)
+{
+ int wait_value;
+
+ XC_LOG(("_setup_curses called\n"));
+
+ close(xc_display_sockets[1]);
+ close(xc_key_sockets[1]);
+
+ xc_display_sock = xc_display_sockets[0];
+ xc_key_sock = xc_key_sockets[0];
+
+ FD_ZERO(&xc_readfds);
+
+ XC_read_socket(xc_display_sock, &wait_value, sizeof(int));
+
+ if (wait_value != CURSES_CHILD)
+ return ERR;
+
+ /* Set LINES and COLS now so that the size of the shared memory
+ segment can be allocated */
+
+ if ((shmidSP = shmget(shmkeySP, sizeof(SCREEN) + XCURSESSHMMIN, 0700)) < 0)
+ {
+ perror("Cannot allocate shared memory for SCREEN");
+ kill(xc_otherpid, SIGKILL);
+ return ERR;
+ }
+
+ SP = (SCREEN*)shmat(shmidSP, 0, 0);
+
+ XCursesLINES = SP->lines;
+ LINES = XCursesLINES - SP->linesrippedoff - SP->slklines;
+ XCursesCOLS = COLS = SP->cols;
+
+ if ((shmid_Xcurscr = shmget(shmkey_Xcurscr,
+ SP->XcurscrSize + XCURSESSHMMIN, 0700)) < 0)
+ {
+ perror("Cannot allocate shared memory for curscr");
+ kill(xc_otherpid, SIGKILL);
+ return ERR;
+ }
+
+ PDC_LOG(("%s:shmid_Xcurscr %d shmkey_Xcurscr %d LINES %d COLS %d\n",
+ XCLOGMSG, shmid_Xcurscr, shmkey_Xcurscr, LINES, COLS));
+
+ Xcurscr = (unsigned char *)shmat(shmid_Xcurscr, 0, 0);
+ xc_atrtab = (short *)(Xcurscr + XCURSCR_ATRTAB_OFF);
+
+ XC_LOG(("cursesprocess exiting from Xinitscr\n"));
+
+ /* Always trap SIGWINCH if the C library supports SIGWINCH */
+
+ XCursesSetSignal(SIGWINCH, XCursesSigwinchHandler);
+
+ atexit(XCursesExit);
+
+ return OK;
+}
+
+int XCursesInitscr(int argc, char *argv[])
+{
+ int pid, rc;
+
+ XC_LOG(("XCursesInitscr() - called\n"));
+
+ shmkeySP = getpid();
+
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, xc_display_sockets) < 0)
+ {
+ fprintf(stderr, "ERROR: cannot create display socketpair\n");
+ return ERR;
+ }
+
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, xc_key_sockets) < 0)
+ {
+ fprintf(stderr, "ERROR: cannot create key socketpair\n");
+ return ERR;
+ }
+
+ pid = fork();
+
+ switch(pid)
+ {
+ case -1:
+ fprintf(stderr, "ERROR: cannot fork()\n");
+ return ERR;
+ break;
+
+ case 0: /* child */
+ shmkey_Xcurscr = getpid();
+#ifdef XISPARENT
+ XCursesProcess = 0;
+ rc = _setup_curses();
+#else
+ XCursesProcess = 1;
+ xc_otherpid = getppid();
+ rc = XCursesSetupX(argc, argv);
+#endif
+ break;
+
+ default: /* parent */
+ shmkey_Xcurscr = pid;
+#ifdef XISPARENT
+ XCursesProcess = 1;
+ xc_otherpid = pid;
+ rc = XCursesSetupX(argc, argv);
+#else
+ XCursesProcess = 0;
+ rc = _setup_curses();
+#endif
+ }
+
+ return rc;
+}
+
+static void _cleanup_curses_process(int rc)
+{
+ PDC_LOG(("%s:_cleanup_curses_process() - called: %d\n", XCLOGMSG, rc));
+
+ shutdown(xc_display_sock, 2);
+ close(xc_display_sock);
+
+ shutdown(xc_key_sock, 2);
+ close(xc_key_sock);
+
+ shmdt((char *)SP);
+ shmdt((char *)Xcurscr);
+
+ if (rc)
+ _exit(rc);
+}
+
+void XCursesExitCursesProcess(int rc, char *msg)
+{
+ PDC_LOG(("%s:XCursesExitCursesProcess() - called: %d %s\n",
+ XCLOGMSG, rc, msg));
+
+ endwin();
+ _cleanup_curses_process(rc);
+}
+
+void XCursesExit(void)
+{
+ static bool called = FALSE;
+
+ XC_LOG(("XCursesExit() - called\n"));
+
+ if (FALSE == called)
+ {
+ XCursesInstruct(CURSES_EXIT);
+ _cleanup_curses_process(0);
+
+ called = TRUE;
+ }
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.h b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.h
new file mode 100644
index 0000000000..0b66c8809e
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.h
@@ -0,0 +1,188 @@
+/* Public Domain Curses */
+
+/* $Id: pdcx11.h,v 1.64 2008/07/14 04:24:52 wmcbrine Exp $ */
+
+#include <curspriv.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <signal.h>
+#include <ctype.h>
+#include <pwd.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+#ifdef HAVE_SYS_SELECT_H
+# include <sys/select.h> /* AIX needs this for FD_ZERO etc macros */
+#endif
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+#include <Intrinsic.h>
+#include <StringDefs.h>
+#include <Shell.h>
+
+#ifdef USE_XAW3D
+# include <Xaw3d/Box.h>
+# include <Xaw3d/Scrollbar.h>
+#elif defined(USE_NEXTAW)
+# include <neXtaw/Box.h>
+# include <neXtaw/Scrollbar.h>
+#else
+# include <Xaw/Box.h>
+# include <Xaw/Scrollbar.h>
+#endif
+#include "x11/ScrollBox.h"
+
+#include "Xmu/StdSel.h"
+#include "Xmu/Atoms.h"
+
+#include <keysym.h>
+#include <Xatom.h>
+
+#define XCURSCR_Y_SIZE (XCursesLINES * XCursesCOLS * sizeof(chtype))
+#define XCURSCR_FLAG_SIZE (XCursesLINES * sizeof(int))
+#define XCURSCR_START_SIZE (XCursesLINES * sizeof(int))
+#define XCURSCR_LENGTH_SIZE (XCursesLINES * sizeof(int))
+#define XCURSCR_ATRTAB_SIZE (PDC_COLOR_PAIRS * 2 * sizeof(short))
+#define XCURSCR_SIZE (XCURSCR_FLAG_SIZE + XCURSCR_START_SIZE + \
+ XCURSCR_LENGTH_SIZE + XCURSCR_Y_SIZE + XCURSCR_ATRTAB_SIZE + \
+ sizeof(XColor))
+
+#define XCURSCR_Y_OFF(y) ((y) * XCursesCOLS * sizeof(chtype))
+#define XCURSCR_FLAG_OFF (XCURSCR_Y_OFF(0) + XCURSCR_Y_SIZE)
+#define XCURSCR_START_OFF (XCURSCR_FLAG_OFF + XCURSCR_FLAG_SIZE)
+#define XCURSCR_LENGTH_OFF (XCURSCR_START_OFF + XCURSCR_START_SIZE)
+#define XCURSCR_ATRTAB_OFF (XCURSCR_LENGTH_OFF + XCURSCR_LENGTH_SIZE)
+#define XCURSCR_XCOLOR_OFF (XCURSCR_ATRTAB_OFF + XCURSCR_ATRTAB_SIZE)
+
+typedef struct
+{
+ int lines;
+ int cols;
+ Pixel cursorColor;
+ Pixel colorBlack;
+ Pixel colorRed;
+ Pixel colorGreen;
+ Pixel colorYellow;
+ Pixel colorBlue;
+ Pixel colorMagenta;
+ Pixel colorCyan;
+ Pixel colorWhite;
+ Pixel colorBoldBlack;
+ Pixel colorBoldRed;
+ Pixel colorBoldGreen;
+ Pixel colorBoldYellow;
+ Pixel colorBoldBlue;
+ Pixel colorBoldMagenta;
+ Pixel colorBoldCyan;
+ Pixel colorBoldWhite;
+ Pixel pointerForeColor;
+ Pixel pointerBackColor;
+ XFontStruct *normalFont;
+ XFontStruct *italicFont;
+ char *bitmap;
+#ifdef HAVE_XPM_H
+ char *pixmap;
+#endif
+ char *composeKey;
+ Cursor pointer;
+ int shmmin;
+ int borderWidth;
+ int borderColor;
+ int clickPeriod;
+ int doubleClickPeriod;
+ int scrollbarWidth;
+ int cursorBlinkRate;
+ char *textCursor;
+} XCursesAppData;
+
+extern XCursesAppData xc_app_data;
+
+#define XCURSESSHMMIN xc_app_data.shmmin
+
+#define XCLOGMSG (XCursesProcess ? " X" : "CURSES")
+
+void XC_get_line_lock(int);
+void XC_release_line_lock(int);
+
+int PDC_display_cursor(int, int, int, int, int);
+
+void XCursesExitCursesProcess(int, char *);
+int XCursesInstruct(int);
+int XCursesInstructAndWait(int);
+int XCursesInitscr(int, char **);
+
+int XC_write_socket(int, const void *, int);
+int XC_read_socket(int, void *, int);
+int XC_write_display_socket_int(int);
+
+int XCursesSetupX(int argc, char *argv[]);
+RETSIGTYPE XCursesSigwinchHandler(int signo);
+
+#ifdef _HPUX_SOURCE
+# define FD_SET_CAST int *
+#else
+# define FD_SET_CAST fd_set *
+#endif
+
+extern fd_set xc_readfds;
+
+extern unsigned char *Xcurscr;
+extern int XCursesProcess;
+extern int shmidSP;
+extern int shmid_Xcurscr;
+extern int shmkeySP;
+extern int shmkey_Xcurscr;
+extern int xc_otherpid;
+extern int XCursesLINES;
+extern int XCursesCOLS;
+extern int xc_display_sock;
+extern int xc_key_sock;
+extern int xc_display_sockets[2];
+extern int xc_key_sockets[2];
+extern int xc_exit_sock;
+
+typedef RETSIGTYPE (*signal_handler)();
+
+signal_handler XCursesSetSignal(int, signal_handler);
+
+#ifdef PDCDEBUG
+void XC_say(const char *msg);
+# define XC_LOG(x) XC_say x
+#else
+# define XC_LOG(x)
+#endif
+
+#ifdef MOUSE_DEBUG
+# define MOUSE_LOG(x) printf x
+#else
+# define MOUSE_LOG(x)
+#endif
+
+enum
+{
+ CURSES_CLEAR_SELECTION, CURSES_DISPLAY_CURSOR, CURSES_SET_SELECTION,
+ CURSES_GET_SELECTION, CURSES_TITLE, CURSES_REFRESH_SCROLLBAR,
+ CURSES_RESIZE, CURSES_BELL, CURSES_CONTINUE, CURSES_CURSOR,
+ CURSES_CHILD, CURSES_REFRESH, CURSES_GET_COLOR, CURSES_SET_COLOR,
+ CURSES_EXIT
+};
+
+extern short *xc_atrtab;
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/sb.c b/payloads/libpayload/curses/PDCurses-3.4/x11/sb.c
new file mode 100644
index 0000000000..a34f502b24
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/sb.c
@@ -0,0 +1,153 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: sb.c,v 1.27 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: sb
+
+ Synopsis:
+ int sb_init(void)
+ int sb_set_horz(int total, int viewport, int cur)
+ int sb_set_vert(int total, int viewport, int cur)
+ int sb_get_horz(int *total, int *viewport, int *cur)
+ int sb_get_vert(int *total, int *viewport, int *cur)
+ int sb_refresh(void);
+
+ Description:
+ These functions manipulate the scrollbar.
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ sb_init - - -
+ sb_set_horz - - -
+ sb_set_vert - - -
+ sb_get_horz - - -
+ sb_get_vert - - -
+ sb_refresh - - -
+
+**man-end****************************************************************/
+
+bool sb_started = FALSE;
+
+/* sb_init() is the sb initialization routine.
+ This must be called before initscr(). */
+
+int sb_init(void)
+{
+ PDC_LOG(("sb_init() - called\n"));
+
+ if (SP)
+ return ERR;
+
+ sb_started = TRUE;
+
+ return OK;
+}
+
+/* sb_set_horz() - Used to set horizontal scrollbar.
+
+ total = total number of columns
+ viewport = size of viewport in columns
+ cur = current column in total */
+
+int sb_set_horz(int total, int viewport, int cur)
+{
+ PDC_LOG(("sb_set_horz() - called: total %d viewport %d cur %d\n",
+ total, viewport, cur));
+
+ if (!SP)
+ return ERR;
+
+ SP->sb_total_x = total;
+ SP->sb_viewport_x = viewport;
+ SP->sb_cur_x = cur;
+
+ return OK;
+}
+
+/* sb_set_vert() - Used to set vertical scrollbar.
+
+ total = total number of columns on line
+ viewport = size of viewport in columns
+ cur = current column in total */
+
+int sb_set_vert(int total, int viewport, int cur)
+{
+ PDC_LOG(("sb_set_vert() - called: total %d viewport %d cur %d\n",
+ total, viewport, cur));
+
+ if (!SP)
+ return ERR;
+
+ SP->sb_total_y = total;
+ SP->sb_viewport_y = viewport;
+ SP->sb_cur_y = cur;
+
+ return OK;
+}
+
+/* sb_get_horz() - Used to get horizontal scrollbar.
+
+ total = total number of lines
+ viewport = size of viewport in lines
+ cur = current line in total */
+
+int sb_get_horz(int *total, int *viewport, int *cur)
+{
+ PDC_LOG(("sb_get_horz() - called\n"));
+
+ if (!SP)
+ return ERR;
+
+ if (total)
+ *total = SP->sb_total_x;
+ if (viewport)
+ *viewport = SP->sb_viewport_x;
+ if (cur)
+ *cur = SP->sb_cur_x;
+
+ return OK;
+}
+
+/* sb_get_vert() - Used to get vertical scrollbar.
+
+ total = total number of lines
+ viewport = size of viewport in lines
+ cur = current line in total */
+
+int sb_get_vert(int *total, int *viewport, int *cur)
+{
+ PDC_LOG(("sb_get_vert() - called\n"));
+
+ if (!SP)
+ return ERR;
+
+ if (total)
+ *total = SP->sb_total_y;
+ if (viewport)
+ *viewport = SP->sb_viewport_y;
+ if (cur)
+ *cur = SP->sb_cur_y;
+
+ return OK;
+}
+
+/* sb_refresh() - Used to draw the scrollbars. */
+
+int sb_refresh(void)
+{
+ PDC_LOG(("sb_refresh() - called\n"));
+
+ if (!SP)
+ return ERR;
+
+ XCursesInstruct(CURSES_REFRESH_SCROLLBAR);
+
+ return OK;
+}
+
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/x11.c b/payloads/libpayload/curses/PDCurses-3.4/x11/x11.c
new file mode 100644
index 0000000000..97d44985e5
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/x11.c
@@ -0,0 +1,3229 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: x11.c,v 1.94 2008/07/14 04:33:26 wmcbrine Exp $")
+
+#ifdef HAVE_DECKEYSYM_H
+# include <DECkeysym.h>
+#endif
+
+#ifdef HAVE_SUNKEYSYM_H
+# include <Sunkeysym.h>
+#endif
+
+#ifdef HAVE_XPM_H
+# include <xpm.h>
+#endif
+
+#if defined PDC_XIM
+# include <Xlocale.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef XPOINTER_TYPEDEFED
+typedef char * XPointer;
+#endif
+
+#ifndef MAX_PATH
+# define MAX_PATH 256
+#endif
+
+XCursesAppData xc_app_data;
+
+#if NeedWidePrototypes
+# define PDC_SCROLLBAR_TYPE double
+#else
+# define PDC_SCROLLBAR_TYPE float
+#endif
+
+#define MAX_COLORS 16 /* maximum of "normal" colors */
+#define COLOR_CURSOR MAX_COLORS /* color of cursor */
+#define COLOR_BORDER MAX_COLORS + 1 /* color of border */
+
+#define XCURSESDISPLAY (XtDisplay(drawing))
+#define XCURSESWIN (XtWindow(drawing))
+
+/* Default icons for XCurses applications. */
+
+#include "big_icon.xbm"
+#include "little_icon.xbm"
+
+static void _selection_off(void);
+static void _display_cursor(int, int, int, int);
+static void _redraw_cursor(void);
+static void _exit_process(int, int, char *);
+static void _send_key_to_curses(unsigned long, MOUSE_STATUS *, bool);
+
+static void XCursesButton(Widget, XEvent *, String *, Cardinal *);
+static void XCursesHandleString(Widget, XEvent *, String *, Cardinal *);
+static void XCursesKeyPress(Widget, XEvent *, String *, Cardinal *);
+static void XCursesPasteSelection(Widget, XButtonEvent *);
+
+static struct
+{
+ KeySym keycode;
+ bool numkeypad;
+ unsigned short normal;
+ unsigned short shifted;
+ unsigned short control;
+ unsigned short alt;
+} key_table[] =
+{
+/* keycode keypad normal shifted control alt*/
+ {XK_Left, FALSE, KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT},
+ {XK_Right, FALSE, KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT},
+ {XK_Up, FALSE, KEY_UP, KEY_SUP, CTL_UP, ALT_UP},
+ {XK_Down, FALSE, KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN},
+ {XK_Home, FALSE, KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME},
+/* Sun Type 4 keyboard */
+ {XK_R7, FALSE, KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME},
+ {XK_End, FALSE, KEY_END, KEY_SEND, CTL_END, ALT_END},
+/* Sun Type 4 keyboard */
+ {XK_R13, FALSE, KEY_END, KEY_SEND, CTL_END, ALT_END},
+ {XK_Prior, FALSE, KEY_PPAGE, KEY_SPREVIOUS,CTL_PGUP, ALT_PGUP},
+/* Sun Type 4 keyboard */
+ {XK_R9, FALSE, KEY_PPAGE, KEY_SPREVIOUS,CTL_PGUP, ALT_PGUP},
+ {XK_Next, FALSE, KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN},
+/* Sun Type 4 keyboard */
+ {XK_R15, FALSE, KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN},
+ {XK_Insert, FALSE, KEY_IC, KEY_SIC, CTL_INS, ALT_INS},
+ {XK_Delete, FALSE, KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL},
+ {XK_F1, FALSE, KEY_F(1), KEY_F(13), KEY_F(25), KEY_F(37)},
+ {XK_F2, FALSE, KEY_F(2), KEY_F(14), KEY_F(26), KEY_F(38)},
+ {XK_F3, FALSE, KEY_F(3), KEY_F(15), KEY_F(27), KEY_F(39)},
+ {XK_F4, FALSE, KEY_F(4), KEY_F(16), KEY_F(28), KEY_F(40)},
+ {XK_F5, FALSE, KEY_F(5), KEY_F(17), KEY_F(29), KEY_F(41)},
+ {XK_F6, FALSE, KEY_F(6), KEY_F(18), KEY_F(30), KEY_F(42)},
+ {XK_F7, FALSE, KEY_F(7), KEY_F(19), KEY_F(31), KEY_F(43)},
+ {XK_F8, FALSE, KEY_F(8), KEY_F(20), KEY_F(32), KEY_F(44)},
+ {XK_F9, FALSE, KEY_F(9), KEY_F(21), KEY_F(33), KEY_F(45)},
+ {XK_F10, FALSE, KEY_F(10), KEY_F(22), KEY_F(34), KEY_F(46)},
+ {XK_F11, FALSE, KEY_F(11), KEY_F(23), KEY_F(35), KEY_F(47)},
+ {XK_F12, FALSE, KEY_F(12), KEY_F(24), KEY_F(36), KEY_F(48)},
+ {XK_F13, FALSE, KEY_F(13), KEY_F(25), KEY_F(37), KEY_F(49)},
+ {XK_F14, FALSE, KEY_F(14), KEY_F(26), KEY_F(38), KEY_F(50)},
+ {XK_F15, FALSE, KEY_F(15), KEY_F(27), KEY_F(39), KEY_F(51)},
+ {XK_F16, FALSE, KEY_F(16), KEY_F(28), KEY_F(40), KEY_F(52)},
+ {XK_F17, FALSE, KEY_F(17), KEY_F(29), KEY_F(41), KEY_F(53)},
+ {XK_F18, FALSE, KEY_F(18), KEY_F(30), KEY_F(42), KEY_F(54)},
+ {XK_F19, FALSE, KEY_F(19), KEY_F(31), KEY_F(43), KEY_F(55)},
+ {XK_F20, FALSE, KEY_F(20), KEY_F(32), KEY_F(44), KEY_F(56)},
+ {XK_BackSpace, FALSE, 0x08, 0x08, CTL_BKSP, ALT_BKSP},
+ {XK_Tab, FALSE, 0x09, KEY_BTAB, CTL_TAB, ALT_TAB},
+ {XK_Select, FALSE, KEY_SELECT, KEY_SELECT, KEY_SELECT, KEY_SELECT},
+ {XK_Print, FALSE, KEY_PRINT, KEY_SPRINT, KEY_PRINT, KEY_PRINT},
+ {XK_Find, FALSE, KEY_FIND, KEY_SFIND, KEY_FIND, KEY_FIND},
+ {XK_Pause, FALSE, KEY_SUSPEND, KEY_SSUSPEND, KEY_SUSPEND, KEY_SUSPEND},
+ {XK_Clear, FALSE, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR},
+ {XK_Cancel, FALSE, KEY_CANCEL, KEY_SCANCEL, KEY_CANCEL, KEY_CANCEL},
+ {XK_Break, FALSE, KEY_BREAK, KEY_BREAK, KEY_BREAK, KEY_BREAK},
+ {XK_Help, FALSE, KEY_HELP, KEY_SHELP, KEY_LHELP, KEY_HELP},
+ {XK_L4, FALSE, KEY_UNDO, KEY_SUNDO, KEY_UNDO, KEY_UNDO},
+ {XK_L6, FALSE, KEY_COPY, KEY_SCOPY, KEY_COPY, KEY_COPY},
+ {XK_L9, FALSE, KEY_FIND, KEY_SFIND, KEY_FIND, KEY_FIND},
+ {XK_Menu, FALSE, KEY_OPTIONS, KEY_SOPTIONS, KEY_OPTIONS, KEY_OPTIONS},
+#ifdef HAVE_SUNKEYSYM_H
+ {SunXK_F36, FALSE, KEY_F(41), KEY_F(43), KEY_F(45), KEY_F(47)},
+ {SunXK_F37, FALSE, KEY_F(42), KEY_F(44), KEY_F(46), KEY_F(48)},
+#endif
+#ifdef HAVE_DECKEYSYM_H
+ {DXK_Remove, FALSE, KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL},
+#endif
+ {XK_Escape, FALSE, 0x1B, 0x1B, 0x1B, ALT_ESC},
+ {XK_KP_Enter, TRUE, PADENTER, PADENTER, CTL_PADENTER,ALT_PADENTER},
+ {XK_KP_Add, TRUE, PADPLUS, '+', CTL_PADPLUS, ALT_PADPLUS},
+ {XK_KP_Subtract,TRUE, PADMINUS, '-', CTL_PADMINUS,ALT_PADMINUS},
+ {XK_KP_Multiply,TRUE, PADSTAR, '*', CTL_PADSTAR, ALT_PADSTAR},
+/* Sun Type 4 keyboard */
+ {XK_R6, TRUE, PADSTAR, '*', CTL_PADSTAR, ALT_PADSTAR},
+ {XK_KP_Divide, TRUE, PADSLASH, '/', CTL_PADSLASH,ALT_PADSLASH},
+/* Sun Type 4 keyboard */
+ {XK_R5, TRUE, PADSLASH, '/', CTL_PADSLASH,ALT_PADSLASH},
+ {XK_KP_Decimal,TRUE, PADSTOP, '.', CTL_PADSTOP, ALT_PADSTOP},
+ {XK_KP_0, TRUE, PAD0, '0', CTL_PAD0, ALT_PAD0},
+ {XK_KP_1, TRUE, KEY_C1, '1', CTL_PAD1, ALT_PAD1},
+ {XK_KP_2, TRUE, KEY_C2, '2', CTL_PAD2, ALT_PAD2},
+ {XK_KP_3, TRUE, KEY_C3, '3', CTL_PAD3, ALT_PAD3},
+ {XK_KP_4, TRUE, KEY_B1, '4', CTL_PAD4, ALT_PAD4},
+ {XK_KP_5, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
+/* Sun Type 4 keyboard */
+ {XK_R11, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
+ {XK_KP_6, TRUE, KEY_B3, '6', CTL_PAD6, ALT_PAD6},
+ {XK_KP_7, TRUE, KEY_A1, '7', CTL_PAD7, ALT_PAD7},
+ {XK_KP_8, TRUE, KEY_A2, '8', CTL_PAD8, ALT_PAD8},
+ {XK_KP_9, TRUE, KEY_A3, '9', CTL_PAD9, ALT_PAD9},
+/* the following added to support Sun Type 5 keyboards */
+ {XK_F21, FALSE, KEY_SUSPEND, KEY_SSUSPEND, KEY_SUSPEND, KEY_SUSPEND},
+ {XK_F22, FALSE, KEY_PRINT, KEY_SPRINT, KEY_PRINT, KEY_PRINT},
+ {XK_F24, TRUE, PADMINUS, '-', CTL_PADMINUS,ALT_PADMINUS},
+/* Sun Type 4 keyboard */
+ {XK_F25, TRUE, PADSLASH, '/', CTL_PADSLASH,ALT_PADSLASH},
+/* Sun Type 4 keyboard */
+ {XK_F26, TRUE, PADSTAR, '*', CTL_PADSTAR, ALT_PADSTAR},
+ {XK_F27, TRUE, KEY_A1, '7', CTL_PAD7, ALT_PAD7},
+ {XK_F29, TRUE, KEY_A3, '9', CTL_PAD9, ALT_PAD9},
+ {XK_F31, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
+ {XK_F35, TRUE, KEY_C3, '3', CTL_PAD3, ALT_PAD3},
+#ifdef HAVE_XK_KP_DELETE
+ {XK_KP_Delete, TRUE, PADSTOP, '.', CTL_PADSTOP, ALT_PADSTOP},
+#endif
+#ifdef HAVE_XK_KP_INSERT
+ {XK_KP_Insert, TRUE, PAD0, '0', CTL_PAD0, ALT_PAD0},
+#endif
+#ifdef HAVE_XK_KP_END
+ {XK_KP_End, TRUE, KEY_C1, '1', CTL_PAD1, ALT_PAD1},
+#endif
+#ifdef HAVE_XK_KP_DOWN
+ {XK_KP_Down, TRUE, KEY_C2, '2', CTL_PAD2, ALT_PAD2},
+#endif
+#ifdef HAVE_XK_KP_NEXT
+ {XK_KP_Next, TRUE, KEY_C3, '3', CTL_PAD3, ALT_PAD3},
+#endif
+#ifdef HAVE_XK_KP_LEFT
+ {XK_KP_Left, TRUE, KEY_B1, '4', CTL_PAD4, ALT_PAD4},
+#endif
+#ifdef HAVE_XK_KP_BEGIN
+ {XK_KP_Begin, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
+#endif
+#ifdef HAVE_XK_KP_RIGHT
+ {XK_KP_Right, TRUE, KEY_B3, '6', CTL_PAD6, ALT_PAD6},
+#endif
+#ifdef HAVE_XK_KP_HOME
+ {XK_KP_Home, TRUE, KEY_A1, '7', CTL_PAD7, ALT_PAD7},
+#endif
+#ifdef HAVE_XK_KP_UP
+ {XK_KP_Up, TRUE, KEY_A2, '8', CTL_PAD8, ALT_PAD8},
+#endif
+#ifdef HAVE_XK_KP_PRIOR
+ {XK_KP_Prior, TRUE, KEY_A3, '9', CTL_PAD9, ALT_PAD9},
+#endif
+ {0, 0, 0, 0, 0, 0}
+};
+
+#ifndef PDC_XIM
+# include "compose.h"
+#endif
+
+#define BITMAPDEPTH 1
+
+unsigned long pdc_key_modifiers = 0L;
+
+static GC normal_gc, block_cursor_gc, rect_cursor_gc, italic_gc, border_gc;
+static int font_height, font_width, font_ascent, font_descent,
+ window_width, window_height;
+static int resize_window_width = 0, resize_window_height = 0;
+static char *bitmap_file = NULL;
+#ifdef HAVE_XPM_H
+static char *pixmap_file = NULL;
+#endif
+static KeySym keysym = 0;
+
+static int state_mask[8] =
+{
+ ShiftMask,
+ LockMask,
+ ControlMask,
+ Mod1Mask,
+ Mod2Mask,
+ Mod3Mask,
+ Mod4Mask,
+ Mod5Mask
+};
+
+static Atom wm_atom[2];
+static String class_name = "XCurses";
+static XtAppContext app_context;
+static Widget topLevel, drawing, scrollBox, scrollVert, scrollHoriz;
+static int received_map_notify = 0;
+static bool mouse_selection = FALSE;
+static chtype *tmpsel = NULL;
+static unsigned long tmpsel_length = 0;
+static int selection_start_x = 0, selection_start_y = 0,
+ selection_end_x = 0, selection_end_y = 0;
+static Pixmap icon_bitmap;
+#ifdef HAVE_XPM_H
+static Pixmap icon_pixmap;
+static Pixmap icon_pixmap_mask;
+#endif
+static bool visible_cursor = FALSE;
+static bool window_entered = TRUE;
+static char *program_name;
+
+/* Macros just for app_resources */
+
+#ifdef PDC_WIDE
+# define DEFFONT "-misc-fixed-medium-r-normal--20-200-75-75-c-100-iso10646-1"
+#else
+# define DEFFONT "7x13"
+#endif
+
+#define APPDATAOFF(n) XtOffsetOf(XCursesAppData, n)
+
+#define RINT(name1, name2, value) { \
+ #name1, #name2, XtRInt, \
+ sizeof(int), APPDATAOFF(name1), XtRImmediate, \
+ (XtPointer)value \
+ }
+
+#define RPIXEL(name1, name2, value) { \
+ #name1, #name2, XtRPixel, \
+ sizeof(Pixel), APPDATAOFF(name1), XtRString, \
+ (XtPointer)#value \
+ }
+
+#define RCOLOR(name, value) RPIXEL(color##name, Color##name, value)
+
+
+#define RSTRINGP(name1, name2, param) { \
+ #name1, #name2, XtRString, \
+ MAX_PATH, APPDATAOFF(name1), XtRString, (XtPointer)param \
+ }
+
+#define RSTRING(name1, name2) RSTRINGP(name1, name2, "")
+
+#define RFONT(name1, name2, value) { \
+ #name1, #name2, XtRFontStruct, \
+ sizeof(XFontStruct), APPDATAOFF(name1), XtRString, \
+ (XtPointer)value \
+ }
+
+#define RCURSOR(name1, name2, value) { \
+ #name1, #name2, XtRCursor, \
+ sizeof(Cursor), APPDATAOFF(name1), XtRString, \
+ (XtPointer)#value \
+ }
+
+static XtResource app_resources[] =
+{
+ RINT(lines, Lines, 24),
+ RINT(cols, Cols, 80),
+
+ RPIXEL(cursorColor, CursorColor, Red),
+
+ RCOLOR(Black, Black),
+ RCOLOR(Red, red3),
+ RCOLOR(Green, green3),
+ RCOLOR(Yellow, yellow3),
+ RCOLOR(Blue, blue3),
+ RCOLOR(Magenta, magenta3),
+ RCOLOR(Cyan, cyan3),
+ RCOLOR(White, Grey),
+
+ RCOLOR(BoldBlack, grey40),
+ RCOLOR(BoldRed, red1),
+ RCOLOR(BoldGreen, green1),
+ RCOLOR(BoldYellow, yellow1),
+ RCOLOR(BoldBlue, blue1),
+ RCOLOR(BoldMagenta, magenta1),
+ RCOLOR(BoldCyan, cyan1),
+ RCOLOR(BoldWhite, White),
+
+ RFONT(normalFont, NormalFont, DEFFONT),
+ RFONT(italicFont, ItalicFont, DEFFONT),
+
+ RSTRING(bitmap, Bitmap),
+#ifdef HAVE_XPM_H
+ RSTRING(pixmap, Pixmap),
+#endif
+ RSTRINGP(composeKey, ComposeKey, "Multi_key"),
+
+ RCURSOR(pointer, Pointer, xterm),
+
+ RPIXEL(pointerForeColor, PointerForeColor, Black),
+ RPIXEL(pointerBackColor, PointerBackColor, White),
+
+ RINT(shmmin, Shmmin, 0),
+ RINT(borderWidth, BorderWidth, 0),
+
+ RPIXEL(borderColor, BorderColor, Black),
+
+ RINT(doubleClickPeriod, DoubleClickPeriod, (PDC_CLICK_PERIOD * 2)),
+ RINT(clickPeriod, ClickPeriod, PDC_CLICK_PERIOD),
+ RINT(scrollbarWidth, ScrollbarWidth, 15),
+ RINT(cursorBlinkRate, CursorBlinkRate, 0),
+
+ RSTRING(textCursor, TextCursor)
+};
+
+#undef RCURSOR
+#undef RFONT
+#undef RSTRING
+#undef RCOLOR
+#undef RPIXEL
+#undef RINT
+#undef APPDATAOFF
+#undef DEFFONT
+
+/* Macros for options */
+
+#define COPT(name) {"-" #name, "*" #name, XrmoptionSepArg, NULL}
+#define CCOLOR(name) COPT(color##name)
+
+static XrmOptionDescRec options[] =
+{
+ COPT(lines), COPT(cols), COPT(normalFont), COPT(italicFont),
+ COPT(bitmap),
+#ifdef HAVE_XPM_H
+ COPT(pixmap),
+#endif
+ COPT(pointer), COPT(shmmin), COPT(composeKey), COPT(clickPeriod),
+ COPT(doubleClickPeriod), COPT(scrollbarWidth),
+ COPT(pointerForeColor), COPT(pointerBackColor),
+ COPT(cursorBlinkRate), COPT(cursorColor), COPT(textCursor),
+
+ CCOLOR(Black), CCOLOR(Red), CCOLOR(Green), CCOLOR(Yellow),
+ CCOLOR(Blue), CCOLOR(Magenta), CCOLOR(Cyan), CCOLOR(White),
+
+ CCOLOR(BoldBlack), CCOLOR(BoldRed), CCOLOR(BoldGreen),
+ CCOLOR(BoldYellow), CCOLOR(BoldBlue), CCOLOR(BoldMagenta),
+ CCOLOR(BoldCyan), CCOLOR(BoldWhite)
+};
+
+#undef CCOLOR
+#undef COPT
+
+static XtActionsRec action_table[] =
+{
+ {"XCursesButton", (XtActionProc)XCursesButton},
+ {"XCursesKeyPress", (XtActionProc)XCursesKeyPress},
+ {"XCursesPasteSelection", (XtActionProc)XCursesPasteSelection},
+ {"string", (XtActionProc)XCursesHandleString}
+};
+
+static bool after_first_curses_request = FALSE;
+static Pixel colors[MAX_COLORS + 2];
+static bool vertical_cursor = FALSE;
+
+#ifdef PDC_XIM
+static XIM Xim = NULL;
+static XIC Xic = NULL;
+#endif
+
+static const char *default_translations =
+{
+ "<Key>: XCursesKeyPress() \n" \
+ "<KeyUp>: XCursesKeyPress() \n" \
+ "<BtnDown>: XCursesButton() \n" \
+ "<BtnUp>: XCursesButton() \n" \
+ "<BtnMotion>: XCursesButton()"
+};
+
+static int _to_utf8(char *outcode, chtype code)
+{
+#ifdef PDC_WIDE
+ if (code & A_ALTCHARSET && !(code & 0xff80))
+ code = acs_map[code & 0x7f];
+#endif
+ code &= A_CHARTEXT;
+
+ if (code < 0x80)
+ {
+ outcode[0] = code;
+ return 1;
+ }
+ else
+ if (code < 0x800)
+ {
+ outcode[0] = ((code & 0x07c0) >> 6) | 0xc0;
+ outcode[1] = (code & 0x003f) | 0x80;
+ return 2;
+ }
+ else
+ {
+ outcode[0] = ((code & 0xf000) >> 12) | 0xe0;
+ outcode[1] = ((code & 0x0fc0) >> 6) | 0x80;
+ outcode[2] = (code & 0x003f) | 0x80;
+ return 3;
+ }
+}
+
+static int _from_utf8(wchar_t *pwc, const char *s, size_t n)
+{
+ wchar_t key;
+ int i = -1;
+ const unsigned char *string;
+
+ if (!s || (n < 1))
+ return -1;
+
+ if (!*s)
+ return 0;
+
+ string = (const unsigned char *)s;
+
+ key = string[0];
+
+ /* Simplistic UTF-8 decoder -- only does the BMP, minimal validation */
+
+ if (key & 0x80)
+ {
+ if ((key & 0xe0) == 0xc0)
+ {
+ if (1 < n)
+ {
+ key = ((key & 0x1f) << 6) | (string[1] & 0x3f);
+ i = 2;
+ }
+ }
+ else if ((key & 0xe0) == 0xe0)
+ {
+ if (2 < n)
+ {
+ key = ((key & 0x0f) << 12) |
+ ((string[1] & 0x3f) << 6) | (string[2] & 0x3f);
+ i = 3;
+ }
+ }
+ }
+ else
+ i = 1;
+
+ if (i)
+ *pwc = key;
+
+ return i;
+}
+
+#ifndef X_HAVE_UTF8_STRING
+static Atom XA_UTF8_STRING(Display *dpy)
+{
+ static AtomPtr p = NULL;
+
+ if (!p)
+ p = XmuMakeAtom("UTF8_STRING");
+
+ return XmuInternAtom(dpy, p);
+}
+#endif
+
+signal_handler XCursesSetSignal(int signo, signal_handler action)
+{
+#if defined(SA_INTERRUPT) || defined(SA_RESTART)
+ struct sigaction sigact, osigact;
+
+ sigact.sa_handler = action;
+
+ sigact.sa_flags =
+# ifdef SA_INTERRUPT
+# ifdef SA_RESTART
+ SA_INTERRUPT | SA_RESTART;
+# else
+ SA_INTERRUPT;
+# endif
+# else /* must be SA_RESTART */
+ SA_RESTART;
+# endif
+ sigemptyset(&sigact.sa_mask);
+
+ if (sigaction(signo, &sigact, &osigact))
+ return SIG_ERR;
+
+ return osigact.sa_handler;
+
+#else /* not SA_INTERRUPT or SA_RESTART, use plain signal */
+ return signal(signo, action);
+#endif
+}
+
+RETSIGTYPE XCursesSigwinchHandler(int signo)
+{
+ PDC_LOG(("%s:XCursesSigwinchHandler() - called: SIGNO: %d\n",
+ XCLOGMSG, signo));
+
+ /* Patch by: Georg Fuchs, georg.fuchs@rz.uni-regensburg.de
+ 02-Feb-1999 */
+
+ SP->resized += 1;
+
+ /* Always trap SIGWINCH if the C library supports SIGWINCH */
+
+#ifdef SIGWINCH
+ XCursesSetSignal(SIGWINCH, XCursesSigwinchHandler);
+#endif
+}
+
+/* Convert character positions x and y to pixel positions, stored in
+ xpos and ypos */
+
+static void _make_xy(int x, int y, int *xpos, int *ypos)
+{
+ *xpos = (x * font_width) + xc_app_data.borderWidth;
+ *ypos = xc_app_data.normalFont->ascent + (y * font_height) +
+ xc_app_data.borderWidth;
+}
+
+/* Output a block of characters with common attributes */
+
+static int _new_packet(chtype attr, bool rev, int len, int col, int row,
+#ifdef PDC_WIDE
+ XChar2b *text)
+#else
+ char *text)
+#endif
+{
+ GC gc;
+ int xpos, ypos;
+ short fore, back;
+
+ PDC_pair_content(PAIR_NUMBER(attr), &fore, &back);
+
+#ifdef PDC_WIDE
+ text[len].byte1 = text[len].byte2 = 0;
+#else
+ text[len] = '\0';
+#endif
+
+ /* Specify the color table offsets */
+
+ fore |= (attr & A_BOLD) ? 8 : 0;
+ back |= (attr & A_BLINK) ? 8 : 0;
+
+ /* Reverse flag = highlighted selection XOR A_REVERSE set */
+
+ rev ^= !!(attr & A_REVERSE);
+
+ /* Determine which GC to use - normal or italic */
+
+ gc = (attr & A_ITALIC) ? italic_gc : normal_gc;
+
+ /* Draw it */
+
+ XSetForeground(XCURSESDISPLAY, gc, colors[rev ? back : fore]);
+ XSetBackground(XCURSESDISPLAY, gc, colors[rev ? fore : back]);
+
+ _make_xy(col, row, &xpos, &ypos);
+
+#ifdef PDC_WIDE
+ XDrawImageString16(
+#else
+ XDrawImageString(
+#endif
+ XCURSESDISPLAY, XCURSESWIN, gc, xpos, ypos, text, len);
+
+ /* Underline, etc. */
+
+ if (attr & (A_LEFTLINE|A_RIGHTLINE|A_UNDERLINE))
+ {
+ int k;
+
+ if (SP->line_color != -1)
+ XSetForeground(XCURSESDISPLAY, gc, colors[SP->line_color]);
+
+ if (attr & A_UNDERLINE) /* UNDER */
+ XDrawLine(XCURSESDISPLAY, XCURSESWIN, gc,
+ xpos, ypos + 1, xpos + font_width * len, ypos + 1);
+
+ if (attr & A_LEFTLINE) /* LEFT */
+ for (k = 0; k < len; k++)
+ {
+ int x = xpos + font_width * k - 1;
+ XDrawLine(XCURSESDISPLAY, XCURSESWIN, gc,
+ x, ypos - font_ascent, x, ypos + font_descent);
+ }
+
+ if (attr & A_RIGHTLINE) /* RIGHT */
+ for (k = 0; k < len; k++)
+ {
+ int x = xpos + font_width * (k + 1) - 1;
+ XDrawLine(XCURSESDISPLAY, XCURSESWIN, gc,
+ x, ypos - font_ascent, x, ypos + font_descent);
+ }
+ }
+
+ PDC_LOG(("%s:_new_packet() - row: %d col: %d "
+ "num_cols: %d fore: %d back: %d text:<%s>\n",
+ XCLOGMSG, row, col, len, fore, back, text));
+
+ return OK;
+}
+
+/* The core display routine -- update one line of text */
+
+static int _display_text(const chtype *ch, int row, int col,
+ int num_cols, bool highlight)
+{
+#ifdef PDC_WIDE
+ XChar2b text[513];
+#else
+ char text[513];
+#endif
+ chtype old_attr, attr;
+ int i, j;
+
+ PDC_LOG(("%s:_display_text() - called: row: %d col: %d "
+ "num_cols: %d\n", XCLOGMSG, row, col, num_cols));
+
+ if (!num_cols)
+ return OK;
+
+ old_attr = *ch & A_ATTRIBUTES;
+
+ for (i = 0, j = 0; j < num_cols; j++)
+ {
+ chtype curr = ch[j];
+
+ attr = curr & A_ATTRIBUTES;
+
+#ifdef CHTYPE_LONG
+ if (attr & A_ALTCHARSET && !(curr & 0xff80))
+ {
+ attr ^= A_ALTCHARSET;
+ curr = acs_map[curr & 0x7f];
+ }
+#endif
+
+#ifndef PDC_WIDE
+ /* Special handling for ACS_BLOCK */
+
+ if (!(curr & A_CHARTEXT))
+ {
+ curr |= ' ';
+ attr ^= A_REVERSE;
+ }
+#endif
+ if (attr != old_attr)
+ {
+ if (_new_packet(old_attr, highlight, i, col, row, text) == ERR)
+ return ERR;
+
+ old_attr = attr;
+ col += i;
+ i = 0;
+ }
+
+#ifdef PDC_WIDE
+ text[i].byte1 = (curr & 0xff00) >> 8;
+ text[i++].byte2 = curr & 0x00ff;
+#else
+ text[i++] = curr & 0xff;
+#endif
+ }
+
+ return _new_packet(old_attr, highlight, i, col, row, text);
+}
+
+static void _get_gc(GC *gc, XFontStruct *font_info, int fore, int back)
+{
+ XGCValues values;
+
+ /* Create default Graphics Context */
+
+ *gc = XCreateGC(XCURSESDISPLAY, XCURSESWIN, 0L, &values);
+
+ /* specify font */
+
+ XSetFont(XCURSESDISPLAY, *gc, font_info->fid);
+
+ XSetForeground(XCURSESDISPLAY, *gc, colors[fore]);
+ XSetBackground(XCURSESDISPLAY, *gc, colors[back]);
+}
+
+static void _initialize_colors(void)
+{
+ colors[COLOR_BLACK] = xc_app_data.colorBlack;
+ colors[COLOR_RED] = xc_app_data.colorRed;
+ colors[COLOR_GREEN] = xc_app_data.colorGreen;
+ colors[COLOR_YELLOW] = xc_app_data.colorYellow;
+ colors[COLOR_BLUE] = xc_app_data.colorBlue;
+ colors[COLOR_MAGENTA] = xc_app_data.colorMagenta;
+ colors[COLOR_CYAN] = xc_app_data.colorCyan;
+ colors[COLOR_WHITE] = xc_app_data.colorWhite;
+
+ colors[COLOR_BLACK + 8] = xc_app_data.colorBoldBlack;
+ colors[COLOR_RED + 8] = xc_app_data.colorBoldRed;
+ colors[COLOR_GREEN + 8] = xc_app_data.colorBoldGreen;
+ colors[COLOR_YELLOW + 8] = xc_app_data.colorBoldYellow;
+ colors[COLOR_BLUE + 8] = xc_app_data.colorBoldBlue;
+ colors[COLOR_MAGENTA + 8] = xc_app_data.colorBoldMagenta;
+ colors[COLOR_CYAN + 8] = xc_app_data.colorBoldCyan;
+ colors[COLOR_WHITE + 8] = xc_app_data.colorBoldWhite;
+
+ colors[COLOR_CURSOR] = xc_app_data.cursorColor;
+ colors[COLOR_BORDER] = xc_app_data.borderColor;
+}
+
+static void _refresh_scrollbar(void)
+{
+ XC_LOG(("_refresh_scrollbar() - called\n"));
+
+ if (SP->sb_on)
+ {
+ PDC_SCROLLBAR_TYPE total_y = SP->sb_total_y;
+ PDC_SCROLLBAR_TYPE total_x = SP->sb_total_x;
+
+ if (total_y)
+ XawScrollbarSetThumb(scrollVert,
+ (PDC_SCROLLBAR_TYPE)(SP->sb_cur_y) / total_y,
+ (PDC_SCROLLBAR_TYPE)(SP->sb_viewport_y) / total_y);
+
+ if (total_x)
+ XawScrollbarSetThumb(scrollHoriz,
+ (PDC_SCROLLBAR_TYPE)(SP->sb_cur_x) / total_x,
+ (PDC_SCROLLBAR_TYPE)(SP->sb_viewport_x) / total_x);
+ }
+}
+
+static void _set_cursor_color(chtype *ch, short *fore, short *back)
+{
+ int attr;
+ short f, b;
+
+ attr = PAIR_NUMBER(*ch);
+
+ if (attr)
+ {
+ PDC_pair_content(attr, &f, &b);
+ *fore = 7 - (f % 8);
+ *back = 7 - (b % 8);
+ }
+ else
+ {
+ if (*ch & A_REVERSE)
+ {
+ *back = COLOR_BLACK;
+ *fore = COLOR_WHITE;
+ }
+ else
+ {
+ *back = COLOR_WHITE;
+ *fore = COLOR_BLACK;
+ }
+ }
+}
+
+static void _get_icon(void)
+{
+ XIconSize *icon_size;
+ int size_count = 0;
+ Status rc;
+ unsigned char *bitmap_bits = NULL;
+ unsigned icon_bitmap_width = 0, icon_bitmap_height = 0,
+ file_bitmap_width = 0, file_bitmap_height = 0;
+
+ XC_LOG(("_get_icon() - called\n"));
+
+ icon_size = XAllocIconSize();
+
+ rc = XGetIconSizes(XtDisplay(topLevel),
+ RootWindowOfScreen(XtScreen(topLevel)),
+ &icon_size, &size_count);
+
+ /* if the WM can advise on icon sizes... */
+
+ if (rc && size_count)
+ {
+ int i, max_height = 0, max_width = 0;
+
+ PDC_LOG(("%s:size_count: %d rc: %d\n", XCLOGMSG, size_count, rc));
+
+ for (i = 0; i < size_count; i++)
+ {
+ if (icon_size[i].max_width > max_width)
+ max_width = icon_size[i].max_width;
+ if (icon_size[i].max_height > max_height)
+ max_height = icon_size[i].max_height;
+
+ PDC_LOG(("%s:min: %d %d\n", XCLOGMSG,
+ icon_size[i].min_width, icon_size[i].min_height));
+
+ PDC_LOG(("%s:max: %d %d\n", XCLOGMSG,
+ icon_size[i].max_width, icon_size[i].max_height));
+
+ PDC_LOG(("%s:inc: %d %d\n", XCLOGMSG,
+ icon_size[i].width_inc, icon_size[i].height_inc));
+ }
+
+ if (max_width >= big_icon_width && max_height >= big_icon_height)
+ {
+ icon_bitmap_width = big_icon_width;
+ icon_bitmap_height = big_icon_height;
+ bitmap_bits = (unsigned char *)big_icon_bits;
+ }
+ else
+ {
+ icon_bitmap_width = little_icon_width;
+ icon_bitmap_height = little_icon_height;
+ bitmap_bits = (unsigned char *)little_icon_bits;
+ }
+
+ }
+ else /* use small icon */
+ {
+ icon_bitmap_width = little_icon_width;
+ icon_bitmap_height = little_icon_height;
+ bitmap_bits = (unsigned char *)little_icon_bits;
+ }
+
+ XFree(icon_size);
+
+#ifdef HAVE_XPM_H
+ if (xc_app_data.pixmap && xc_app_data.pixmap[0]) /* supplied pixmap */
+ {
+ XpmReadFileToPixmap(XtDisplay(topLevel),
+ RootWindowOfScreen(XtScreen(topLevel)),
+ (char *)xc_app_data.pixmap,
+ &icon_pixmap, &icon_pixmap_mask, NULL);
+ return;
+ }
+#endif
+
+ if (xc_app_data.bitmap && xc_app_data.bitmap[0]) /* supplied bitmap */
+ {
+ int x_hot = 0, y_hot = 0;
+
+ rc = XReadBitmapFile(XtDisplay(topLevel),
+ RootWindowOfScreen(XtScreen(topLevel)),
+ (char *)xc_app_data.bitmap,
+ &file_bitmap_width, &file_bitmap_height,
+ &icon_bitmap, &x_hot, &y_hot);
+
+ switch(rc)
+ {
+ case BitmapOpenFailed:
+ fprintf(stderr, "bitmap file %s: not found\n",
+ xc_app_data.bitmap);
+ break;
+ case BitmapFileInvalid:
+ fprintf(stderr, "bitmap file %s: contents invalid\n",
+ xc_app_data.bitmap);
+ break;
+ default:
+ return;
+ }
+ }
+
+ icon_bitmap = XCreateBitmapFromData(XtDisplay(topLevel),
+ RootWindowOfScreen(XtScreen(topLevel)),
+ (char *)bitmap_bits, icon_bitmap_width, icon_bitmap_height);
+}
+
+static void _draw_border(void)
+{
+ /* Draw the border if required */
+
+ if (xc_app_data.borderWidth)
+ XDrawRectangle(XCURSESDISPLAY, XCURSESWIN, border_gc,
+ xc_app_data.borderWidth / 2,
+ xc_app_data.borderWidth / 2,
+ window_width - xc_app_data.borderWidth,
+ window_height - xc_app_data.borderWidth);
+}
+
+/* Redraw the entire screen */
+
+static void _display_screen(void)
+{
+ int row;
+
+ XC_LOG(("_display_screen() - called\n"));
+
+ for (row = 0; row < XCursesLINES; row++)
+ {
+ XC_get_line_lock(row);
+
+ _display_text((const chtype *)(Xcurscr + XCURSCR_Y_OFF(row)),
+ row, 0, COLS, FALSE);
+
+ XC_release_line_lock(row);
+ }
+
+ _redraw_cursor();
+ _draw_border();
+}
+
+/* Draw changed portions of the screen */
+
+static void _refresh_screen(void)
+{
+ int row, start_col, num_cols;
+
+ XC_LOG(("_refresh_screen() - called\n"));
+
+ for (row = 0; row < XCursesLINES; row++)
+ {
+ num_cols = (int)*(Xcurscr + XCURSCR_LENGTH_OFF + row);
+
+ if (num_cols)
+ {
+ XC_get_line_lock(row);
+
+ start_col = (int)*(Xcurscr + XCURSCR_START_OFF + row);
+
+ _display_text((const chtype *)(Xcurscr + XCURSCR_Y_OFF(row) +
+ (start_col * sizeof(chtype))), row, start_col,
+ num_cols, FALSE);
+
+ *(Xcurscr + XCURSCR_LENGTH_OFF + row) = 0;
+
+ XC_release_line_lock(row);
+ }
+ }
+
+ if (mouse_selection)
+ _selection_off();
+}
+
+static void _handle_expose(Widget w, XtPointer client_data, XEvent *event,
+ Boolean *unused)
+{
+ XC_LOG(("_handle_expose() - called\n"));
+
+ /* ignore all Exposes except last */
+
+ if (event->xexpose.count)
+ return;
+
+ if (after_first_curses_request && received_map_notify)
+ _display_screen();
+}
+
+static void _handle_nonmaskable(Widget w, XtPointer client_data, XEvent *event,
+ Boolean *unused)
+{
+ XClientMessageEvent *client_event = (XClientMessageEvent *)event;
+
+ PDC_LOG(("%s:_handle_nonmaskable called: xc_otherpid %d event %d\n",
+ XCLOGMSG, xc_otherpid, event->type));
+
+ if (event->type == ClientMessage)
+ {
+ XC_LOG(("ClientMessage received\n"));
+
+ /* This code used to include handling of WM_SAVE_YOURSELF, but
+ it resulted in continual failure of THE on my Toshiba laptop.
+ Removed on 3-3-2001. Now only exits on WM_DELETE_WINDOW. */
+
+ if ((Atom)client_event->data.s[0] == wm_atom[0])
+ _exit_process(0, SIGKILL, "");
+ }
+}
+
+static void XCursesKeyPress(Widget w, XEvent *event, String *params,
+ Cardinal *nparams)
+{
+ enum { STATE_NORMAL, STATE_COMPOSE, STATE_CHAR };
+
+#ifdef PDC_XIM
+ Status status;
+ wchar_t buffer[120];
+#else
+ unsigned char buffer[120];
+ XComposeStatus compose;
+ static int compose_state = STATE_NORMAL;
+ static int compose_index = 0;
+ int char_idx = 0;
+#endif
+ unsigned long key = 0;
+ int buflen = 40;
+ int i, count;
+ unsigned long modifier = 0;
+ bool key_code = FALSE;
+
+ XC_LOG(("XCursesKeyPress() - called\n"));
+
+ /* Handle modifier keys first; ignore other KeyReleases */
+
+ if (event->type == KeyRelease)
+ {
+ /* The keysym value was set by a previous call to this function
+ with a KeyPress event (or reset by the mouse event handler) */
+
+ if (SP->return_key_modifiers &&
+#ifndef PDC_XIM
+ keysym != compose_key &&
+#endif
+ IsModifierKey(keysym))
+ {
+ switch (keysym) {
+ case XK_Shift_L:
+ key = KEY_SHIFT_L;
+ break;
+ case XK_Shift_R:
+ key = KEY_SHIFT_R;
+ break;
+ case XK_Control_L:
+ key = KEY_CONTROL_L;
+ break;
+ case XK_Control_R:
+ key = KEY_CONTROL_R;
+ break;
+ case XK_Alt_L:
+ key = KEY_ALT_L;
+ break;
+ case XK_Alt_R:
+ key = KEY_ALT_R;
+ }
+
+ if (key)
+ _send_key_to_curses(key, NULL, TRUE);
+ }
+
+ return;
+ }
+
+ buffer[0] = '\0';
+
+#ifdef PDC_XIM
+ count = XwcLookupString(Xic, &(event->xkey), buffer, buflen,
+ &keysym, &status);
+#else
+ count = XLookupString(&(event->xkey), (char *)buffer, buflen,
+ &keysym, &compose);
+#endif
+
+ /* translate keysym into curses key code */
+
+ PDC_LOG(("%s:Key mask: %x\n", XCLOGMSG, event->xkey.state));
+
+#ifdef PDCDEBUG
+ for (i = 0; i < 4; i++)
+ PDC_debug("%s:Keysym %x %d\n", XCLOGMSG,
+ XKeycodeToKeysym(XCURSESDISPLAY, event->xkey.keycode, i), i);
+#endif
+
+#ifndef PDC_XIM
+
+ /* Check if the key just pressed is the user-specified compose
+ key; if it is, set the compose state and exit. */
+
+ if (keysym == compose_key)
+ {
+ chtype *ch;
+ int xpos, ypos, save_visibility = SP->visibility;
+ short fore = 0, back = 0;
+
+ /* Change the shape of the cursor to an outline rectangle to
+ indicate we are in "compose" status */
+
+ SP->visibility = 0;
+
+ _redraw_cursor();
+
+ SP->visibility = save_visibility;
+ _make_xy(SP->curscol, SP->cursrow, &xpos, &ypos);
+
+ ch = (chtype *)(Xcurscr + XCURSCR_Y_OFF(SP->cursrow) +
+ (SP->curscol * sizeof(chtype)));
+
+ _set_cursor_color(ch, &fore, &back);
+
+ XSetForeground(XCURSESDISPLAY, rect_cursor_gc, colors[back]);
+
+ XDrawRectangle(XCURSESDISPLAY, XCURSESWIN, rect_cursor_gc,
+ xpos + 1, ypos - font_height +
+ xc_app_data.normalFont->descent + 1,
+ font_width - 2, font_height - 2);
+
+ compose_state = STATE_COMPOSE;
+ return;
+ }
+
+ switch (compose_state)
+ {
+ case STATE_COMPOSE:
+ if (IsModifierKey(keysym))
+ return;
+
+ if (event->xkey.state & compose_mask)
+ {
+ compose_state = STATE_NORMAL;
+ _redraw_cursor();
+ break;
+ }
+
+ if (buffer[0] && count == 1)
+ key = buffer[0];
+
+ compose_index = -1;
+
+ for (i = 0; i < (int)strlen(compose_chars); i++)
+ if (compose_chars[i] == key)
+ {
+ compose_index = i;
+ break;
+ }
+
+ if (compose_index == -1)
+ {
+ compose_state = STATE_NORMAL;
+ compose_index = 0;
+ _redraw_cursor();
+ break;
+ }
+
+ compose_state = STATE_CHAR;
+ return;
+
+ case STATE_CHAR:
+ if (IsModifierKey(keysym))
+ return;
+
+ if (event->xkey.state & compose_mask)
+ {
+ compose_state = STATE_NORMAL;
+ _redraw_cursor();
+ break;
+ }
+
+ if (buffer[0] && count == 1)
+ key = buffer[0];
+
+ char_idx = -1;
+
+ for (i = 0; i < MAX_COMPOSE_CHARS; i++)
+ if (compose_lookups[compose_index][i] == key)
+ {
+ char_idx = i;
+ break;
+ }
+
+ if (char_idx == -1)
+ {
+ compose_state = STATE_NORMAL;
+ compose_index = 0;
+ _redraw_cursor();
+ break;
+ }
+
+ _send_key_to_curses(compose_keys[compose_index][char_idx],
+ NULL, FALSE);
+
+ compose_state = STATE_NORMAL;
+ compose_index = 0;
+
+ _redraw_cursor();
+
+ return;
+ }
+
+#endif /* PDC_XIM */
+
+ /* To get here we are procesing "normal" keys */
+
+ PDC_LOG(("%s:Keysym %x %d\n", XCLOGMSG,
+ XKeycodeToKeysym(XCURSESDISPLAY, event->xkey.keycode, key), key));
+
+ if (SP->save_key_modifiers)
+ {
+ /* 0x10: usually, numlock modifier */
+
+ if (event->xkey.state & Mod2Mask)
+ modifier |= PDC_KEY_MODIFIER_NUMLOCK;
+
+ /* 0x01: shift modifier */
+
+ if (event->xkey.state & ShiftMask)
+ modifier |= PDC_KEY_MODIFIER_SHIFT;
+
+ /* 0x04: control modifier */
+
+ if (event->xkey.state & ControlMask)
+ modifier |= PDC_KEY_MODIFIER_CONTROL;
+
+ /* 0x08: usually, alt modifier */
+
+ if (event->xkey.state & Mod1Mask)
+ modifier |= PDC_KEY_MODIFIER_ALT;
+ }
+
+ for (i = 0; key_table[i].keycode; i++)
+ {
+ if (key_table[i].keycode == keysym)
+ {
+ PDC_LOG(("%s:State %x\n", XCLOGMSG, event->xkey.state));
+
+ /* ControlMask: 0x04: control modifier
+ Mod1Mask: 0x08: usually, alt modifier
+ Mod2Mask: 0x10: usually, numlock modifier
+ ShiftMask: 0x01: shift modifier */
+
+ if ((event->xkey.state & ShiftMask) ||
+ (key_table[i].numkeypad &&
+ (event->xkey.state & Mod2Mask)))
+ {
+ key = key_table[i].shifted;
+ }
+ else if (event->xkey.state & ControlMask)
+ {
+ key = key_table[i].control;
+ }
+ else if (event->xkey.state & Mod1Mask)
+ {
+ key = key_table[i].alt;
+ }
+
+ /* To get here, we ignore all other modifiers */
+
+ else
+ key = key_table[i].normal;
+
+ key_code = (key > 0x100);
+ break;
+ }
+ }
+
+ if (!key && buffer[0] && count == 1)
+ key = buffer[0];
+
+ PDC_LOG(("%s:Key: %s pressed - %x Mod: %x\n", XCLOGMSG,
+ XKeysymToString(keysym), key, event->xkey.state));
+
+ /* Handle ALT letters and numbers */
+
+ if (event->xkey.state == Mod1Mask)
+ {
+ if (key >= 'A' && key <= 'Z')
+ {
+ key += ALT_A - 'A';
+ key_code = TRUE;
+ }
+
+ if (key >= 'a' && key <= 'z')
+ {
+ key += ALT_A - 'a';
+ key_code = TRUE;
+ }
+
+ if (key >= '0' && key <= '9')
+ {
+ key += ALT_0 - '0';
+ key_code = TRUE;
+ }
+ }
+
+ /* After all that, send the key back to the application if is
+ NOT zero. */
+
+ if (key)
+ {
+ key |= (modifier << 24);
+
+ _send_key_to_curses(key, NULL, key_code);
+ }
+}
+
+static void XCursesHandleString(Widget w, XEvent *event, String *params,
+ Cardinal *nparams)
+{
+ unsigned char *ptr;
+
+ if (*nparams != 1)
+ return;
+
+ ptr = (unsigned char *)*params;
+
+ if (ptr[0] == '0' && ptr[1] == 'x' && ptr[2] != '\0')
+ {
+ unsigned char c;
+ unsigned long total = 0;
+
+ for (ptr += 2; (c = tolower(*ptr)); ptr++)
+ {
+ total <<= 4;
+
+ if (c >= '0' && c <= '9')
+ total += c - '0';
+ else
+ if (c >= 'a' && c <= 'f')
+ total += c - ('a' - 10);
+ else
+ break;
+ }
+
+ if (c == '\0')
+ _send_key_to_curses(total, NULL, FALSE);
+ }
+ else
+ for (; *ptr; ptr++)
+ _send_key_to_curses((unsigned long)*ptr, NULL, FALSE);
+}
+
+static void _paste_string(Widget w, XtPointer data, Atom *selection, Atom *type,
+ XtPointer value, unsigned long *length, int *format)
+{
+ unsigned long i, key;
+ unsigned char *string = value;
+
+ XC_LOG(("_paste_string() - called\n"));
+
+ if (!*type || !*length || !string)
+ return;
+
+ for (i = 0; string[i] && (i < (*length)); i++)
+ {
+ key = string[i];
+
+ if (key == 10) /* new line - convert to ^M */
+ key = 13;
+
+ _send_key_to_curses(key, NULL, FALSE);
+ }
+
+ XtFree(value);
+}
+
+static void _paste_utf8(Widget w, XtPointer event, Atom *selection, Atom *type,
+ XtPointer value, unsigned long *length, int *format)
+{
+ wchar_t key;
+ size_t i = 0, len;
+ char *string = value;
+
+ XC_LOG(("_paste_utf8() - called\n"));
+
+ if (!*type || !*length)
+ {
+ XtGetSelectionValue(w, XA_PRIMARY, XA_STRING, _paste_string,
+ event, ((XButtonEvent *)event)->time);
+ return;
+ }
+
+ len = *length;
+
+ if (!string)
+ return;
+
+ while (string[i] && (i < len))
+ {
+ int retval = _from_utf8(&key, string + i, len - i);
+
+ if (retval < 1)
+ return;
+
+ if (key == 10) /* new line - convert to ^M */
+ key = 13;
+
+ _send_key_to_curses(key, NULL, FALSE);
+
+ i += retval;
+ }
+
+ XtFree(value);
+}
+
+static void XCursesPasteSelection(Widget w, XButtonEvent *button_event)
+{
+ XC_LOG(("XCursesPasteSelection() - called\n"));
+
+ XtGetSelectionValue(w, XA_PRIMARY, XA_UTF8_STRING(XtDisplay(w)),
+ _paste_utf8, (XtPointer)button_event,
+ button_event->time);
+}
+
+static Boolean _convert_proc(Widget w, Atom *selection, Atom *target,
+ Atom *type_return, XtPointer *value_return,
+ unsigned long *length_return, int *format_return)
+{
+ XC_LOG(("_convert_proc() - called\n"));
+
+ if (*target == XA_TARGETS(XtDisplay(topLevel)))
+ {
+ XSelectionRequestEvent *req = XtGetSelectionRequest(w,
+ *selection, (XtRequestId)NULL);
+
+ Atom *targetP;
+ XPointer std_targets;
+ unsigned long std_length;
+
+ XmuConvertStandardSelection(topLevel, req->time, selection,
+ target, type_return, &std_targets,
+ &std_length, format_return);
+
+ *length_return = std_length + 2;
+ *value_return = XtMalloc(sizeof(Atom) * (*length_return));
+
+ targetP = *(Atom**)value_return;
+ *targetP++ = XA_STRING;
+ *targetP++ = XA_UTF8_STRING(XtDisplay(topLevel));
+
+ memmove((void *)targetP, (const void *)std_targets,
+ sizeof(Atom) * std_length);
+
+ XtFree((char *)std_targets);
+ *type_return = XA_ATOM;
+ *format_return = sizeof(Atom) * 8;
+
+ return True;
+ }
+ else if (*target == XA_UTF8_STRING(XtDisplay(topLevel)) ||
+ *target == XA_STRING)
+ {
+ bool utf8 = !(*target == XA_STRING);
+ char *data = XtMalloc(tmpsel_length * 3 + 1);
+ chtype *tmp = tmpsel;
+ int ret_length = 0;
+
+ if (utf8)
+ {
+ while (*tmp)
+ ret_length += _to_utf8(data + ret_length, *tmp++);
+ }
+ else
+ while (*tmp)
+ data[ret_length++] = *tmp++ & 0xff;
+
+ data[ret_length++] = '\0';
+
+ *value_return = data;
+ *length_return = ret_length;
+ *format_return = 8;
+ *type_return = *target;
+
+ return True;
+ }
+ else
+ return XmuConvertStandardSelection(topLevel, CurrentTime,
+ selection, target, type_return, (XPointer*)value_return,
+ length_return, format_return);
+}
+
+static void _lose_ownership(Widget w, Atom *type)
+{
+ XC_LOG(("_lose_ownership() - called\n"));
+
+ if (tmpsel)
+ free(tmpsel);
+
+ tmpsel = NULL;
+ tmpsel_length = 0;
+ _selection_off();
+}
+
+static void _show_selection(int start_x, int start_y, int end_x, int end_y,
+ bool highlight)
+{
+ int i, num_cols, start_col, row;
+
+ PDC_LOG(("%s:_show_selection() - called StartX: %d StartY: %d "
+ "EndX: %d EndY: %d Highlight: %d\n", XCLOGMSG,
+ start_x, start_y, end_x, end_y, highlight));
+
+ for (i = 0; i < end_y - start_y + 1; i++)
+ {
+ if (start_y == end_y) /* only one line */
+ {
+ start_col = start_x;
+ num_cols = end_x - start_x + 1;
+ row = start_y;
+ }
+ else if (!i) /* first line */
+ {
+ start_col = start_x;
+ num_cols = COLS - start_x;
+ row = start_y;
+ }
+ else if (start_y + i == end_y) /* last line */
+ {
+ start_col = 0;
+ num_cols = end_x + 1;
+ row = end_y;
+ }
+ else /* full line */
+ {
+ start_col = 0;
+ num_cols = COLS;
+ row = start_y + i;
+ }
+
+ XC_get_line_lock(row);
+
+ _display_text((const chtype *)(Xcurscr + XCURSCR_Y_OFF(row) +
+ (start_col * sizeof(chtype))), row, start_col,
+ num_cols, highlight);
+
+ XC_release_line_lock(row);
+ }
+}
+
+static void _selection_off(void)
+{
+ XC_LOG(("_selection_off() - called\n"));
+
+ _display_screen();
+
+ selection_start_x = selection_start_y = selection_end_x =
+ selection_end_y = 0;
+
+ mouse_selection = FALSE;
+}
+
+static void _selection_on(int x, int y)
+{
+ XC_LOG(("_selection_on() - called\n"));
+
+ selection_start_x = selection_end_x = x;
+ selection_start_y = selection_end_y = y;
+}
+
+static void _selection_extend(int x, int y)
+{
+ int temp, current_start, current_end, current_start_x,
+ current_end_x, current_start_y, current_end_y, new_start,
+ new_end, new_start_x, new_end_x, new_start_y, new_end_y;
+
+ XC_LOG(("_selection_extend() - called\n"));
+
+ mouse_selection = TRUE;
+
+ /* convert x/y coordinates into start/stop */
+
+ current_start = (selection_start_y * COLS) + selection_start_x;
+ current_end = (selection_end_y * COLS) + selection_end_x;
+
+ if (current_start > current_end)
+ {
+ current_start_x = selection_end_x;
+ current_start_y = selection_end_y;
+ current_end_x = selection_start_x;
+ current_end_y = selection_start_y;
+ temp = current_start;
+ current_start = current_end;
+ current_end = temp;
+ }
+ else
+ {
+ current_end_x = selection_end_x;
+ current_end_y = selection_end_y;
+ current_start_x = selection_start_x;
+ current_start_y = selection_start_y;
+ }
+
+ /* Now we have the current selection as a linear expression.
+ Convert the new position to a linear expression. */
+
+ selection_end_x = x;
+ selection_end_y = y;
+
+ /* convert x/y coordinates into start/stop */
+
+ new_start = (selection_start_y * COLS) + selection_start_x;
+ new_end = (selection_end_y * COLS) + selection_end_x;
+
+ if (new_start > new_end)
+ {
+ new_start_x = selection_end_x;
+ new_start_y = selection_end_y;
+ new_end_x = selection_start_x;
+ new_end_y = selection_start_y;
+ temp = new_start;
+ new_start = new_end;
+ new_end = temp;
+ }
+ else
+ {
+ new_end_x = selection_end_x;
+ new_end_y = selection_end_y;
+ new_start_x = selection_start_x;
+ new_start_y = selection_start_y;
+ }
+
+ if (new_end > current_end)
+ _show_selection(current_end_x, current_end_y, new_end_x,
+ new_end_y, TRUE);
+ else if (new_end < current_end)
+ _show_selection(new_end_x, new_end_y, current_end_x,
+ current_end_y, FALSE);
+ else if (new_start < current_start)
+ _show_selection(new_start_x, new_start_y, current_start_x,
+ current_start_y, TRUE);
+ else if (new_start > current_start)
+ _show_selection(current_start_x, current_start_y,
+ new_start_x, new_start_y, FALSE);
+ else
+ _show_selection(current_start_x, current_start_y,
+ new_start_x, new_start_y, TRUE);
+}
+
+static void _selection_set(void)
+{
+ int i, j, start, end, start_x, end_x, start_y, end_y, num_cols,
+ start_col, row, num_chars, ch, last_nonblank, length, newlen;
+ chtype *ptr = NULL;
+
+ XC_LOG(("_selection_set() - called\n"));
+
+ /* convert x/y coordinates into start/stop */
+
+ start = (selection_start_y * COLS) + selection_start_x;
+ end = (selection_end_y * COLS) + selection_end_x;
+
+ if (start == end)
+ {
+ if (tmpsel)
+ free(tmpsel);
+
+ tmpsel = NULL;
+ tmpsel_length = 0;
+
+ return;
+ }
+
+ if (start > end)
+ {
+ start_x = selection_end_x;
+ start_y = selection_end_y;
+ end_x = selection_start_x;
+ end_y = selection_start_y;
+ length = start - end + 1;
+ }
+ else
+ {
+ end_x = selection_end_x;
+ end_y = selection_end_y;
+ start_x = selection_start_x;
+ start_y = selection_start_y;
+ length = end - start + 1;
+ }
+
+ newlen = length + end_y - start_y + 2;
+
+ if (length > (int)tmpsel_length)
+ {
+ if (!tmpsel_length)
+ tmpsel = malloc(newlen * sizeof(chtype));
+ else
+ tmpsel = realloc(tmpsel, newlen * sizeof(chtype));
+ }
+
+ if (!tmpsel)
+ {
+ tmpsel_length = 0;
+ return;
+ }
+
+ tmpsel_length = length;
+ num_chars = 0;
+
+ for (i = 0; i < end_y - start_y + 1; i++)
+ {
+
+ if (start_y == end_y) /* only one line */
+ {
+ start_col = start_x;
+ num_cols = end_x - start_x + 1;
+ row = start_y;
+ }
+ else if (!i) /* first line */
+ {
+ start_col = start_x;
+ num_cols = COLS - start_x;
+ row = start_y;
+ }
+ else if (start_y + i == end_y) /* last line */
+ {
+ start_col = 0;
+ num_cols = end_x + 1;
+ row = end_y;
+ }
+ else /* full line */
+ {
+ start_col = 0;
+ num_cols = COLS;
+ row = start_y + i;
+ }
+
+ XC_get_line_lock(row);
+
+ ptr = (chtype *)(Xcurscr + XCURSCR_Y_OFF(row) +
+ start_col * sizeof(chtype));
+
+ if (i < end_y - start_y)
+ {
+ last_nonblank = 0;
+
+ for (j = 0; j < num_cols; j++)
+ {
+ ch = (int)(ptr[j] & A_CHARTEXT);
+ if (ch != (int)' ')
+ last_nonblank = j;
+ }
+ }
+ else
+ last_nonblank = num_cols - 1;
+
+ for (j = 0; j <= last_nonblank; j++)
+ tmpsel[num_chars++] = ptr[j];
+
+ XC_release_line_lock(row);
+
+ if (i < end_y - start_y)
+ tmpsel[num_chars++] = '\n';
+ }
+
+ tmpsel[num_chars] = '\0';
+ tmpsel_length = num_chars;
+}
+
+static void _display_cursor(int old_row, int old_x, int new_row, int new_x)
+{
+ int xpos, ypos, i;
+ chtype *ch;
+ short fore = 0, back = 0;
+
+ PDC_LOG(("%s:_display_cursor() - draw char at row: %d col %d\n",
+ XCLOGMSG, old_row, old_x));
+
+ /* if the cursor position is outside the boundary of the screen,
+ ignore the request */
+
+ if (old_row >= XCursesLINES || old_x >= COLS ||
+ new_row >= XCursesLINES || new_x >= COLS)
+ return;
+
+ /* display the character at the current cursor position */
+
+ PDC_LOG(("%s:_display_cursor() - draw char at row: %d col %d\n",
+ XCLOGMSG, old_row, old_x));
+
+ _display_text((const chtype *)(Xcurscr + (XCURSCR_Y_OFF(old_row) +
+ (old_x * sizeof(chtype)))), old_row, old_x, 1, FALSE);
+
+ /* display the cursor at the new cursor position */
+
+ if (!SP->visibility)
+ return; /* cursor not displayed, no more to do */
+
+ _make_xy(new_x, new_row, &xpos, &ypos);
+
+ ch = (chtype *)(Xcurscr + XCURSCR_Y_OFF(new_row) + new_x * sizeof(chtype));
+
+ _set_cursor_color(ch, &fore, &back);
+
+ if (vertical_cursor)
+ {
+ XSetForeground(XCURSESDISPLAY, rect_cursor_gc, colors[back]);
+
+ for (i = 1; i <= SP->visibility; i++)
+ XDrawLine(XCURSESDISPLAY, XCURSESWIN, rect_cursor_gc,
+ xpos + i, ypos - xc_app_data.normalFont->ascent,
+ xpos + i, ypos - xc_app_data.normalFont->ascent +
+ font_height - 1);
+ }
+ else
+ {
+ if (SP->visibility == 1)
+ {
+ /* cursor visibility normal */
+
+ XSetForeground(XCURSESDISPLAY, rect_cursor_gc, colors[back]);
+
+ for (i = 0; i < xc_app_data.normalFont->descent + 2; i++)
+ XDrawLine(XCURSESDISPLAY, XCURSESWIN, rect_cursor_gc,
+ xpos, ypos - 2 + i, xpos + font_width, ypos - 2 + i);
+ }
+ else
+ {
+ /* cursor visibility high */
+#ifdef PDC_WIDE
+ XChar2b buf[2];
+
+ buf[0].byte1 = (*ch & 0xff00) >> 8;
+ buf[0].byte2 = *ch & 0x00ff;
+
+ buf[1].byte1 = buf[1].byte2 = 0;
+#else
+ char buf[2];
+
+ buf[0] = *ch & 0xff;
+ buf[1] = '\0';
+#endif
+ XSetForeground(XCURSESDISPLAY, block_cursor_gc, colors[fore]);
+ XSetBackground(XCURSESDISPLAY, block_cursor_gc, colors[back]);
+#ifdef PDC_WIDE
+ XDrawImageString16(
+#else
+ XDrawImageString(
+#endif
+ XCURSESDISPLAY, XCURSESWIN, block_cursor_gc,
+ xpos, ypos, buf, 1);
+ }
+ }
+
+ PDC_LOG(("%s:_display_cursor() - draw cursor at row %d col %d\n",
+ XCLOGMSG, new_row, new_x));
+}
+
+static void _redraw_cursor(void)
+{
+ _display_cursor(SP->cursrow, SP->curscol, SP->cursrow, SP->curscol);
+}
+
+static void _handle_enter_leave(Widget w, XtPointer client_data,
+ XEvent *event, Boolean *unused)
+{
+ XC_LOG(("_handle_enter_leave called\n"));
+
+ switch(event->type)
+ {
+ case EnterNotify:
+ XC_LOG(("EnterNotify received\n"));
+
+ window_entered = TRUE;
+ break;
+
+ case LeaveNotify:
+ XC_LOG(("LeaveNotify received\n"));
+
+ window_entered = FALSE;
+
+ /* Display the cursor so it stays on while the window is
+ not current */
+
+ _redraw_cursor();
+ break;
+
+ default:
+ PDC_LOG(("%s:_handle_enter_leave - unknown event %d\n",
+ XCLOGMSG, event->type));
+ }
+}
+
+static void _send_key_to_curses(unsigned long key, MOUSE_STATUS *ms,
+ bool key_code)
+{
+ PDC_LOG(("%s:_send_key_to_curses() - called: sending %d\n",
+ XCLOGMSG, key));
+
+ SP->key_code = key_code;
+
+ if (XC_write_socket(xc_key_sock, &key, sizeof(unsigned long)) < 0)
+ _exit_process(1, SIGKILL, "exiting from _send_key_to_curses");
+
+ if (ms)
+ {
+ MOUSE_LOG(("%s:writing mouse stuff\n", XCLOGMSG));
+
+ if (XC_write_socket(xc_key_sock, ms, sizeof(MOUSE_STATUS)) < 0)
+ _exit_process(1, SIGKILL, "exiting from _send_key_to_curses");
+ }
+}
+
+static void _blink_cursor(XtPointer unused, XtIntervalId *id)
+{
+ XC_LOG(("_blink_cursor() - called:\n"));
+
+ if (window_entered)
+ {
+ if (visible_cursor)
+ {
+ /* Cursor currently ON, turn it off */
+
+ int save_visibility = SP->visibility;
+ SP->visibility = 0;
+ _redraw_cursor();
+ SP->visibility = save_visibility;
+ visible_cursor = FALSE;
+ }
+ else
+ {
+ /* Cursor currently OFF, turn it on */
+
+ _redraw_cursor();
+ visible_cursor = TRUE;
+ }
+ }
+
+ XtAppAddTimeOut(app_context, xc_app_data.cursorBlinkRate,
+ _blink_cursor, NULL);
+}
+
+static void XCursesButton(Widget w, XEvent *event, String *params,
+ Cardinal *nparams)
+{
+ int button_no;
+ static int last_button_no = 0;
+ static Time last_button_press_time = 0;
+ MOUSE_STATUS save_mouse_status;
+ bool send_key = TRUE;
+ static bool remove_release;
+ static bool handle_real_release;
+
+ XC_LOG(("XCursesButton() - called\n"));
+
+ keysym = 0; /* suppress any modifier key return */
+
+ save_mouse_status = Mouse_status;
+ button_no = event->xbutton.button;
+
+ /* It appears that under X11R6 (at least on Linux), that an
+ event_type of ButtonMotion does not include the mouse button in
+ the event. The following code is designed to cater for this
+ situation. */
+
+ if (!button_no)
+ button_no = last_button_no;
+
+ last_button_no = button_no;
+
+ Mouse_status.changes = 0;
+
+ switch(event->type)
+ {
+ case ButtonPress:
+ /* Handle button 4 and 5, which are normally mapped to the wheel
+ mouse scroll up and down */
+
+ if (button_no == 4 || button_no == 5)
+ {
+ /* Send the KEY_MOUSE to curses program */
+
+ memset(&Mouse_status, 0, sizeof(Mouse_status));
+
+ Mouse_status.changes = (button_no == 5) ?
+ PDC_MOUSE_WHEEL_DOWN : PDC_MOUSE_WHEEL_UP;
+
+ MOUSE_X_POS = MOUSE_Y_POS = -1;
+ _send_key_to_curses(KEY_MOUSE, &Mouse_status, TRUE);
+ remove_release = TRUE;
+
+ return;
+ }
+
+ if (button_no == 2 &&
+ (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
+ {
+ XCursesPasteSelection(drawing, (XButtonEvent *)event);
+ remove_release = TRUE;
+
+ return;
+ }
+
+ remove_release = False;
+ handle_real_release = False;
+
+ MOUSE_LOG(("\nButtonPress\n"));
+
+ if ((event->xbutton.time - last_button_press_time) <
+ xc_app_data.doubleClickPeriod)
+ {
+ MOUSE_X_POS = save_mouse_status.x;
+ MOUSE_Y_POS = save_mouse_status.y;
+ BUTTON_STATUS(button_no) = BUTTON_DOUBLE_CLICKED;
+
+ _selection_off();
+ remove_release = True;
+ }
+ else
+ {
+ napms(SP->mouse_wait);
+ event->type = ButtonRelease;
+ XSendEvent(event->xbutton.display, event->xbutton.window,
+ True, 0, event);
+ last_button_press_time = event->xbutton.time;
+
+ return;
+ }
+
+ last_button_press_time = event->xbutton.time;
+ break;
+
+ case MotionNotify:
+ MOUSE_LOG(("\nMotionNotify: y: %d x: %d Width: %d "
+ "Height: %d\n", event->xbutton.y, event->xbutton.x,
+ font_width, font_height));
+
+ MOUSE_X_POS = (event->xbutton.x - xc_app_data.borderWidth) /
+ font_width;
+ MOUSE_Y_POS = (event->xbutton.y - xc_app_data.borderWidth) /
+ font_height;
+
+ if (button_no == 1 &&
+ (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
+ {
+ _selection_extend(MOUSE_X_POS, MOUSE_Y_POS);
+ send_key = FALSE;
+ }
+ else
+ _selection_off();
+
+ /* Throw away mouse movements if they are in the same character
+ position as the last mouse event, or if we are currently in
+ the middle of a double click event. */
+
+ if ((MOUSE_X_POS == save_mouse_status.x &&
+ MOUSE_Y_POS == save_mouse_status.y) ||
+ save_mouse_status.button[button_no - 1] == BUTTON_DOUBLE_CLICKED)
+ {
+ send_key = FALSE;
+ break;
+ }
+
+ Mouse_status.changes |= PDC_MOUSE_MOVED;
+ break;
+
+ case ButtonRelease:
+ if (remove_release)
+ {
+ MOUSE_LOG(("Release at: %ld - removed\n", event->xbutton.time));
+ return;
+ }
+ else
+ {
+ MOUSE_X_POS = (event->xbutton.x - xc_app_data.borderWidth) /
+ font_width;
+ MOUSE_Y_POS = (event->xbutton.y - xc_app_data.borderWidth) /
+ font_height;
+
+ if (!handle_real_release)
+ {
+ if ((event->xbutton.time - last_button_press_time) <
+ SP->mouse_wait &&
+ (event->xbutton.time != last_button_press_time))
+ {
+ /* The "real" release was shorter than usleep() time;
+ therefore generate a click event */
+
+ MOUSE_LOG(("Release at: %ld - click\n",
+ event->xbutton.time));
+
+ BUTTON_STATUS(button_no) = BUTTON_CLICKED;
+
+ if (button_no == 1 && mouse_selection &&
+ (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
+ {
+ send_key = FALSE;
+
+ if (XtOwnSelection(topLevel, XA_PRIMARY,
+ event->xbutton.time, _convert_proc,
+ _lose_ownership, NULL) == False)
+ _selection_off();
+ }
+ else
+ _selection_off();
+
+ /* Ensure the "pseudo" release event is ignored */
+
+ remove_release = True;
+ handle_real_release = False;
+ break;
+ }
+ else
+ {
+ /* Button release longer than usleep() time;
+ therefore generate a press and wait for the real
+ release to occur later. */
+
+ MOUSE_LOG(("Generated Release at: %ld - "
+ "press & release\n", event->xbutton.time));
+
+ BUTTON_STATUS(button_no) = BUTTON_PRESSED;
+
+ if (button_no == 1 &&
+ (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
+ {
+ _selection_off();
+ _selection_on(MOUSE_X_POS, MOUSE_Y_POS);
+ }
+
+ handle_real_release = True;
+ break;
+ }
+ }
+ else
+ {
+ MOUSE_LOG(("Release at: %ld - released\n",
+ event->xbutton.time));
+ }
+ }
+
+ MOUSE_LOG(("\nButtonRelease\n"));
+
+ BUTTON_STATUS(button_no) = BUTTON_RELEASED;
+
+ if (button_no == 1 && mouse_selection &&
+ (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
+ {
+ send_key = FALSE;
+
+ if (XtOwnSelection(topLevel, XA_PRIMARY,
+ event->xbutton.time, _convert_proc,
+ _lose_ownership, NULL) == False)
+ _selection_off();
+
+ _selection_set();
+ }
+ else
+ _selection_off();
+
+ break;
+ }
+
+ /* Set up the mouse status fields in preparation for sending */
+
+ Mouse_status.changes |= 1 << (button_no - 1);
+
+ if (Mouse_status.changes & PDC_MOUSE_MOVED &&
+ BUTTON_STATUS(button_no) == BUTTON_PRESSED)
+ BUTTON_STATUS(button_no) = BUTTON_MOVED;
+
+ if (event->xbutton.state & ShiftMask)
+ BUTTON_STATUS(button_no) |= BUTTON_SHIFT;
+ if (event->xbutton.state & ControlMask)
+ BUTTON_STATUS(button_no) |= BUTTON_CONTROL;
+ if (event->xbutton.state & Mod1Mask)
+ BUTTON_STATUS(button_no) |= BUTTON_ALT;
+
+ /* If we are ignoring the event, or the mouse position is outside
+ the bounds of the screen (because of the border), return here */
+
+ MOUSE_LOG(("Button: %d x: %d y: %d Button status: %x "
+ "Mouse status: %x\n", button_no, MOUSE_X_POS, MOUSE_Y_POS,
+ BUTTON_STATUS(button_no), Mouse_status.changes));
+
+ MOUSE_LOG(("Send: %d Button1: %x Button2: %x Button3: %x %d %d\n",
+ send_key, BUTTON_STATUS(1), BUTTON_STATUS(2),
+ BUTTON_STATUS(3), XCursesLINES, XCursesCOLS));
+
+ if (!send_key || MOUSE_X_POS < 0 || MOUSE_X_POS >= XCursesCOLS ||
+ MOUSE_Y_POS < 0 || MOUSE_Y_POS >= XCursesLINES)
+ return;
+
+ /* Send the KEY_MOUSE to curses program */
+
+ _send_key_to_curses(KEY_MOUSE, &Mouse_status, TRUE);
+}
+
+static void _scroll_up_down(Widget w, XtPointer client_data,
+ XtPointer call_data)
+{
+ int pixels = (long) call_data;
+ int total_y = SP->sb_total_y * font_height;
+ int viewport_y = SP->sb_viewport_y * font_height;
+ int cur_y = SP->sb_cur_y * font_height;
+
+ /* When pixels is negative, right button pressed, move data down,
+ thumb moves up. Otherwise, left button pressed, pixels positive,
+ move data up, thumb down. */
+
+ cur_y += pixels;
+
+ /* limit panning to size of overall */
+
+ if (cur_y < 0)
+ cur_y = 0;
+ else
+ if (cur_y > (total_y - viewport_y))
+ cur_y = total_y - viewport_y;
+
+ SP->sb_cur_y = cur_y / font_height;
+
+ XawScrollbarSetThumb(w, (double)((double)cur_y / (double)total_y),
+ (double)((double)viewport_y / (double)total_y));
+
+ /* Send a key: if pixels negative, send KEY_SCROLL_DOWN */
+
+ _send_key_to_curses(KEY_SF, NULL, TRUE);
+}
+
+static void _scroll_left_right(Widget w, XtPointer client_data,
+ XtPointer call_data)
+{
+ int pixels = (long) call_data;
+ int total_x = SP->sb_total_x * font_width;
+ int viewport_x = SP->sb_viewport_x * font_width;
+ int cur_x = SP->sb_cur_x * font_width;
+
+ cur_x += pixels;
+
+ /* limit panning to size of overall */
+
+ if (cur_x < 0)
+ cur_x = 0;
+ else
+ if (cur_x > (total_x - viewport_x))
+ cur_x = total_x - viewport_x;
+
+ SP->sb_cur_x = cur_x / font_width;
+
+ XawScrollbarSetThumb(w, (double)((double)cur_x / (double)total_x),
+ (double)((double)viewport_x / (double)total_x));
+
+ _send_key_to_curses(KEY_SR, NULL, TRUE);
+}
+
+static void _thumb_up_down(Widget w, XtPointer client_data,
+ XtPointer call_data)
+{
+ double percent = *(double *) call_data;
+ double total_y = (double)SP->sb_total_y;
+ double viewport_y = (double)SP->sb_viewport_y;
+ int cur_y = SP->sb_cur_y;
+
+ /* If the size of the viewport is > overall area simply return,
+ as no scrolling is permitted. */
+
+ if (SP->sb_viewport_y >= SP->sb_total_y)
+ return;
+
+ if ((SP->sb_cur_y = (int)((double)total_y * percent)) >=
+ (total_y - viewport_y))
+ SP->sb_cur_y = total_y - viewport_y;
+
+ XawScrollbarSetThumb(w, (double)(cur_y / total_y),
+ (double)(viewport_y / total_y));
+
+ _send_key_to_curses(KEY_SF, NULL, TRUE);
+}
+
+static void _thumb_left_right(Widget w, XtPointer client_data,
+ XtPointer call_data)
+{
+ double percent = *(double *) call_data;
+ double total_x = (double)SP->sb_total_x;
+ double viewport_x = (double)SP->sb_viewport_x;
+ int cur_x = SP->sb_cur_x;
+
+ if (SP->sb_viewport_x >= SP->sb_total_x)
+ return;
+
+ if ((SP->sb_cur_x = (int)((float)total_x * percent)) >=
+ (total_x - viewport_x))
+ SP->sb_cur_x = total_x - viewport_x;
+
+ XawScrollbarSetThumb(w, (double)(cur_x / total_x),
+ (double)(viewport_x / total_x));
+
+ _send_key_to_curses(KEY_SR, NULL, TRUE);
+}
+
+static void _exit_process(int rc, int sig, char *msg)
+{
+ if (rc || sig)
+ fprintf(stderr, "%s:_exit_process() - called: rc:%d sig:%d <%s>\n",
+ XCLOGMSG, rc, sig, msg);
+
+ shmdt((char *)SP);
+ shmdt((char *)Xcurscr);
+ shmctl(shmidSP, IPC_RMID, 0);
+ shmctl(shmid_Xcurscr, IPC_RMID, 0);
+
+ if (bitmap_file)
+ {
+ XFreePixmap(XCURSESDISPLAY, icon_bitmap);
+ free(bitmap_file);
+ }
+
+#ifdef HAVE_XPM_H
+ if (pixmap_file)
+ {
+ XFreePixmap(XCURSESDISPLAY, icon_pixmap);
+ XFreePixmap(XCURSESDISPLAY, icon_pixmap_mask);
+ free(pixmap_file);
+ }
+#endif
+ XFreeGC(XCURSESDISPLAY, normal_gc);
+ XFreeGC(XCURSESDISPLAY, italic_gc);
+ XFreeGC(XCURSESDISPLAY, block_cursor_gc);
+ XFreeGC(XCURSESDISPLAY, rect_cursor_gc);
+ XFreeGC(XCURSESDISPLAY, border_gc);
+#ifdef PDC_XIM
+ XDestroyIC(Xic);
+#endif
+
+ shutdown(xc_display_sock, 2);
+ close(xc_display_sock);
+
+ shutdown(xc_exit_sock, 2);
+ close(xc_exit_sock);
+
+ shutdown(xc_key_sock, 2);
+ close(xc_key_sock);
+
+ if (sig)
+ kill(xc_otherpid, sig); /* to kill parent process */
+
+ _exit(rc);
+}
+
+static void _resize(void)
+{
+ short save_atrtab[PDC_COLOR_PAIRS * 2];
+
+ after_first_curses_request = FALSE;
+
+ SP->lines = XCursesLINES = ((resize_window_height -
+ (2 * xc_app_data.borderWidth)) / font_height);
+
+ LINES = XCursesLINES - SP->linesrippedoff - SP->slklines;
+
+ SP->cols = COLS = XCursesCOLS = ((resize_window_width -
+ (2 * xc_app_data.borderWidth)) / font_width);
+
+ window_width = resize_window_width;
+ window_height = resize_window_height;
+ visible_cursor = TRUE;
+
+ _draw_border();
+
+ /* Detach and drop the current shared memory segment and create and
+ attach to a new segment */
+
+ memcpy(save_atrtab, xc_atrtab, sizeof(save_atrtab));
+
+ SP->XcurscrSize = XCURSCR_SIZE;
+ shmdt((char *)Xcurscr);
+ shmctl(shmid_Xcurscr, IPC_RMID, 0);
+
+ if ((shmid_Xcurscr = shmget(shmkey_Xcurscr,
+ SP->XcurscrSize + XCURSESSHMMIN, 0700 | IPC_CREAT)) < 0)
+ {
+ perror("Cannot allocate shared memory for curscr");
+
+ _exit_process(4, SIGKILL, "exiting from _process_curses_requests");
+ }
+
+ Xcurscr = (unsigned char*)shmat(shmid_Xcurscr, 0, 0);
+ memset(Xcurscr, 0, SP->XcurscrSize);
+ xc_atrtab = (short *)(Xcurscr + XCURSCR_ATRTAB_OFF);
+ memcpy(xc_atrtab, save_atrtab, sizeof(save_atrtab));
+}
+
+/* For PDC_set_title() */
+
+static void _set_title(void)
+{
+ char title[1024]; /* big enough for window title */
+ int pos;
+
+ if ((XC_read_socket(xc_display_sock, &pos, sizeof(int)) < 0) ||
+ (XC_read_socket(xc_display_sock, title, pos) < 0))
+ {
+ _exit_process(5, SIGKILL, "exiting from _set_title");
+ }
+
+ XtVaSetValues(topLevel, XtNtitle, title, NULL);
+}
+
+/* For color_content() */
+
+static void _get_color(void)
+{
+ XColor *tmp = (XColor *)(Xcurscr + XCURSCR_XCOLOR_OFF);
+ int index = tmp->pixel;
+ Colormap cmap = DefaultColormap(XCURSESDISPLAY,
+ DefaultScreen(XCURSESDISPLAY));
+
+ if (index < 0 || index >= MAX_COLORS)
+ _exit_process(4, SIGKILL, "exiting from _get_color");
+
+ tmp->pixel = colors[index];
+ XQueryColor(XCURSESDISPLAY, cmap, tmp);
+}
+
+/* For init_color() */
+
+static void _set_color(void)
+{
+ XColor *tmp = (XColor *)(Xcurscr + XCURSCR_XCOLOR_OFF);
+ int index = tmp->pixel;
+ Colormap cmap = DefaultColormap(XCURSESDISPLAY,
+ DefaultScreen(XCURSESDISPLAY));
+
+ if (index < 0 || index >= MAX_COLORS)
+ _exit_process(4, SIGKILL, "exiting from _set_color");
+
+ if (XAllocColor(XCURSESDISPLAY, cmap, tmp))
+ {
+ XFreeColors(XCURSESDISPLAY, cmap, colors + index, 1, 0);
+ colors[index] = tmp->pixel;
+
+ _display_screen();
+ }
+}
+
+/* For PDC_getclipboard() */
+
+static void _get_selection(Widget w, XtPointer data, Atom *selection,
+ Atom *type, XtPointer value,
+ unsigned long *length, int *format)
+{
+ unsigned char *src = value;
+ int pos, len = *length;
+
+ XC_LOG(("_get_selection() - called\n"));
+
+ if (!value && !len)
+ {
+ if (XC_write_display_socket_int(PDC_CLIP_EMPTY) < 0)
+ _exit_process(4, SIGKILL, "exiting from _get_selection");
+ }
+ else
+ {
+ /* Here all is OK, send PDC_CLIP_SUCCESS, then length, then
+ contents */
+
+ if (XC_write_display_socket_int(PDC_CLIP_SUCCESS) < 0)
+ _exit_process(4, SIGKILL, "exiting from _get_selection");
+
+ if (XC_write_display_socket_int(len) < 0)
+ _exit_process(4, SIGKILL, "exiting from _get_selection");
+
+ for (pos = 0; pos < len; pos++)
+ {
+#ifdef PDC_WIDE
+ wchar_t c;
+#else
+ unsigned char c;
+#endif
+ c = *src++;
+
+ if (XC_write_socket(xc_display_sock, &c, sizeof(c)) < 0)
+ _exit_process(4, SIGKILL, "exiting from _get_selection");
+ }
+ }
+}
+
+#ifdef PDC_WIDE
+static void _get_selection_utf8(Widget w, XtPointer data, Atom *selection,
+ Atom *type, XtPointer value,
+ unsigned long *length, int *format)
+{
+ int len = *length;
+
+ XC_LOG(("_get_selection_utf8() - called\n"));
+
+ if (!*type || !*length)
+ {
+ XtGetSelectionValue(w, XA_PRIMARY, XA_STRING, _get_selection,
+ (XtPointer)NULL, 0);
+ return;
+ }
+
+ if (!value && !len)
+ {
+ if (XC_write_display_socket_int(PDC_CLIP_EMPTY) >= 0)
+ return;
+ }
+ else
+ {
+ wchar_t *wcontents = malloc((len + 1) * sizeof(wchar_t));
+ char *src = value;
+ int i = 0;
+
+ while (*src && i < (*length))
+ {
+ int retval = _from_utf8(wcontents + i, src, len);
+
+ src += retval;
+ len -= retval;
+ i++;
+ }
+
+ wcontents[i] = 0;
+ len = i;
+
+ /* Here all is OK, send PDC_CLIP_SUCCESS, then length, then
+ contents */
+
+ if (XC_write_display_socket_int(PDC_CLIP_SUCCESS) >= 0)
+ if (XC_write_display_socket_int(len) >= 0)
+ if (XC_write_socket(xc_display_sock,
+ wcontents, len * sizeof(wchar_t)) >= 0)
+ {
+ free(wcontents);
+ return;
+ }
+ }
+
+ _exit_process(4, SIGKILL, "exiting from _get_selection_utf8");
+}
+#endif
+
+/* For PDC_setclipboard() */
+
+static void _set_selection(void)
+{
+ long length, pos;
+ int status;
+
+ if (XC_read_socket(xc_display_sock, &length, sizeof(long)) < 0)
+ _exit_process(5, SIGKILL, "exiting from _set_selection");
+
+ if (length > (long)tmpsel_length)
+ {
+ if (!tmpsel_length)
+ tmpsel = malloc((length + 1) * sizeof(chtype));
+ else
+ tmpsel = realloc(tmpsel, (length + 1) * sizeof(chtype));
+ }
+
+ if (!tmpsel)
+ if (XC_write_display_socket_int(PDC_CLIP_MEMORY_ERROR) < 0)
+ _exit_process(4, SIGKILL, "exiting from _set_selection");
+
+ for (pos = 0; pos < length; pos++)
+ {
+#ifdef PDC_WIDE
+ wchar_t c;
+#else
+ unsigned char c;
+#endif
+ if (XC_read_socket(xc_display_sock, &c, sizeof(c)) < 0)
+ _exit_process(5, SIGKILL, "exiting from _set_selection");
+
+ tmpsel[pos] = c;
+ }
+
+ tmpsel_length = length;
+ tmpsel[length] = 0;
+
+ if (XtOwnSelection(topLevel, XA_PRIMARY, CurrentTime,
+ _convert_proc, _lose_ownership, NULL) == False)
+ {
+ status = PDC_CLIP_ACCESS_ERROR;
+ free(tmpsel);
+ tmpsel = NULL;
+ tmpsel_length = 0;
+ }
+ else
+ status = PDC_CLIP_SUCCESS;
+
+ _selection_off();
+
+ if (XC_write_display_socket_int(status) < 0)
+ _exit_process(4, SIGKILL, "exiting from _set_selection");
+}
+
+/* The curses process is waiting; tell it to continue */
+
+static void _resume_curses(void)
+{
+ if (XC_write_display_socket_int(CURSES_CONTINUE) < 0)
+ _exit_process(4, SIGKILL, "exiting from _process_curses_requests");
+}
+
+/* The curses process sent us a message */
+
+static void _process_curses_requests(XtPointer client_data, int *fid,
+ XtInputId *id)
+{
+ struct timeval socket_timeout = {0};
+ int s;
+ int old_row, new_row;
+ int old_x, new_x;
+ int pos, num_cols;
+
+ char buf[12]; /* big enough for 2 integers */
+
+ XC_LOG(("_process_curses_requests() - called\n"));
+
+ if (!received_map_notify)
+ return;
+
+ FD_ZERO(&xc_readfds);
+ FD_SET(xc_display_sock, &xc_readfds);
+
+ if ((s = select(FD_SETSIZE, (FD_SET_CAST)&xc_readfds, NULL,
+ NULL, &socket_timeout)) < 0)
+ _exit_process(2, SIGKILL, "exiting from _process_curses_requests"
+ " - select failed");
+
+ if (!s) /* no requests pending - should never happen! */
+ return;
+
+ if (FD_ISSET(xc_display_sock, &xc_readfds))
+ {
+ /* read first integer to determine total message has been
+ received */
+
+ XC_LOG(("_process_curses_requests() - before XC_read_socket()\n"));
+
+ if (XC_read_socket(xc_display_sock, &num_cols, sizeof(int)) < 0)
+ _exit_process(3, SIGKILL, "exiting from _process_curses_requests"
+ " - first read");
+
+ XC_LOG(("_process_curses_requests() - after XC_read_socket()\n"));
+
+ after_first_curses_request = TRUE;
+
+ switch(num_cols)
+ {
+ case CURSES_EXIT: /* request from curses to stop */
+ XC_LOG(("CURSES_EXIT received from child\n"));
+ _exit_process(0, 0, "XCursesProcess requested to exit by child");
+ break;
+
+ case CURSES_BELL:
+ XC_LOG(("CURSES_BELL received from child\n"));
+ XBell(XCURSESDISPLAY, 50);
+ break;
+
+ /* request from curses to confirm completion of display */
+
+ case CURSES_REFRESH:
+ XC_LOG(("CURSES_REFRESH received from child\n"));
+ _refresh_screen();
+ _resume_curses();
+ break;
+
+ case CURSES_REFRESH_SCROLLBAR:
+ _refresh_scrollbar();
+ break;
+
+ case CURSES_CURSOR:
+ XC_LOG(("CURSES_CURSOR received from child\n"));
+
+ if (XC_read_socket(xc_display_sock, buf, sizeof(int) * 2) < 0)
+ _exit_process(5, SIGKILL, "exiting from CURSES_CURSOR "
+ "_process_curses_requests");
+
+ memcpy(&pos, buf, sizeof(int));
+ old_row = pos & 0xFF;
+ old_x = pos >> 8;
+
+ memcpy(&pos, buf + sizeof(int), sizeof(int));
+ new_row = pos & 0xFF;
+ new_x = pos >> 8;
+
+ visible_cursor = TRUE;
+ _display_cursor(old_row, old_x, new_row, new_x);
+ break;
+
+ case CURSES_DISPLAY_CURSOR:
+ XC_LOG(("CURSES_DISPLAY_CURSOR received from child. Vis now: "));
+ XC_LOG((visible_cursor ? "1\n" : "0\n"));
+
+ /* If the window is not active, ignore this command. The
+ cursor will stay solid. */
+
+ if (window_entered)
+ {
+ if (visible_cursor)
+ {
+ /* Cursor currently ON, turn it off */
+
+ int save_visibility = SP->visibility;
+ SP->visibility = 0;
+ _redraw_cursor();
+ SP->visibility = save_visibility;
+ visible_cursor = FALSE;
+ }
+ else
+ {
+ /* Cursor currently OFF, turn it on */
+
+ _redraw_cursor();
+ visible_cursor = TRUE;
+ }
+ }
+
+ break;
+
+ case CURSES_TITLE:
+ XC_LOG(("CURSES_TITLE received from child\n"));
+ _set_title();
+ break;
+
+ case CURSES_RESIZE:
+ XC_LOG(("CURSES_RESIZE received from child\n"));
+ _resize();
+ _resume_curses();
+ break;
+
+ case CURSES_GET_SELECTION:
+ XC_LOG(("CURSES_GET_SELECTION received from child\n"));
+
+ _resume_curses();
+
+ XtGetSelectionValue(topLevel, XA_PRIMARY,
+#ifdef PDC_WIDE
+ XA_UTF8_STRING(XtDisplay(topLevel)),
+ _get_selection_utf8,
+#else
+ XA_STRING, _get_selection,
+#endif
+ (XtPointer)NULL, 0);
+
+ break;
+
+ case CURSES_SET_SELECTION:
+ XC_LOG(("CURSES_SET_SELECTION received from child\n"));
+ _set_selection();
+ break;
+
+ case CURSES_CLEAR_SELECTION:
+ XC_LOG(("CURSES_CLEAR_SELECTION received from child\n"));
+ _resume_curses();
+ _selection_off();
+ break;
+
+ case CURSES_GET_COLOR:
+ XC_LOG(("CURSES_GET_COLOR recieved from child\n"));
+ _get_color();
+ _resume_curses();
+ break;
+
+ case CURSES_SET_COLOR:
+ XC_LOG(("CURSES_SET_COLOR recieved from child\n"));
+ _set_color();
+ _resume_curses();
+ break;
+
+ default:
+ PDC_LOG(("%s:Unknown request %d\n", XCLOGMSG, num_cols));
+ }
+ }
+}
+
+static void _handle_structure_notify(Widget w, XtPointer client_data,
+ XEvent *event, Boolean *unused)
+{
+ XC_LOG(("_handle_structure_notify() - called\n"));
+
+ switch(event->type)
+ {
+ case ConfigureNotify:
+ XC_LOG(("ConfigureNotify received\n"));
+
+ /* Window has been resized, change width and height to send to
+ place_text and place_graphics in next Expose. Also will need
+ to kill (SIGWINCH) curses process if screen size changes. */
+
+ resize_window_width = event->xconfigure.width;
+ resize_window_height = event->xconfigure.height;
+
+ after_first_curses_request = FALSE;
+
+#ifdef SIGWINCH
+ SP->resized = 1;
+
+ kill(xc_otherpid, SIGWINCH);
+#endif
+ _send_key_to_curses(KEY_RESIZE, NULL, TRUE);
+ break;
+
+ case MapNotify:
+ XC_LOG(("MapNotify received\n"));
+
+ received_map_notify = 1;
+
+ _draw_border();
+ break;
+
+ default:
+ PDC_LOG(("%s:_handle_structure_notify - unknown event %d\n",
+ XCLOGMSG, event->type));
+ }
+}
+
+static RETSIGTYPE _handle_signals(int signo)
+{
+ int flag = CURSES_EXIT;
+
+ PDC_LOG(("%s:_handle_signals() - called: %d\n", XCLOGMSG, signo));
+
+ /* Patch by: Georg Fuchs */
+
+ XCursesSetSignal(signo, _handle_signals);
+
+#ifdef SIGTSTP
+ if (signo == SIGTSTP)
+ {
+ pause();
+ return;
+ }
+#endif
+#ifdef SIGCONT
+ if (signo == SIGCONT)
+ return;
+#endif
+#ifdef SIGCLD
+ if (signo == SIGCLD)
+ return;
+#endif
+#ifdef SIGTTIN
+ if (signo == SIGTTIN)
+ return;
+#endif
+#ifdef SIGWINCH
+ if (signo == SIGWINCH)
+ return;
+#endif
+
+ /* End of patch by: Georg Fuchs */
+
+ XCursesSetSignal(signo, SIG_IGN);
+
+ /* Send a CURSES_EXIT to myself */
+
+ if (XC_write_socket(xc_exit_sock, &flag, sizeof(int)) < 0)
+ _exit_process(7, signo, "exiting from _handle_signals");
+}
+
+#ifdef PDC_XIM
+static void _dummy_handler(Widget w, XtPointer client_data,
+ XEvent *event, Boolean *unused)
+{
+}
+#endif
+
+int XCursesSetupX(int argc, char *argv[])
+{
+ char *myargv[] = {"PDCurses", NULL};
+ extern bool sb_started;
+
+ int italic_font_valid;
+ XColor pointerforecolor, pointerbackcolor;
+ XrmValue rmfrom, rmto;
+ int i = 0;
+ int minwidth, minheight;
+
+ XC_LOG(("XCursesSetupX called\n"));
+
+ if (!argv)
+ {
+ argv = myargv;
+ argc = 1;
+ }
+
+ program_name = argv[0];
+
+ /* Keep open the 'write' end of the socket so the XCurses process
+ can send a CURSES_EXIT to itself from within the signal handler */
+
+ xc_exit_sock = xc_display_sockets[0];
+ xc_display_sock = xc_display_sockets[1];
+
+ close(xc_key_sockets[0]);
+ xc_key_sock = xc_key_sockets[1];
+
+ /* Trap all signals when XCurses is the child process, but only if
+ they haven't already been ignored by the application. */
+
+ for (i = 0; i < PDC_MAX_SIGNALS; i++)
+ if (XCursesSetSignal(i, _handle_signals) == SIG_IGN)
+ XCursesSetSignal(i, SIG_IGN);
+
+ /* Start defining X Toolkit things */
+
+#if XtSpecificationRelease > 4
+ XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL);
+#endif
+
+ /* Exit if no DISPLAY variable set */
+
+ if (!getenv("DISPLAY"))
+ {
+ fprintf(stderr, "Error: no DISPLAY variable set\n");
+ kill(xc_otherpid, SIGKILL);
+ return ERR;
+ }
+
+ /* Initialise the top level widget */
+
+ topLevel = XtVaAppInitialize(&app_context, class_name, options,
+ XtNumber(options), &argc, argv, NULL, NULL);
+
+ XtVaGetApplicationResources(topLevel, &xc_app_data, app_resources,
+ XtNumber(app_resources), NULL);
+
+ /* Check application resource values here */
+
+ font_width = xc_app_data.normalFont->max_bounds.rbearing -
+ xc_app_data.normalFont->min_bounds.lbearing;
+
+ font_height = xc_app_data.normalFont->max_bounds.ascent +
+ xc_app_data.normalFont->max_bounds.descent;
+
+ font_ascent = xc_app_data.normalFont->max_bounds.ascent;
+ font_descent = xc_app_data.normalFont->max_bounds.descent;
+
+ /* Check that the italic font and normal fonts are the same size */
+ /* This appears backwards */
+
+ italic_font_valid = font_width !=
+ xc_app_data.italicFont->max_bounds.rbearing -
+ xc_app_data.italicFont->min_bounds.lbearing ||
+ font_height !=
+ xc_app_data.italicFont->max_bounds.ascent +
+ xc_app_data.italicFont->max_bounds.descent;
+
+ /* Calculate size of display window */
+
+ XCursesCOLS = xc_app_data.cols;
+ XCursesLINES = xc_app_data.lines;
+
+ window_width = font_width * XCursesCOLS +
+ 2 * xc_app_data.borderWidth;
+
+ window_height = font_height * XCursesLINES +
+ 2 * xc_app_data.borderWidth;
+
+ minwidth = font_width * 2 + xc_app_data.borderWidth * 2;
+ minheight = font_height * 2 + xc_app_data.borderWidth * 2;
+
+ /* Set up the icon for the application; the default is an internal
+ one for PDCurses. Then set various application level resources. */
+
+ _get_icon();
+
+#ifdef HAVE_XPM_H
+ if (xc_app_data.pixmap && xc_app_data.pixmap[0])
+ XtVaSetValues(topLevel, XtNminWidth, minwidth, XtNminHeight,
+ minheight, XtNbaseWidth, xc_app_data.borderWidth * 2,
+ XtNbaseHeight, xc_app_data.borderWidth * 2,
+ XtNiconPixmap, icon_pixmap,
+ XtNiconMask, icon_pixmap_mask, NULL);
+ else
+#endif
+ XtVaSetValues(topLevel, XtNminWidth, minwidth, XtNminHeight,
+ minheight, XtNbaseWidth, xc_app_data.borderWidth * 2,
+ XtNbaseHeight, xc_app_data.borderWidth * 2,
+ XtNiconPixmap, icon_bitmap, NULL);
+
+ /* Create a BOX widget in which to draw */
+
+ if (xc_app_data.scrollbarWidth && sb_started)
+ {
+ scrollBox = XtVaCreateManagedWidget(program_name,
+ scrollBoxWidgetClass, topLevel, XtNwidth,
+ window_width + xc_app_data.scrollbarWidth,
+ XtNheight, window_height + xc_app_data.scrollbarWidth,
+ XtNwidthInc, font_width, XtNheightInc, font_height, NULL);
+
+ drawing = XtVaCreateManagedWidget(program_name,
+ boxWidgetClass, scrollBox, XtNwidth,
+ window_width, XtNheight, window_height, XtNwidthInc,
+ font_width, XtNheightInc, font_height, NULL);
+
+ scrollVert = XtVaCreateManagedWidget("scrollVert",
+ scrollbarWidgetClass, scrollBox, XtNorientation,
+ XtorientVertical, XtNheight, window_height, XtNwidth,
+ xc_app_data.scrollbarWidth, NULL);
+
+ XtAddCallback(scrollVert, XtNscrollProc, _scroll_up_down, drawing);
+ XtAddCallback(scrollVert, XtNjumpProc, _thumb_up_down, drawing);
+
+ scrollHoriz = XtVaCreateManagedWidget("scrollHoriz",
+ scrollbarWidgetClass, scrollBox, XtNorientation,
+ XtorientHorizontal, XtNwidth, window_width, XtNheight,
+ xc_app_data.scrollbarWidth, NULL);
+
+ XtAddCallback(scrollHoriz, XtNscrollProc, _scroll_left_right, drawing);
+ XtAddCallback(scrollHoriz, XtNjumpProc, _thumb_left_right, drawing);
+ }
+ else
+ {
+ drawing = XtVaCreateManagedWidget(program_name, boxWidgetClass,
+ topLevel, XtNwidth, window_width, XtNheight, window_height,
+ XtNwidthInc, font_width, XtNheightInc, font_height, NULL);
+
+ XtVaSetValues(topLevel, XtNwidthInc, font_width, XtNheightInc,
+ font_height, NULL);
+ }
+
+ /* Process any default translations */
+
+ XtAugmentTranslations(drawing,
+ XtParseTranslationTable(default_translations));
+ XtAppAddActions(app_context, action_table, XtNumber(action_table));
+
+ /* Process the supplied colors */
+
+ _initialize_colors();
+
+ /* Determine text cursor alignment from resources */
+
+ if (!strcmp(xc_app_data.textCursor, "vertical"))
+ vertical_cursor = TRUE;
+
+ /* Now have LINES and COLS. Set these in the shared SP so the curses
+ program can find them. */
+
+ LINES = XCursesLINES;
+ COLS = XCursesCOLS;
+
+ if ((shmidSP = shmget(shmkeySP, sizeof(SCREEN) + XCURSESSHMMIN,
+ 0700 | IPC_CREAT)) < 0)
+ {
+ perror("Cannot allocate shared memory for SCREEN");
+ kill(xc_otherpid, SIGKILL);
+ return ERR;
+ }
+
+ SP = (SCREEN*)shmat(shmidSP, 0, 0);
+ memset(SP, 0, sizeof(SCREEN));
+ SP->XcurscrSize = XCURSCR_SIZE;
+ SP->lines = XCursesLINES;
+ SP->cols = XCursesCOLS;
+
+ SP->mouse_wait = xc_app_data.clickPeriod;
+ SP->audible = TRUE;
+
+ PDC_LOG(("%s:SHM size for curscr %d\n", XCLOGMSG, SP->XcurscrSize));
+
+ if ((shmid_Xcurscr = shmget(shmkey_Xcurscr, SP->XcurscrSize +
+ XCURSESSHMMIN, 0700 | IPC_CREAT)) < 0)
+ {
+ perror("Cannot allocate shared memory for curscr");
+ kill(xc_otherpid, SIGKILL);
+ shmdt((char *)SP);
+ shmctl(shmidSP, IPC_RMID, 0);
+ return ERR;
+ }
+
+ Xcurscr = (unsigned char *)shmat(shmid_Xcurscr, 0, 0);
+ memset(Xcurscr, 0, SP->XcurscrSize);
+ xc_atrtab = (short *)(Xcurscr + XCURSCR_ATRTAB_OFF);
+
+ PDC_LOG(("%s:shmid_Xcurscr %d shmkey_Xcurscr %d LINES %d COLS %d\n",
+ XCLOGMSG, shmid_Xcurscr, shmkey_Xcurscr, LINES, COLS));
+
+ /* Add Event handlers to the drawing widget */
+
+ XtAddEventHandler(drawing, ExposureMask, False, _handle_expose, NULL);
+ XtAddEventHandler(drawing, StructureNotifyMask, False,
+ _handle_structure_notify, NULL);
+ XtAddEventHandler(drawing, EnterWindowMask | LeaveWindowMask, False,
+ _handle_enter_leave, NULL);
+ XtAddEventHandler(topLevel, 0, True, _handle_nonmaskable, NULL);
+
+ /* Add input handler from xc_display_sock (requests from curses
+ program) */
+
+ XtAppAddInput(app_context, xc_display_sock, (XtPointer)XtInputReadMask,
+ _process_curses_requests, NULL);
+
+ /* If there is a cursorBlink resource, start the Timeout event */
+
+ if (xc_app_data.cursorBlinkRate)
+ XtAppAddTimeOut(app_context, xc_app_data.cursorBlinkRate,
+ _blink_cursor, NULL);
+
+ /* Leave telling the curses process that it can start to here so
+ that when the curses process makes a request, the Xcurses
+ process can service the request. */
+
+ XC_write_display_socket_int(CURSES_CHILD);
+
+ XtRealizeWidget(topLevel);
+
+ /* Handle trapping of the WM_DELETE_WINDOW property */
+
+ wm_atom[0] = XInternAtom(XtDisplay(topLevel), "WM_DELETE_WINDOW", False);
+
+ XSetWMProtocols(XtDisplay(topLevel), XtWindow(topLevel), wm_atom, 1);
+
+ /* Create the Graphics Context for drawing. This MUST be done AFTER
+ the associated widget has been realized. */
+
+ XC_LOG(("before _get_gc\n"));
+
+ _get_gc(&normal_gc, xc_app_data.normalFont, COLOR_WHITE, COLOR_BLACK);
+
+ _get_gc(&italic_gc, italic_font_valid ? xc_app_data.italicFont :
+ xc_app_data.normalFont, COLOR_WHITE, COLOR_BLACK);
+
+ _get_gc(&block_cursor_gc, xc_app_data.normalFont,
+ COLOR_BLACK, COLOR_CURSOR);
+
+ _get_gc(&rect_cursor_gc, xc_app_data.normalFont,
+ COLOR_CURSOR, COLOR_BLACK);
+
+ _get_gc(&border_gc, xc_app_data.normalFont, COLOR_BORDER, COLOR_BLACK);
+
+ XSetLineAttributes(XCURSESDISPLAY, rect_cursor_gc, 2,
+ LineSolid, CapButt, JoinMiter);
+
+ XSetLineAttributes(XCURSESDISPLAY, border_gc, xc_app_data.borderWidth,
+ LineSolid, CapButt, JoinMiter);
+
+ /* Set the cursor for the application */
+
+ XDefineCursor(XCURSESDISPLAY, XCURSESWIN, xc_app_data.pointer);
+ rmfrom.size = sizeof(Pixel);
+ rmto.size = sizeof(XColor);
+
+ rmto.addr = (XPointer)&pointerforecolor;
+ rmfrom.addr = (XPointer)&(xc_app_data.pointerForeColor);
+ XtConvertAndStore(drawing, XtRPixel, &rmfrom, XtRColor, &rmto);
+
+ rmfrom.size = sizeof(Pixel);
+ rmto.size = sizeof(XColor);
+
+ rmfrom.addr = (XPointer)&(xc_app_data.pointerBackColor);
+ rmto.addr = (XPointer)&pointerbackcolor;
+ XtConvertAndStore(drawing, XtRPixel, &rmfrom, XtRColor, &rmto);
+
+ XRecolorCursor(XCURSESDISPLAY, xc_app_data.pointer,
+ &pointerforecolor, &pointerbackcolor);
+
+#ifndef PDC_XIM
+
+ /* Convert the supplied compose key to a Keysym */
+
+ compose_key = XStringToKeysym(xc_app_data.composeKey);
+
+ if (compose_key && IsModifierKey(compose_key))
+ {
+ int i, j;
+ KeyCode *kcp;
+ XModifierKeymap *map;
+ KeyCode compose_keycode = XKeysymToKeycode(XCURSESDISPLAY, compose_key);
+
+ map = XGetModifierMapping(XCURSESDISPLAY);
+ kcp = map->modifiermap;
+
+ for (i = 0; i < 8; i++)
+ {
+ for (j = 0; j < map->max_keypermod; j++, kcp++)
+ {
+ if (!*kcp)
+ continue;
+
+ if (compose_keycode == *kcp)
+ {
+ compose_mask = state_mask[i];
+ break;
+ }
+ }
+
+ if (compose_mask)
+ break;
+ }
+
+ XFreeModifiermap(map);
+ }
+
+#else
+ Xim = XOpenIM(XCURSESDISPLAY, NULL, NULL, NULL);
+
+ if (Xim)
+ {
+ Xic = XCreateIC(Xim, XNInputStyle,
+ XIMPreeditNothing | XIMStatusNothing,
+ XNClientWindow, XCURSESWIN, NULL);
+ }
+
+ if (Xic)
+ {
+ long im_event_mask;
+
+ XGetICValues(Xic, XNFilterEvents, &im_event_mask, NULL);
+ if (im_event_mask)
+ XtAddEventHandler(drawing, im_event_mask, False,
+ _dummy_handler, NULL);
+
+ XSetICFocus(Xic);
+ }
+ else
+ {
+ perror("ERROR: Cannot create input context");
+ kill(xc_otherpid, SIGKILL);
+ shmdt((char *)SP);
+ shmdt((char *)Xcurscr);
+ shmctl(shmidSP, IPC_RMID, 0);
+ shmctl(shmid_Xcurscr, IPC_RMID, 0);
+ return ERR;
+ }
+
+#endif
+
+ /* Wait for events */
+
+ XtAppMainLoop(app_context);
+ return OK; /* won't get here */
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/xcurses-config.in b/payloads/libpayload/curses/PDCurses-3.4/x11/xcurses-config.in
new file mode 100644
index 0000000000..55b4704c6c
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/xcurses-config.in
@@ -0,0 +1,76 @@
+#! /bin/sh
+#
+# The idea to this kind of setup info script was stolen from numerous
+# other packages, such as neon, libxml and gnome.
+#
+# $Id: xcurses-config.in,v 1.6 2007/11/07 23:33:07 wmcbrine Exp $
+#
+
+verdot=3.4
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+includedir=@includedir@/xcurses
+
+usage()
+{
+ echo "Usage: xcurses-config [OPTION]"
+ echo ""
+ echo "Available values for OPTION include:"
+ echo ""
+ echo " --help display this help and exit"
+ echo " --cflags pre-processor and compiler flags"
+ echo " [-I$includedir]"
+ echo " --libs library linking information"
+ echo " [-L$prefix/lib -lXCurses @LDFLAGS@ @MH_XLIBS@ @MH_EXTRA_LIBS@"
+ echo " --prefix PDCurses install prefix"
+ echo " [$prefix]"
+ echo " --version output version information"
+ echo " [$verdot]"
+ exit $1
+}
+
+if test $# -eq 0; then
+ usage 1
+fi
+
+while test $# -gt 0; do
+ case "$1" in
+ # this deals with options in the style
+ # --option=value and extracts the value part
+ # [not currently used]
+ -*=*) value=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) value= ;;
+ esac
+
+ case "$1" in
+ --prefix)
+ echo $prefix
+ ;;
+
+ --version)
+ echo $verdot
+ exit 0
+ ;;
+
+ --help)
+ usage 0
+ ;;
+
+ --cflags)
+ echo -I$includedir
+ ;;
+
+ --libs)
+ echo -L$prefix/lib -lXCurses @LDFLAGS@ @MH_XLIBS@ @MH_EXTRA_LIBS@
+ ;;
+
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+exit 0