From 74b6d6443d1d9f427612abb7ff4f44e4841c04d0 Mon Sep 17 00:00:00 2001 From: gered Date: Sun, 31 Mar 2019 16:08:07 -0400 Subject: [PATCH] remove files not needed for a dos djgpp build and move to top level --- Makefile | 25 - src/bin2c.cpp => bin2c.cpp | 0 src/c_bind.cpp => c_bind.cpp | 0 src/c_bind.h => c_bind.h | 0 src/c_cmdtab.h => c_cmdtab.h | 0 src/c_color.cpp => c_color.cpp | 0 src/c_color.h => c_color.h | 0 src/c_commands.h => c_commands.h | 0 src/c_config.cpp => c_config.cpp | 0 src/c_config.h => c_config.h | 0 src/c_desktop.cpp => c_desktop.cpp | 0 src/c_desktop.h => c_desktop.h | 0 src/c_fconfig.h => c_fconfig.h | 0 src/c_hilit.cpp => c_hilit.cpp | 0 src/c_hilit.h => c_hilit.h | 0 src/c_history.cpp => c_history.cpp | 0 src/c_history.h => c_history.h | 0 src/c_mode.cpp => c_mode.cpp | 0 src/c_mode.h => c_mode.h | 0 src/cfte.cpp => cfte.cpp | 0 src/clip_no.cpp => clip_no.cpp | 0 src/commands.cpp => commands.cpp | 0 src/con_dosx.cpp => con_dosx.cpp | 0 src/conkbd.h => conkbd.h | 0 src/console.h => console.h | 0 src/defcfg.fte => defcfg.fte | 0 src/e_block.cpp => e_block.cpp | 0 src/e_buffer.cpp => e_buffer.cpp | 0 src/e_buffer.h => e_buffer.h | 0 src/e_cmds.cpp => e_cmds.cpp | 0 src/e_djgpp2.cpp => e_djgpp2.cpp | 0 src/e_file.cpp => e_file.cpp | 0 src/e_fold.cpp => e_fold.cpp | 0 src/e_line.cpp => e_line.cpp | 0 src/e_loadsave.cpp => e_loadsave.cpp | 0 src/e_mark.cpp => e_mark.cpp | 0 src/e_mark.h => e_mark.h | 0 src/e_print.cpp => e_print.cpp | 0 src/e_redraw.cpp => e_redraw.cpp | 0 src/e_regex.cpp => e_regex.cpp | 0 src/e_regex.h => e_regex.h | 0 src/e_search.cpp => e_search.cpp | 0 src/e_tags.cpp => e_tags.cpp | 0 src/e_tags.h => e_tags.h | 0 src/e_trans.cpp => e_trans.cpp | 0 src/e_undo.cpp => e_undo.cpp | 0 src/e_undo.h => e_undo.h | 0 src/egui.cpp => egui.cpp | 0 src/egui.h => egui.h | 0 src/feature.h => feature.h | 0 src/fte-dj2.mak => fte-dj2.mak | 0 src/fte.cnf => fte.cnf | Bin src/fte.cpp => fte.cpp | 0 src/fte.h => fte.h | 0 fte.in | 17 - src/ftever.h => ftever.h | 0 src/g_draw.cpp => g_draw.cpp | 0 src/g_menu.cpp => g_menu.cpp | 0 src/g_nodlg.cpp => g_nodlg.cpp | 0 src/g_text.cpp => g_text.cpp | 0 src/gui.cpp => gui.cpp | 0 src/gui.h => gui.h | 0 src/h_ada.cpp => h_ada.cpp | 0 src/h_c.cpp => h_c.cpp | 0 src/h_catbs.cpp => h_catbs.cpp | 0 src/h_diff.cpp => h_diff.cpp | 0 src/h_fte.cpp => h_fte.cpp | 0 src/h_html.cpp => h_html.cpp | 0 src/h_ipf.cpp => h_ipf.cpp | 0 src/h_make.cpp => h_make.cpp | 0 src/h_merge.cpp => h_merge.cpp | 0 src/h_msg.cpp => h_msg.cpp | 0 src/h_pascal.cpp => h_pascal.cpp | 0 src/h_perl.cpp => h_perl.cpp | 0 src/h_plain.cpp => h_plain.cpp | 0 src/h_rexx.cpp => h_rexx.cpp | 0 src/h_sh.cpp => h_sh.cpp | 0 src/h_simple.cpp => h_simple.cpp | 0 src/h_tex.cpp => h_tex.cpp | 0 src/i_ascii.cpp => i_ascii.cpp | 0 src/i_ascii.h => i_ascii.h | 0 src/i_choice.cpp => i_choice.cpp | 0 src/i_choice.h => i_choice.h | 0 src/i_complete.cpp => i_complete.cpp | 0 src/i_complete.h => i_complete.h | 0 src/i_input.cpp => i_input.cpp | 0 src/i_input.h => i_input.h | 0 src/i_key.cpp => i_key.cpp | 0 src/i_key.h => i_key.h | 0 src/i_modelview.cpp => i_modelview.cpp | 0 src/i_modelview.h => i_modelview.h | 0 src/i_oview.cpp => i_oview.cpp | 0 src/i_oview.h => i_oview.h | 0 src/i_search.cpp => i_search.cpp | 0 src/i_search.h => i_search.h | 0 src/i_view.cpp => i_view.cpp | 0 src/i_view.h => i_view.h | 0 src/indent.cpp => indent.cpp | 0 src/log.cpp => log.cpp | 0 src/log.h => log.h | 0 src/memicmp.cpp => memicmp.cpp | 0 src/menu_text.cpp => menu_text.cpp | 0 src/o_buffer.cpp => o_buffer.cpp | 0 src/o_buflist.cpp => o_buflist.cpp | 0 src/o_buflist.h => o_buflist.h | 0 src/o_directory.cpp => o_directory.cpp | 0 src/o_directory.h => o_directory.h | 0 src/o_list.cpp => o_list.cpp | 0 src/o_list.h => o_list.h | 0 src/o_messages.cpp => o_messages.cpp | 0 src/o_messages.h => o_messages.h | 0 src/o_model.cpp => o_model.cpp | 0 src/o_model.h => o_model.h | 0 src/o_modemap.cpp => o_modemap.cpp | 0 src/o_modemap.h => o_modemap.h | 0 src/o_routine.cpp => o_routine.cpp | 0 src/o_routine.h => o_routine.h | 0 src/objs.inc => objs.inc | 0 src/port.c => port.c | 0 src/port.h => port.h | 0 src/portdos.c => portdos.c | 0 src/s_direct.cpp => s_direct.cpp | 0 src/s_direct.h => s_direct.h | 0 src/s_files.cpp => s_files.cpp | 0 src/s_files.h => s_files.h | 0 src/s_util.cpp => s_util.cpp | 0 src/s_util.h => s_util.h | 0 src/simple.fte => simple.fte | 0 src/Makefile | 31 - src/bmps/close.bmp | Bin 1806 -> 0 bytes src/bmps/copy.bmp | Bin 1806 -> 0 bytes src/bmps/cut.bmp | Bin 1806 -> 0 bytes src/bmps/errnext.bmp | Bin 1806 -> 0 bytes src/bmps/errprev.bmp | Bin 1806 -> 0 bytes src/bmps/exit.bmp | Bin 1806 -> 0 bytes src/bmps/last.bmp | Bin 1806 -> 0 bytes src/bmps/next.bmp | Bin 1806 -> 0 bytes src/bmps/open.bmp | Bin 1806 -> 0 bytes src/bmps/paste.bmp | Bin 1806 -> 0 bytes src/bmps/pastecol.bmp | Bin 1806 -> 0 bytes src/bmps/prev.bmp | Bin 1806 -> 0 bytes src/bmps/redo.bmp | Bin 1806 -> 0 bytes src/bmps/save.bmp | Bin 1806 -> 0 bytes src/bmps/tagfind.bmp | Bin 1806 -> 0 bytes src/bmps/tagnext.bmp | Bin 1806 -> 0 bytes src/bmps/tagpop.bmp | Bin 1806 -> 0 bytes src/bmps/tagprev.bmp | Bin 1806 -> 0 bytes src/bmps/undo.bmp | Bin 1806 -> 0 bytes src/cfte.def | 3 - src/clip.h | 28 - src/clip_gpm.cpp | 18 - src/clip_os2.cpp | 71 - src/clip_pm.cpp | 57 - src/clip_pmv.cpp | 439 --- src/clip_vio.cpp | 103 - src/clip_x11.cpp | 83 - src/clipprog.cpp | 73 - src/clipserv.cpp | 185 -- src/clipserv.def | 3 - src/cliputil.cpp | 50 - src/cliputil.def | 3 - src/compkeys.cpp | 457 --- src/con_i18n.cpp | 397 --- src/con_i18n.h | 32 - src/con_ikcz.h | 390 --- src/con_linux.cpp | 1205 -------- src/con_nt.cpp | 1925 ------------ src/con_os2.cpp | 1226 -------- src/con_slang.cpp | 1057 ------- src/con_x11.cpp | 1660 ---------- src/defcfg2.fte | 264 -- src/dialog.h | 23 - src/e_os2.cpp | 39 - src/e_unix.cpp | 87 - src/e_win32.cpp | 39 - src/fnmatch.h | 84 - src/fte-bcc2.mak | 72 - src/fte-bcc5.mak | 63 - src/fte-cygwin-xf86.mak | 103 - src/fte-emx.mak | 80 - src/fte-mngw.mak | 62 - src/fte-msvc.mak | 71 - src/fte-unix.mak | 207 -- src/fte-vag.mak | 176 -- src/fte-x2.mak | 134 - src/fte-xwin.mak | 246 -- src/fte.def | 3 - src/fte2.cpp | 525 ---- src/ftepm.def | 3 - src/ftepm.rc | 30 - src/g_motif.cpp | 2003 ------------ src/g_pm.cpp | 3891 ------------------------ src/g_qt.cpp | 2138 ------------- src/g_qt.moc | 129 - src/g_qt_dlg.cpp | 214 -- src/g_qt_dlg.moc | 50 - src/icons/ftepm.ico | Bin 3344 -> 0 bytes src/mkdefcfg.pl | 43 - src/namemaps.h | 27 - src/pm_tool.cpp | 403 --- src/pm_tool.h | 35 - src/pmdlg.h | 26 - src/pmdlg.rc | 81 - src/sysdep.h => sysdep.h | 0 src/view.cpp => view.cpp | 0 205 files changed, 20889 deletions(-) delete mode 100644 Makefile rename src/bin2c.cpp => bin2c.cpp (100%) rename src/c_bind.cpp => c_bind.cpp (100%) rename src/c_bind.h => c_bind.h (100%) rename src/c_cmdtab.h => c_cmdtab.h (100%) rename src/c_color.cpp => c_color.cpp (100%) rename src/c_color.h => c_color.h (100%) rename src/c_commands.h => c_commands.h (100%) rename src/c_config.cpp => c_config.cpp (100%) rename src/c_config.h => c_config.h (100%) rename src/c_desktop.cpp => c_desktop.cpp (100%) rename src/c_desktop.h => c_desktop.h (100%) rename src/c_fconfig.h => c_fconfig.h (100%) rename src/c_hilit.cpp => c_hilit.cpp (100%) rename src/c_hilit.h => c_hilit.h (100%) rename src/c_history.cpp => c_history.cpp (100%) rename src/c_history.h => c_history.h (100%) rename src/c_mode.cpp => c_mode.cpp (100%) rename src/c_mode.h => c_mode.h (100%) rename src/cfte.cpp => cfte.cpp (100%) rename src/clip_no.cpp => clip_no.cpp (100%) rename src/commands.cpp => commands.cpp (100%) rename src/con_dosx.cpp => con_dosx.cpp (100%) rename src/conkbd.h => conkbd.h (100%) rename src/console.h => console.h (100%) rename src/defcfg.fte => defcfg.fte (100%) rename src/e_block.cpp => e_block.cpp (100%) rename src/e_buffer.cpp => e_buffer.cpp (100%) rename src/e_buffer.h => e_buffer.h (100%) rename src/e_cmds.cpp => e_cmds.cpp (100%) rename src/e_djgpp2.cpp => e_djgpp2.cpp (100%) rename src/e_file.cpp => e_file.cpp (100%) rename src/e_fold.cpp => e_fold.cpp (100%) rename src/e_line.cpp => e_line.cpp (100%) rename src/e_loadsave.cpp => e_loadsave.cpp (100%) rename src/e_mark.cpp => e_mark.cpp (100%) rename src/e_mark.h => e_mark.h (100%) rename src/e_print.cpp => e_print.cpp (100%) rename src/e_redraw.cpp => e_redraw.cpp (100%) rename src/e_regex.cpp => e_regex.cpp (100%) rename src/e_regex.h => e_regex.h (100%) rename src/e_search.cpp => e_search.cpp (100%) rename src/e_tags.cpp => e_tags.cpp (100%) rename src/e_tags.h => e_tags.h (100%) rename src/e_trans.cpp => e_trans.cpp (100%) rename src/e_undo.cpp => e_undo.cpp (100%) rename src/e_undo.h => e_undo.h (100%) rename src/egui.cpp => egui.cpp (100%) rename src/egui.h => egui.h (100%) rename src/feature.h => feature.h (100%) rename src/fte-dj2.mak => fte-dj2.mak (100%) rename src/fte.cnf => fte.cnf (100%) rename src/fte.cpp => fte.cpp (100%) rename src/fte.h => fte.h (100%) delete mode 100644 fte.in rename src/ftever.h => ftever.h (100%) rename src/g_draw.cpp => g_draw.cpp (100%) rename src/g_menu.cpp => g_menu.cpp (100%) rename src/g_nodlg.cpp => g_nodlg.cpp (100%) rename src/g_text.cpp => g_text.cpp (100%) rename src/gui.cpp => gui.cpp (100%) rename src/gui.h => gui.h (100%) rename src/h_ada.cpp => h_ada.cpp (100%) rename src/h_c.cpp => h_c.cpp (100%) rename src/h_catbs.cpp => h_catbs.cpp (100%) rename src/h_diff.cpp => h_diff.cpp (100%) rename src/h_fte.cpp => h_fte.cpp (100%) rename src/h_html.cpp => h_html.cpp (100%) rename src/h_ipf.cpp => h_ipf.cpp (100%) rename src/h_make.cpp => h_make.cpp (100%) rename src/h_merge.cpp => h_merge.cpp (100%) rename src/h_msg.cpp => h_msg.cpp (100%) rename src/h_pascal.cpp => h_pascal.cpp (100%) rename src/h_perl.cpp => h_perl.cpp (100%) rename src/h_plain.cpp => h_plain.cpp (100%) rename src/h_rexx.cpp => h_rexx.cpp (100%) rename src/h_sh.cpp => h_sh.cpp (100%) rename src/h_simple.cpp => h_simple.cpp (100%) rename src/h_tex.cpp => h_tex.cpp (100%) rename src/i_ascii.cpp => i_ascii.cpp (100%) rename src/i_ascii.h => i_ascii.h (100%) rename src/i_choice.cpp => i_choice.cpp (100%) rename src/i_choice.h => i_choice.h (100%) rename src/i_complete.cpp => i_complete.cpp (100%) rename src/i_complete.h => i_complete.h (100%) rename src/i_input.cpp => i_input.cpp (100%) rename src/i_input.h => i_input.h (100%) rename src/i_key.cpp => i_key.cpp (100%) rename src/i_key.h => i_key.h (100%) rename src/i_modelview.cpp => i_modelview.cpp (100%) rename src/i_modelview.h => i_modelview.h (100%) rename src/i_oview.cpp => i_oview.cpp (100%) rename src/i_oview.h => i_oview.h (100%) rename src/i_search.cpp => i_search.cpp (100%) rename src/i_search.h => i_search.h (100%) rename src/i_view.cpp => i_view.cpp (100%) rename src/i_view.h => i_view.h (100%) rename src/indent.cpp => indent.cpp (100%) rename src/log.cpp => log.cpp (100%) rename src/log.h => log.h (100%) rename src/memicmp.cpp => memicmp.cpp (100%) rename src/menu_text.cpp => menu_text.cpp (100%) rename src/o_buffer.cpp => o_buffer.cpp (100%) rename src/o_buflist.cpp => o_buflist.cpp (100%) rename src/o_buflist.h => o_buflist.h (100%) rename src/o_directory.cpp => o_directory.cpp (100%) rename src/o_directory.h => o_directory.h (100%) rename src/o_list.cpp => o_list.cpp (100%) rename src/o_list.h => o_list.h (100%) rename src/o_messages.cpp => o_messages.cpp (100%) rename src/o_messages.h => o_messages.h (100%) rename src/o_model.cpp => o_model.cpp (100%) rename src/o_model.h => o_model.h (100%) rename src/o_modemap.cpp => o_modemap.cpp (100%) rename src/o_modemap.h => o_modemap.h (100%) rename src/o_routine.cpp => o_routine.cpp (100%) rename src/o_routine.h => o_routine.h (100%) rename src/objs.inc => objs.inc (100%) rename src/port.c => port.c (100%) rename src/port.h => port.h (100%) rename src/portdos.c => portdos.c (100%) rename src/s_direct.cpp => s_direct.cpp (100%) rename src/s_direct.h => s_direct.h (100%) rename src/s_files.cpp => s_files.cpp (100%) rename src/s_files.h => s_files.h (100%) rename src/s_util.cpp => s_util.cpp (100%) rename src/s_util.h => s_util.h (100%) rename src/simple.fte => simple.fte (100%) delete mode 100644 src/Makefile delete mode 100644 src/bmps/close.bmp delete mode 100644 src/bmps/copy.bmp delete mode 100644 src/bmps/cut.bmp delete mode 100644 src/bmps/errnext.bmp delete mode 100644 src/bmps/errprev.bmp delete mode 100644 src/bmps/exit.bmp delete mode 100644 src/bmps/last.bmp delete mode 100644 src/bmps/next.bmp delete mode 100644 src/bmps/open.bmp delete mode 100644 src/bmps/paste.bmp delete mode 100644 src/bmps/pastecol.bmp delete mode 100644 src/bmps/prev.bmp delete mode 100644 src/bmps/redo.bmp delete mode 100644 src/bmps/save.bmp delete mode 100644 src/bmps/tagfind.bmp delete mode 100644 src/bmps/tagnext.bmp delete mode 100644 src/bmps/tagpop.bmp delete mode 100644 src/bmps/tagprev.bmp delete mode 100644 src/bmps/undo.bmp delete mode 100644 src/cfte.def delete mode 100644 src/clip.h delete mode 100644 src/clip_gpm.cpp delete mode 100644 src/clip_os2.cpp delete mode 100644 src/clip_pm.cpp delete mode 100644 src/clip_pmv.cpp delete mode 100644 src/clip_vio.cpp delete mode 100644 src/clip_x11.cpp delete mode 100644 src/clipprog.cpp delete mode 100644 src/clipserv.cpp delete mode 100644 src/clipserv.def delete mode 100644 src/cliputil.cpp delete mode 100644 src/cliputil.def delete mode 100644 src/compkeys.cpp delete mode 100644 src/con_i18n.cpp delete mode 100644 src/con_i18n.h delete mode 100644 src/con_ikcz.h delete mode 100644 src/con_linux.cpp delete mode 100644 src/con_nt.cpp delete mode 100644 src/con_os2.cpp delete mode 100644 src/con_slang.cpp delete mode 100644 src/con_x11.cpp delete mode 100644 src/defcfg2.fte delete mode 100644 src/dialog.h delete mode 100644 src/e_os2.cpp delete mode 100644 src/e_unix.cpp delete mode 100644 src/e_win32.cpp delete mode 100644 src/fnmatch.h delete mode 100644 src/fte-bcc2.mak delete mode 100644 src/fte-bcc5.mak delete mode 100644 src/fte-cygwin-xf86.mak delete mode 100644 src/fte-emx.mak delete mode 100644 src/fte-mngw.mak delete mode 100644 src/fte-msvc.mak delete mode 100644 src/fte-unix.mak delete mode 100644 src/fte-vag.mak delete mode 100644 src/fte-x2.mak delete mode 100644 src/fte-xwin.mak delete mode 100644 src/fte.def delete mode 100644 src/fte2.cpp delete mode 100644 src/ftepm.def delete mode 100644 src/ftepm.rc delete mode 100644 src/g_motif.cpp delete mode 100644 src/g_pm.cpp delete mode 100644 src/g_qt.cpp delete mode 100644 src/g_qt.moc delete mode 100644 src/g_qt_dlg.cpp delete mode 100644 src/g_qt_dlg.moc delete mode 100644 src/icons/ftepm.ico delete mode 100644 src/mkdefcfg.pl delete mode 100644 src/namemaps.h delete mode 100644 src/pm_tool.cpp delete mode 100644 src/pm_tool.h delete mode 100644 src/pmdlg.h delete mode 100644 src/pmdlg.rc rename src/sysdep.h => sysdep.h (100%) rename src/view.cpp => view.cpp (100%) diff --git a/Makefile b/Makefile deleted file mode 100644 index d586d1c..0000000 --- a/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -PREFIX=/usr/local - -BINDIR=$(PREFIX)/bin -LIBDIR=$(PREFIX)/lib/fte -CONFIGDIR=$(LIBDIR)/config - -.PHONY: all install - -all: fte - (cd src ; make unix) - -install: all - sh install - -fte: fte.in Makefile - sed < fte.in >$@ \ - -e "s|@@CONFIGDIR@@|$(CONFIGDIR)|g" \ - -e "s|@@BINDIR@@|$(BINDIR)|g" - chmod a+x $@ - -dist: fte - -clean: - rm -f fte - (cd src ; make -f fte-unix.mak clean) diff --git a/src/bin2c.cpp b/bin2c.cpp similarity index 100% rename from src/bin2c.cpp rename to bin2c.cpp diff --git a/src/c_bind.cpp b/c_bind.cpp similarity index 100% rename from src/c_bind.cpp rename to c_bind.cpp diff --git a/src/c_bind.h b/c_bind.h similarity index 100% rename from src/c_bind.h rename to c_bind.h diff --git a/src/c_cmdtab.h b/c_cmdtab.h similarity index 100% rename from src/c_cmdtab.h rename to c_cmdtab.h diff --git a/src/c_color.cpp b/c_color.cpp similarity index 100% rename from src/c_color.cpp rename to c_color.cpp diff --git a/src/c_color.h b/c_color.h similarity index 100% rename from src/c_color.h rename to c_color.h diff --git a/src/c_commands.h b/c_commands.h similarity index 100% rename from src/c_commands.h rename to c_commands.h diff --git a/src/c_config.cpp b/c_config.cpp similarity index 100% rename from src/c_config.cpp rename to c_config.cpp diff --git a/src/c_config.h b/c_config.h similarity index 100% rename from src/c_config.h rename to c_config.h diff --git a/src/c_desktop.cpp b/c_desktop.cpp similarity index 100% rename from src/c_desktop.cpp rename to c_desktop.cpp diff --git a/src/c_desktop.h b/c_desktop.h similarity index 100% rename from src/c_desktop.h rename to c_desktop.h diff --git a/src/c_fconfig.h b/c_fconfig.h similarity index 100% rename from src/c_fconfig.h rename to c_fconfig.h diff --git a/src/c_hilit.cpp b/c_hilit.cpp similarity index 100% rename from src/c_hilit.cpp rename to c_hilit.cpp diff --git a/src/c_hilit.h b/c_hilit.h similarity index 100% rename from src/c_hilit.h rename to c_hilit.h diff --git a/src/c_history.cpp b/c_history.cpp similarity index 100% rename from src/c_history.cpp rename to c_history.cpp diff --git a/src/c_history.h b/c_history.h similarity index 100% rename from src/c_history.h rename to c_history.h diff --git a/src/c_mode.cpp b/c_mode.cpp similarity index 100% rename from src/c_mode.cpp rename to c_mode.cpp diff --git a/src/c_mode.h b/c_mode.h similarity index 100% rename from src/c_mode.h rename to c_mode.h diff --git a/src/cfte.cpp b/cfte.cpp similarity index 100% rename from src/cfte.cpp rename to cfte.cpp diff --git a/src/clip_no.cpp b/clip_no.cpp similarity index 100% rename from src/clip_no.cpp rename to clip_no.cpp diff --git a/src/commands.cpp b/commands.cpp similarity index 100% rename from src/commands.cpp rename to commands.cpp diff --git a/src/con_dosx.cpp b/con_dosx.cpp similarity index 100% rename from src/con_dosx.cpp rename to con_dosx.cpp diff --git a/src/conkbd.h b/conkbd.h similarity index 100% rename from src/conkbd.h rename to conkbd.h diff --git a/src/console.h b/console.h similarity index 100% rename from src/console.h rename to console.h diff --git a/src/defcfg.fte b/defcfg.fte similarity index 100% rename from src/defcfg.fte rename to defcfg.fte diff --git a/src/e_block.cpp b/e_block.cpp similarity index 100% rename from src/e_block.cpp rename to e_block.cpp diff --git a/src/e_buffer.cpp b/e_buffer.cpp similarity index 100% rename from src/e_buffer.cpp rename to e_buffer.cpp diff --git a/src/e_buffer.h b/e_buffer.h similarity index 100% rename from src/e_buffer.h rename to e_buffer.h diff --git a/src/e_cmds.cpp b/e_cmds.cpp similarity index 100% rename from src/e_cmds.cpp rename to e_cmds.cpp diff --git a/src/e_djgpp2.cpp b/e_djgpp2.cpp similarity index 100% rename from src/e_djgpp2.cpp rename to e_djgpp2.cpp diff --git a/src/e_file.cpp b/e_file.cpp similarity index 100% rename from src/e_file.cpp rename to e_file.cpp diff --git a/src/e_fold.cpp b/e_fold.cpp similarity index 100% rename from src/e_fold.cpp rename to e_fold.cpp diff --git a/src/e_line.cpp b/e_line.cpp similarity index 100% rename from src/e_line.cpp rename to e_line.cpp diff --git a/src/e_loadsave.cpp b/e_loadsave.cpp similarity index 100% rename from src/e_loadsave.cpp rename to e_loadsave.cpp diff --git a/src/e_mark.cpp b/e_mark.cpp similarity index 100% rename from src/e_mark.cpp rename to e_mark.cpp diff --git a/src/e_mark.h b/e_mark.h similarity index 100% rename from src/e_mark.h rename to e_mark.h diff --git a/src/e_print.cpp b/e_print.cpp similarity index 100% rename from src/e_print.cpp rename to e_print.cpp diff --git a/src/e_redraw.cpp b/e_redraw.cpp similarity index 100% rename from src/e_redraw.cpp rename to e_redraw.cpp diff --git a/src/e_regex.cpp b/e_regex.cpp similarity index 100% rename from src/e_regex.cpp rename to e_regex.cpp diff --git a/src/e_regex.h b/e_regex.h similarity index 100% rename from src/e_regex.h rename to e_regex.h diff --git a/src/e_search.cpp b/e_search.cpp similarity index 100% rename from src/e_search.cpp rename to e_search.cpp diff --git a/src/e_tags.cpp b/e_tags.cpp similarity index 100% rename from src/e_tags.cpp rename to e_tags.cpp diff --git a/src/e_tags.h b/e_tags.h similarity index 100% rename from src/e_tags.h rename to e_tags.h diff --git a/src/e_trans.cpp b/e_trans.cpp similarity index 100% rename from src/e_trans.cpp rename to e_trans.cpp diff --git a/src/e_undo.cpp b/e_undo.cpp similarity index 100% rename from src/e_undo.cpp rename to e_undo.cpp diff --git a/src/e_undo.h b/e_undo.h similarity index 100% rename from src/e_undo.h rename to e_undo.h diff --git a/src/egui.cpp b/egui.cpp similarity index 100% rename from src/egui.cpp rename to egui.cpp diff --git a/src/egui.h b/egui.h similarity index 100% rename from src/egui.h rename to egui.h diff --git a/src/feature.h b/feature.h similarity index 100% rename from src/feature.h rename to feature.h diff --git a/src/fte-dj2.mak b/fte-dj2.mak similarity index 100% rename from src/fte-dj2.mak rename to fte-dj2.mak diff --git a/src/fte.cnf b/fte.cnf similarity index 100% rename from src/fte.cnf rename to fte.cnf diff --git a/src/fte.cpp b/fte.cpp similarity index 100% rename from src/fte.cpp rename to fte.cpp diff --git a/src/fte.h b/fte.h similarity index 100% rename from src/fte.h rename to fte.h diff --git a/fte.in b/fte.in deleted file mode 100644 index 0da8177..0000000 --- a/fte.in +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -if [ ! -f $HOME/.fterc ] -then - # Is there a .fte/mymain.fte ? If not, create it. - if [ ! -f $HOME/.fte/mymain.fte ] - then - if [ ! -d $HOME/.fte ] - then - mkdir $HOME/.fte - fi - cp @@CONFIGDIR@@/mymain.fte $HOME/.fte/mymain.fte - fi - (cd @@CONFIGDIR@@; @@BINDIR@@/cfte mymain.fte $HOME/.fterc) || exit 1 -fi - -exec @@BINDIR@@/xfte "$@" diff --git a/src/ftever.h b/ftever.h similarity index 100% rename from src/ftever.h rename to ftever.h diff --git a/src/g_draw.cpp b/g_draw.cpp similarity index 100% rename from src/g_draw.cpp rename to g_draw.cpp diff --git a/src/g_menu.cpp b/g_menu.cpp similarity index 100% rename from src/g_menu.cpp rename to g_menu.cpp diff --git a/src/g_nodlg.cpp b/g_nodlg.cpp similarity index 100% rename from src/g_nodlg.cpp rename to g_nodlg.cpp diff --git a/src/g_text.cpp b/g_text.cpp similarity index 100% rename from src/g_text.cpp rename to g_text.cpp diff --git a/src/gui.cpp b/gui.cpp similarity index 100% rename from src/gui.cpp rename to gui.cpp diff --git a/src/gui.h b/gui.h similarity index 100% rename from src/gui.h rename to gui.h diff --git a/src/h_ada.cpp b/h_ada.cpp similarity index 100% rename from src/h_ada.cpp rename to h_ada.cpp diff --git a/src/h_c.cpp b/h_c.cpp similarity index 100% rename from src/h_c.cpp rename to h_c.cpp diff --git a/src/h_catbs.cpp b/h_catbs.cpp similarity index 100% rename from src/h_catbs.cpp rename to h_catbs.cpp diff --git a/src/h_diff.cpp b/h_diff.cpp similarity index 100% rename from src/h_diff.cpp rename to h_diff.cpp diff --git a/src/h_fte.cpp b/h_fte.cpp similarity index 100% rename from src/h_fte.cpp rename to h_fte.cpp diff --git a/src/h_html.cpp b/h_html.cpp similarity index 100% rename from src/h_html.cpp rename to h_html.cpp diff --git a/src/h_ipf.cpp b/h_ipf.cpp similarity index 100% rename from src/h_ipf.cpp rename to h_ipf.cpp diff --git a/src/h_make.cpp b/h_make.cpp similarity index 100% rename from src/h_make.cpp rename to h_make.cpp diff --git a/src/h_merge.cpp b/h_merge.cpp similarity index 100% rename from src/h_merge.cpp rename to h_merge.cpp diff --git a/src/h_msg.cpp b/h_msg.cpp similarity index 100% rename from src/h_msg.cpp rename to h_msg.cpp diff --git a/src/h_pascal.cpp b/h_pascal.cpp similarity index 100% rename from src/h_pascal.cpp rename to h_pascal.cpp diff --git a/src/h_perl.cpp b/h_perl.cpp similarity index 100% rename from src/h_perl.cpp rename to h_perl.cpp diff --git a/src/h_plain.cpp b/h_plain.cpp similarity index 100% rename from src/h_plain.cpp rename to h_plain.cpp diff --git a/src/h_rexx.cpp b/h_rexx.cpp similarity index 100% rename from src/h_rexx.cpp rename to h_rexx.cpp diff --git a/src/h_sh.cpp b/h_sh.cpp similarity index 100% rename from src/h_sh.cpp rename to h_sh.cpp diff --git a/src/h_simple.cpp b/h_simple.cpp similarity index 100% rename from src/h_simple.cpp rename to h_simple.cpp diff --git a/src/h_tex.cpp b/h_tex.cpp similarity index 100% rename from src/h_tex.cpp rename to h_tex.cpp diff --git a/src/i_ascii.cpp b/i_ascii.cpp similarity index 100% rename from src/i_ascii.cpp rename to i_ascii.cpp diff --git a/src/i_ascii.h b/i_ascii.h similarity index 100% rename from src/i_ascii.h rename to i_ascii.h diff --git a/src/i_choice.cpp b/i_choice.cpp similarity index 100% rename from src/i_choice.cpp rename to i_choice.cpp diff --git a/src/i_choice.h b/i_choice.h similarity index 100% rename from src/i_choice.h rename to i_choice.h diff --git a/src/i_complete.cpp b/i_complete.cpp similarity index 100% rename from src/i_complete.cpp rename to i_complete.cpp diff --git a/src/i_complete.h b/i_complete.h similarity index 100% rename from src/i_complete.h rename to i_complete.h diff --git a/src/i_input.cpp b/i_input.cpp similarity index 100% rename from src/i_input.cpp rename to i_input.cpp diff --git a/src/i_input.h b/i_input.h similarity index 100% rename from src/i_input.h rename to i_input.h diff --git a/src/i_key.cpp b/i_key.cpp similarity index 100% rename from src/i_key.cpp rename to i_key.cpp diff --git a/src/i_key.h b/i_key.h similarity index 100% rename from src/i_key.h rename to i_key.h diff --git a/src/i_modelview.cpp b/i_modelview.cpp similarity index 100% rename from src/i_modelview.cpp rename to i_modelview.cpp diff --git a/src/i_modelview.h b/i_modelview.h similarity index 100% rename from src/i_modelview.h rename to i_modelview.h diff --git a/src/i_oview.cpp b/i_oview.cpp similarity index 100% rename from src/i_oview.cpp rename to i_oview.cpp diff --git a/src/i_oview.h b/i_oview.h similarity index 100% rename from src/i_oview.h rename to i_oview.h diff --git a/src/i_search.cpp b/i_search.cpp similarity index 100% rename from src/i_search.cpp rename to i_search.cpp diff --git a/src/i_search.h b/i_search.h similarity index 100% rename from src/i_search.h rename to i_search.h diff --git a/src/i_view.cpp b/i_view.cpp similarity index 100% rename from src/i_view.cpp rename to i_view.cpp diff --git a/src/i_view.h b/i_view.h similarity index 100% rename from src/i_view.h rename to i_view.h diff --git a/src/indent.cpp b/indent.cpp similarity index 100% rename from src/indent.cpp rename to indent.cpp diff --git a/src/log.cpp b/log.cpp similarity index 100% rename from src/log.cpp rename to log.cpp diff --git a/src/log.h b/log.h similarity index 100% rename from src/log.h rename to log.h diff --git a/src/memicmp.cpp b/memicmp.cpp similarity index 100% rename from src/memicmp.cpp rename to memicmp.cpp diff --git a/src/menu_text.cpp b/menu_text.cpp similarity index 100% rename from src/menu_text.cpp rename to menu_text.cpp diff --git a/src/o_buffer.cpp b/o_buffer.cpp similarity index 100% rename from src/o_buffer.cpp rename to o_buffer.cpp diff --git a/src/o_buflist.cpp b/o_buflist.cpp similarity index 100% rename from src/o_buflist.cpp rename to o_buflist.cpp diff --git a/src/o_buflist.h b/o_buflist.h similarity index 100% rename from src/o_buflist.h rename to o_buflist.h diff --git a/src/o_directory.cpp b/o_directory.cpp similarity index 100% rename from src/o_directory.cpp rename to o_directory.cpp diff --git a/src/o_directory.h b/o_directory.h similarity index 100% rename from src/o_directory.h rename to o_directory.h diff --git a/src/o_list.cpp b/o_list.cpp similarity index 100% rename from src/o_list.cpp rename to o_list.cpp diff --git a/src/o_list.h b/o_list.h similarity index 100% rename from src/o_list.h rename to o_list.h diff --git a/src/o_messages.cpp b/o_messages.cpp similarity index 100% rename from src/o_messages.cpp rename to o_messages.cpp diff --git a/src/o_messages.h b/o_messages.h similarity index 100% rename from src/o_messages.h rename to o_messages.h diff --git a/src/o_model.cpp b/o_model.cpp similarity index 100% rename from src/o_model.cpp rename to o_model.cpp diff --git a/src/o_model.h b/o_model.h similarity index 100% rename from src/o_model.h rename to o_model.h diff --git a/src/o_modemap.cpp b/o_modemap.cpp similarity index 100% rename from src/o_modemap.cpp rename to o_modemap.cpp diff --git a/src/o_modemap.h b/o_modemap.h similarity index 100% rename from src/o_modemap.h rename to o_modemap.h diff --git a/src/o_routine.cpp b/o_routine.cpp similarity index 100% rename from src/o_routine.cpp rename to o_routine.cpp diff --git a/src/o_routine.h b/o_routine.h similarity index 100% rename from src/o_routine.h rename to o_routine.h diff --git a/src/objs.inc b/objs.inc similarity index 100% rename from src/objs.inc rename to objs.inc diff --git a/src/port.c b/port.c similarity index 100% rename from src/port.c rename to port.c diff --git a/src/port.h b/port.h similarity index 100% rename from src/port.h rename to port.h diff --git a/src/portdos.c b/portdos.c similarity index 100% rename from src/portdos.c rename to portdos.c diff --git a/src/s_direct.cpp b/s_direct.cpp similarity index 100% rename from src/s_direct.cpp rename to s_direct.cpp diff --git a/src/s_direct.h b/s_direct.h similarity index 100% rename from src/s_direct.h rename to s_direct.h diff --git a/src/s_files.cpp b/s_files.cpp similarity index 100% rename from src/s_files.cpp rename to s_files.cpp diff --git a/src/s_files.h b/s_files.h similarity index 100% rename from src/s_files.h rename to s_files.h diff --git a/src/s_util.cpp b/s_util.cpp similarity index 100% rename from src/s_util.cpp rename to s_util.cpp diff --git a/src/s_util.h b/s_util.h similarity index 100% rename from src/s_util.h rename to s_util.h diff --git a/src/simple.fte b/simple.fte similarity index 100% rename from src/simple.fte rename to simple.fte diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index f1fe962..0000000 --- a/src/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -MAKE=make - -all: - @echo 'What (emx, unix, cygwin, bcc2, win32ms, win32bcc5, win32mingw, djgpp2, vag)?' - -emx: - $(MAKE) -f fte-emx.mak - -unix: - $(MAKE) -f fte-unix.mak - -cygwin: - $(MAKE) -f fte-cygwin-xf86.mak - -bcc2: - $(MAKE) -f fte-bcc2.mak - -win32ms: - nmake /f fte-msvc.mak - -win32mingw: - $(MAKE) -f fte-mngw.mak - -win32bcc5: - $(MAKE) -f fte-bcc5.mak - -djgpp2: - $(MAKE) -f fte-dj2.mak - -vag: - nmake /f fte-vag.mak diff --git a/src/bmps/close.bmp b/src/bmps/close.bmp deleted file mode 100644 index 07439bd058e9acbf61ff7d37498437873120ad4a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1806 zcmeH^Q3`-C3`6x69!LDwqt7cjt&~#Iw1R&+980^GY|Lfd1{vo%_c`5jyi_k9jJCJ` zE53j{YX#<{{vIAx!BQp#^bUk1TWYrg@~~-LP&=0^p(SdnS4BjoeNE^hg$eLVjtvn_ tPK>rRL;zPtF4u=H*mOo)5}s_?gsxLE1u7wOXc{GeyCE#=B(#69c>tOwo#_Ao diff --git a/src/bmps/copy.bmp b/src/bmps/copy.bmp deleted file mode 100644 index d6655694eedfdf287fb75a083503acfaf16b8c89..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1806 zcmeHGZ4Q7S2(?>uoYwz3RO@_oBzt6I8i?y_t1X5T6&^grw(DIGnj4II8`WxIaX_Yd z`kdPIc64lK=e@4Z#W(=*d7%_P&SUq(mw)A+5jzfJsPQxo1*#%nztlf~xn2*`VMFi3 zv=}rtvge=66U7pv@H@&lgq2AAt=NW#QBQmXPmYqt+i*}}LO#EcT+|%^plzgLU-dUO QCDaL!fRDgfjHI_8Eev~@{Qv*} diff --git a/src/bmps/cut.bmp b/src/bmps/cut.bmp deleted file mode 100644 index 604a849171e0cff02d36c9cefd3f778587bd9aba..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1806 zcmeHDTMmOT3>&xLIEer4P>A!vm1bsSMQs{Vep%Fl>)7sNet%x9<3C}J=Nx_ri;mj% z?LTh30H4?zYsPk63=8=HxW}nMjcPViITw_fl0ktlx2ANu!VGu$)Kt|uvAcQS} zmNMYs)uni_K-_9E1YJfE^qxu~umhvGUDv7Lf}Tbt2qdH2kRtOkDhTO{(%}VYw_mjc XY}alV2$C{fTrXVjVwt?sx}J=`ASB)! diff --git a/src/bmps/errnext.bmp b/src/bmps/errnext.bmp deleted file mode 100644 index 1993fd2cb2f629b3e6f8af20a74f75a34be843ba..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1806 zcmd6jZ4QD!5JUAA9>?%sj*eHNI^?C!Wm@jd?-giB>?YX{5hYzmh zx%~gF@7Y_@E$5u)r({ct*E%<0ngld%^dXboPzX3QVOc27E_%5$8G+Y2N5-qVOe=R0 zPd16#rt0v>#BNe9x-%j$tWP~?{60Pr&QPz7E6BC3kaY12uKVBy6#YqdGjh9n7Kinz S2eDWk`{8#n=zLF>90n^!R3~l# diff --git a/src/bmps/errprev.bmp b/src/bmps/errprev.bmp deleted file mode 100644 index e12560991ef2ce4d260e15a0184173cf47213114..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1806 zcmd6iQ4T;b5Jb6!!b0Yj$etB8H)2mQYH+vf3c z!IpLTx8M!T@7ZlGD*iS6o>HFb9H8*V>osZA_62ASr-9?i&zo(I>$5+A29)g`6d}) rjRb#%EnM+}F=$|@K)_-F*9b7Cu1B~k9+}D_qAK|Slc>P$Rxp7B{y$nZ diff --git a/src/bmps/next.bmp b/src/bmps/next.bmp deleted file mode 100644 index 604d7bf2af04f4e8d7af99f33cb1268c21fb0cd3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1806 zcmZ?r^<#hl5bXfO5>U(tW&t@QfOF^1jiNyk0>Egaic28TPq|U>WJIA+aC0d4;6NFL zY%hK`{;!b0Yj$etB8H)2mQYH+vf3c z!IpLTx8M!T@7ZlGD*iSl>?FjhGRae%W>37a)^@>L~Cyq2001k3n%6-jusQ+NRfyEkzz`t--KL%!bFUqm$XPHkGY9EBj$gO7Hb=~F$7VxFO diff --git a/src/bmps/pastecol.bmp b/src/bmps/pastecol.bmp deleted file mode 100644 index 66a957a17e7993b56e0e5a119f5e7f2f7ae77dd3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1806 zcmd6l(G9~O3`E;4I!=}UcBm@zB_q+JSE0io;~-Uy1;jYq!>)R5!2RdR@v5=`4sI}CCX&&i5(!q0y>+AQ+?MVl3cNMF%iBfy~(uJmI$H3Y`=YL%BfbDGeOnBz#1I0=rm mTCJRo18+_Dor1RD=Mb;2)eIDURrjqy%|S?pwnX=?-xc40zNEnb diff --git a/src/bmps/prev.bmp b/src/bmps/prev.bmp deleted file mode 100644 index d3b560d03f69e13978a493a77192f3981f53e5c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1806 zcmZ?r^<#hl5bXfO5>U(tW&t@QfOF^1jiSL20>C(<+!>IFr_daD>Y>COxFMAIYj7HZ z>?%w)oFJqnk*@+a5Tc?}9mhb9y~&21Y#N zZ(bcZLU2KWQbm+#&i>EHQMFqL^g+I*78I(Z(WNW69|h x>vZ|kJdY@CM>xjSY=T5H6t=7c=Oiu+h)F=l`q!cYJ_xt@FxB(n%t`z_P diff --git a/src/bmps/save.bmp b/src/bmps/save.bmp deleted file mode 100644 index cb71310ff4f4147136677c2c24ec31bae0db198c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1806 zcmZ?r^<#hl5bXfO5>U(tW&t@QfOF^14R6%Kz(5AV3=^Os|AB~j0JeA39Gn3*8a_CK z1}s6J@PVXi;z(c?z?Ghnvlv!yL9-9oB67?DhX&B(k!%ifAcMjI8$eTo8DGOp1OUed B)n@949$nt|iX%Kj|IUcX%NM182D{ z|GGZq?ipl4tz$?4?O+^G8!}H-c%x5MmBTqc>PsVmJO&Ihn0;W5kMH6*&)lDfY=B%2 zgA&GpvV@Ky17H%M$}03)$F9tLX0U3e$cAkxcl?|BCi$-Q#lQH_C4*?8N&HIIX`M|f j{j|OML*{H|VwX=mn@ZpZz5>!z%xLIces>$~zFq$SPl1lI diff --git a/src/bmps/tagnext.bmp b/src/bmps/tagnext.bmp deleted file mode 100644 index 66daea0a6b4e40bdeb64c9545be94eae78cc8bb3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1806 zcmdUrQ4WGY3@5PN5?B!DVe-%rCXH**gzQC*V%>p_!xY>pEtX&%YB*2UcOk< zbK2|DQ~rDglQ64HQ6UM?GJtg!_P|buV9 P(SH@0zvmDG2dTUO$xwU` diff --git a/src/bmps/tagpop.bmp b/src/bmps/tagpop.bmp deleted file mode 100644 index 03532e6ad271277bc9562e989edde47b90889f3e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1806 zcmc(aQ4Yc|3`5H;I1b_;jy{eAflNv#DfD+bQ; zTK;u)%jq4=gjvOq0ODX2FzYgH1-#QIOy%+%AIl}kKwbj|8O$6w$4B3yIPcuwhpvM> z4ucX#fpsYrLps33LFihkvx-%j`OIKdw&<#@<5FLe9eu|?C#ui8HNDe5Ii-9;N$Nhw eeaa_n%AFX4U3P6%YDUQ}H;*$M&+wAjUwU4doil@$vuSIcDzXp(=>u zD0HHDuqsE-h`<~lTc;TPFltjI5=KZ(27RJ4iZc9s(=!O;Ch31wR;>W3j}2ngGEq;b SN-15JHel5P(h6E_x9e{KVtfw( diff --git a/src/bmps/undo.bmp b/src/bmps/undo.bmp deleted file mode 100644 index b9cfbcad823b8f108e90500bf0d3b1567b5d9694..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1806 zcmeH^-3@>s41{qD$1%R^RL+MZ>FJq<@Mo*MDJf9!_0NHYZdlRa}0o;UwI1O=VLZ$xkygBNnC77fuC8s1KMA>bKvmAkFI202V ut@Clear(); - j = 0; - l = 0; - - for (i = 0; i < cd.fLen; i++) { - if (cd.fChar[i] == 0x0A) { - SSBuffer->AssertLine(l); - P.Col = 0; P.Row = l++; - dx = 0; - if ((i > 0) && (cd.fChar[i-1] == 0x0D)) dx++; - SSBuffer->InsertLine(P, i - j - dx, cd.fChar + j); - j = i + 1; - } - } - if (j < cd.fLen) { // remainder - i = cd.fLen; - SSBuffer->AssertLine(l); - P.Col = 0; P.Row = l++; - dx = 0; - if ((i > 0) && (cd.fChar[i-1] == 0x0D)) dx++; - SSBuffer->InsText(P.Row, P.Col, i - j - dx, cd.fChar + j); - j = i + 1; - } - } - return 0; -} - -int PutPMClip() { - char *p = 0; - int l = 0; - PELine L; - int Len; - ClipData cd; - int rc; - - for (int i = 0; i < SSBuffer->RCount; i++) { - L = SSBuffer->RLine(i); - p = (char *)realloc(p, l + (Len = L->Count) + 2); - memcpy(p + l, L->Chars, L->Count); - l += Len; - if (i < SSBuffer->RCount - 1) { - p[l++] = 13; - p[l++] = 10; - } - } - p = (char *)realloc(p, l + 1); - p[l++] = 0; - cd.fChar = p; - cd.fLen = l; - rc = (PutClipText(&cd) == 0); - free(p); - return rc?1:0; -} diff --git a/src/clip_pm.cpp b/src/clip_pm.cpp deleted file mode 100644 index b063039..0000000 --- a/src/clip_pm.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* clip_pm.cpp - * - * Copyright (c) 1994-1996, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -#include "fte.h" -#include "clip.h" - -#define INCL_WIN -#include -#include -#include - -extern HAB hab; - -int GetClipText(ClipData *cd) { - int rc; - char *text; - - cd->fLen = 0; - cd->fChar = 0; - if ((WinOpenClipbrd(hab) == TRUE) && - ((text = (char *) WinQueryClipbrdData(hab, CF_TEXT)) != 0)) - { - cd->fLen = strlen(text); - cd->fChar = strdup(text); - } - WinCloseClipbrd(hab); - return 0; -} - -int PutClipText(ClipData *cd) { - ULONG len; - void *text; - - if (WinOpenClipbrd(hab) == TRUE) { - WinEmptyClipbrd(hab); - len = cd->fLen; - - if (len) { - DosAllocSharedMem((void **)&text, - 0, - len + 1, - PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE); - strncpy((char *)text, cd->fChar, len + 1); - if (!WinSetClipbrdData(hab, (ULONG) text, CF_TEXT, CFI_POINTER)) - DosBeep(100, 1500); - - } - WinCloseClipbrd(hab); - } - return 0; -} diff --git a/src/clip_pmv.cpp b/src/clip_pmv.cpp deleted file mode 100644 index 5e323e1..0000000 --- a/src/clip_pmv.cpp +++ /dev/null @@ -1,439 +0,0 @@ -/* clip_pm.cpp - * - * Copyright (c) 1994-1998, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -#include "fte.h" -#include "clip.h" - -#define INCL_WIN -#define INCL_DOS -#define INCL_ORDINALS -#include -#include -#include - -/* - * Pointers to PM functions - * Instead of calling PM directly, we are obtaining these pointers - * on first access to clipboard. - * All these prototypes are copied from OS2.H - * Note: all prototypes are 32-bit version only - */ - -#define ORD_WIN32ADDATOM 700 -#define ORD_WIN32ALARM 701 -#define ORD_WIN32BEGINENUMWINDOWS 702 -#define ORD_WIN32BEGINPAINT 703 -#define ORD_WIN32CALCFRAMERECT 704 -#define ORD_WIN32CANCELSHUTDOWN 705 -#define ORD_WIN32CLOSECLIPBRD 707 -#define ORD_WIN32COMPARESTRINGS 708 -#define ORD_WIN32COPYACCELTABLE 709 -#define ORD_WIN32COPYRECT 710 -#define ORD_WIN32CPTRANSLATECHAR 711 -#define ORD_WIN32CPTRANSLATESTRING 712 -#define ORD_WIN32CREATEACCELTABLE 713 -#define ORD_WIN32CREATEATOMTABLE 714 -#define ORD_WIN32CREATECURSOR 715 -#define ORD_WIN32CREATEMSGQUEUE 716 -#define ORD_WIN32CREATEPOINTER 717 -#define ORD_WIN32DDEINITIATE 718 -#define ORD_WIN32DDEPOSTMSG 719 -#define ORD_WIN32DDERESPOND 720 -#define ORD_WIN32DELETEATOM 721 -#define ORD_WIN32DELETELIBRARY 722 -#define ORD_WIN32DESTROYACCELTABLE 723 -#define ORD_WIN32DESTROYATOMTABLE 724 -#define ORD_WIN32DESTROYCURSOR 725 -#define ORD_WIN32DESTROYMSGQUEUE 726 -#define ORD_WIN32DESTROYPOINTER 727 -#define ORD_WIN32DESTROYWINDOW 728 -#define ORD_WIN32DISMISSDLG 729 -#define ORD_WIN32DRAWBITMAP 730 -#define ORD_WIN32DRAWBORDER 731 -#define ORD_WIN32DRAWPOINTER 732 -#define ORD_WIN32EMPTYCLIPBRD 733 -#define ORD_WIN32ENABLEPHYSINPUT 734 -#define ORD_WIN32ENABLEWINDOW 735 -#define ORD_WIN32ENABLEWINDOWUPDATE 736 -#define ORD_WIN32ENDENUMWINDOWS 737 -#define ORD_WIN32ENDPAINT 738 -#define ORD_WIN32ENUMCLIPBRDFMTS 739 -#define ORD_WIN32ENUMDLGITEM 740 -#define ORD_WIN32EQUALRECT 741 -#define ORD_WIN32EXCLUDEUPDATEREGION 742 -#define ORD_WIN32FILLRECT 743 -#define ORD_WIN32FINDATOM 744 -#define ORD_WIN32FLASHWINDOW 745 -#define ORD_WIN32FOCUSCHANGE 746 -#define ORD_WIN32FREEERRORINFO 748 -#define ORD_WIN32GETCLIPPS 749 -#define ORD_WIN32GETCURRENTTIME 750 -#define ORD_WIN32GETERRORINFO 751 -#define ORD_WIN32GETKEYSTATE 752 -#define ORD_WIN32GETLASTERROR 753 -#define ORD_WIN32GETMAXPOSITION 754 -#define ORD_WIN32GETMINPOSITION 755 -#define ORD_WIN32GETNEXTWINDOW 756 -#define ORD_WIN32GETPS 757 -#define ORD_WIN32GETPHYSKEYSTATE 758 -#define ORD_WIN32GETSCREENPS 759 -#define ORD_WIN32GETSYSBITMAP 760 -#define ORD_WIN32INSENDMSG 761 -#define ORD_WIN32INFLATERECT 762 -#define ORD_WIN32INITIALIZE 763 -#define ORD_WIN32INTERSECTRECT 764 -#define ORD_WIN32INVALIDATERECT 765 -#define ORD_WIN32INVALIDATEREGION 766 -#define ORD_WIN32INVERTRECT 767 -#define ORD_WIN32ISCHILD 768 -#define ORD_WIN32ISPHYSINPUTENABLED 769 -#define ORD_WIN32ISRECTEMPTY 770 -#define ORD_WIN32ISTHREADACTIVE 771 -#define ORD_WIN32ISWINDOW 772 -#define ORD_WIN32ISWINDOWENABLED 773 -#define ORD_WIN32ISWINDOWSHOWING 774 -#define ORD_WIN32ISWINDOWVISIBLE 775 -#define ORD_WIN32LOADACCELTABLE 776 -#define ORD_WIN32LOADLIBRARY 777 -#define ORD_WIN32LOADMENU 778 -#define ORD_WIN32LOADMESSAGE 779 -#define ORD_WIN32LOADPOINTER 780 -#define ORD_WIN32LOADSTRING 781 -#define ORD_WIN32LOCKVISREGIONS 782 -#define ORD_WIN32LOCKWINDOWUPDATE 784 -#define ORD_WIN32MAKEPOINTS 785 -#define ORD_WIN32MAKERECT 786 -#define ORD_WIN32MAPDLGPOINTS 787 -#define ORD_WIN32MAPWINDOWPOINTS 788 -#define ORD_WIN32MESSAGEBOX 789 -#define ORD_WIN32MSGSEMWAIT 790 -#define ORD_WIN32NEXTCHAR 791 -#define ORD_WIN32OFFSETRECT 792 -#define ORD_WIN32OPENCLIPBRD 793 -#define ORD_WIN32OPENWINDOWDC 794 -#define ORD_WIN32PREVCHAR 795 -#define ORD_WIN32PROCESSDLG 796 -#define ORD_WIN32PTINRECT 797 -#define ORD_WIN32QUERYACCELTABLE 798 -#define ORD_WIN32QUERYACTIVEWINDOW 799 -#define ORD_WIN32QUERYANCHORBLOCK 800 -#define ORD_WIN32QUERYATOMLENGTH 801 -#define ORD_WIN32QUERYATOMNAME 802 -#define ORD_WIN32QUERYATOMUSAGE 803 -#define ORD_WIN32QUERYCAPTURE 804 -#define ORD_WIN32QUERYCLASSNAME 805 -#define ORD_WIN32QUERYCLIPBRDDATA 806 -#define ORD_WIN32QUERYCLIPBRDFMTINFO 807 -#define ORD_WIN32QUERYCLIPBRDOWNER 808 -#define ORD_WIN32QUERYCLIPBRDVIEWER 809 -#define ORD_WIN32QUERYCP 810 -#define ORD_WIN32QUERYCPLIST 811 -#define ORD_WIN32QUERYCURSORINFO 812 -#define ORD_WIN32QUERYDESKTOPWINDOW 813 -#define ORD_WIN32QUERYDLGITEMSHORT 814 -#define ORD_WIN32QUERYDLGITEMTEXT 815 -#define ORD_WIN32QUERYDLGITEMTEXTLENGTH 816 -#define ORD_WIN32QUERYFOCUS 817 -#define ORD_WIN32QUERYMSGPOS 818 -#define ORD_WIN32QUERYMSGTIME 819 -#define ORD_WIN32QUERYOBJECTWINDOW 820 -#define ORD_WIN32QUERYPOINTER 821 -#define ORD_WIN32QUERYPOINTERINFO 822 -#define ORD_WIN32QUERYPOINTERPOS 823 -#define ORD_WIN32QUERYQUEUEINFO 824 -#define ORD_WIN32QUERYQUEUESTATUS 825 -#define ORD_WIN32QUERYSYSCOLOR 826 -#define ORD_WIN32QUERYSYSMODALWINDOW 827 -#define ORD_WIN32QUERYSYSPOINTER 828 -#define ORD_WIN32QUERYSYSVALUE 829 -#define ORD_WIN32QUERYSYSTEMATOMTABLE 830 -#define ORD_WIN32QUERYUPDATERECT 831 -#define ORD_WIN32QUERYUPDATEREGION 832 -#define ORD_WIN32QUERYVERSION 833 -#define ORD_WIN32QUERYWINDOW 834 -#define ORD_WIN32QUERYWINDOWDC 835 -#define ORD_WIN32QUERYWINDOWPOS 837 -#define ORD_WIN32QUERYWINDOWPROCESS 838 -#define ORD_WIN32QUERYWINDOWPTR 839 -#define ORD_WIN32QUERYWINDOWRECT 840 -#define ORD_WIN32QUERYWINDOWTEXT 841 -#define ORD_WIN32QUERYWINDOWTEXTLENGTH 842 -#define ORD_WIN32QUERYWINDOWULONG 843 -#define ORD_WIN32QUERYWINDOWUSHORT 844 -#define ORD_WIN32REGISTERUSERDATATYPE 845 -#define ORD_WIN32REGISTERUSERMSG 846 -#define ORD_WIN32RELEASEPS 848 -#define ORD_WIN32SCROLLWINDOW 849 -#define ORD_WIN32SETACCELTABLE 850 -#define ORD_WIN32SETACTIVEWINDOW 851 -#define ORD_WIN32SETCAPTURE 852 -#define ORD_WIN32SETCLASSMSGINTEREST 853 -#define ORD_WIN32SETCLIPBRDDATA 854 -#define ORD_WIN32SETCLIPBRDOWNER 855 -#define ORD_WIN32SETCLIPBRDVIEWER 856 -#define ORD_WIN32SETCP 857 -#define ORD_WIN32SETDLGITEMSHORT 858 -#define ORD_WIN32SETDLGITEMTEXT 859 -#define ORD_WIN32SETFOCUS 860 -#define ORD_WIN32SETMSGINTEREST 861 -#define ORD_WIN32SETMSGMODE 862 -#define ORD_WIN32SETMULTWINDOWPOS 863 -#define ORD_WIN32SETOWNER 864 -#define ORD_WIN32SETPARENT 865 -#define ORD_WIN32SETPOINTER 866 -#define ORD_WIN32SETPOINTERPOS 867 -#define ORD_WIN32SETRECT 868 -#define ORD_WIN32SETRECTEMPTY 869 -#define ORD_WIN32SETSYNCHROMODE 870 -#define ORD_WIN32SETSYSCOLORS 871 -#define ORD_WIN32SETSYSMODALWINDOW 872 -#define ORD_WIN32SETSYSVALUE 873 -#define ORD_WIN32SETWINDOWBITS 874 -#define ORD_WIN32SETWINDOWPOS 875 -#define ORD_WIN32SETWINDOWPTR 876 -#define ORD_WIN32SETWINDOWTEXT 877 -#define ORD_WIN32SETWINDOWULONG 878 -#define ORD_WIN32SETWINDOWUSHORT 879 -#define ORD_WIN32SHOWCURSOR 880 -#define ORD_WIN32SHOWPOINTER 881 -#define ORD_WIN32SHOWTRACKRECT 882 -#define ORD_WIN32SHOWWINDOW 883 -#define ORD_WIN32STARTTIMER 884 -#define ORD_WIN32STOPTIMER 885 -#define ORD_WIN32SUBSTITUTESTRINGS 886 -#define ORD_WIN32SUBTRACTRECT 887 -#define ORD_WIN32TERMINATE 888 -#define ORD_WIN32TRACKRECT 890 -#define ORD_WIN32UNIONRECT 891 -#define ORD_WIN32UPDATEWINDOW 892 -#define ORD_WIN32UPPER 893 -#define ORD_WIN32UPPERCHAR 894 -#define ORD_WIN32VALIDATERECT 895 -#define ORD_WIN32VALIDATEREGION 896 -#define ORD_WIN32WAITMSG 897 -#define ORD_WIN32WINDOWFROMDC 898 -#define ORD_WIN32WINDOWFROMID 899 -#define ORD_WIN32WINDOWFROMPOINT 900 -#define ORD_WIN32BROADCASTMSG 901 -#define ORD_WIN32POSTQUEUEMSG 902 -#define ORD_WIN32SENDDLGITEMMSG 903 -#define ORD_WIN32TRANSLATEACCEL 904 -#define ORD_WIN32CALLMSGFILTER 905 -#define ORD_WIN32CREATEFRAMECONTROLS 906 -#define ORD_WIN32CREATEMENU 907 -#define ORD_WIN32CREATESTDWINDOW 908 -#define ORD_WIN32CREATEWINDOW 909 -#define ORD_WIN32DEFDLGPROC 910 -#define ORD_WIN32DEFWINDOWPROC 911 -#define ORD_WIN32DISPATCHMSG 912 -#define ORD_WIN32DRAWTEXT 913 -#define ORD_WIN32GETDLGMSG 914 -#define ORD_WIN32GETMSG 915 -#define ORD_WIN32MSGMUXSEMWAIT 916 -#define ORD_WIN32MULTWINDOWFROMIDS 917 -#define ORD_WIN32PEEKMSG 918 -#define ORD_WIN32POSTMSG 919 -#define ORD_WIN32SENDMSG 920 -#define ORD_WIN32SETKEYBOARDSTATETABLE 921 -#define ORD_WIN32CREATEDLG 922 -#define ORD_WIN32DLGBOX 923 -#define ORD_WIN32LOADDLG 924 -#define ORD_WIN32QUERYCLASSINFO 925 -#define ORD_WIN32REGISTERCLASS 926 -#define ORD_WIN32RELEASEHOOK 927 -#define ORD_WIN32SETHOOK 928 -#define ORD_WIN32SUBCLASSWINDOW 929 -#define ORD_WIN32SETCLASSTHUNKPROC 930 -#define ORD_WIN32QUERYCLASSTHUNKPROC 931 -#define ORD_WIN32SETWINDOWTHUNKPROC 932 -#define ORD_WIN32QUERYWINDOWTHUNKPROC 933 -#define ORD_WIN32QUERYWINDOWMODEL 934 -#define ORD_WIN32SETDESKTOPBKGND 935 -#define ORD_WIN32QUERYDESKTOPBKGND 936 -#define ORD_WIN32POPUPMENU 937 -#define ORD_WIN32SETPRESPARAM 938 -#define ORD_WIN32QUERYPRESPARAM 939 -#define ORD_WIN32REMOVEPRESPARAM 940 -#define ORD_WIN32REALIZEPALETTE 941 -#define ORD_WIN32CREATEPOINTERINDIRECT 942 -#define ORD_WIN32SAVEWINDOWPOS 943 -#define ORD_WIN32GETERASEPS 952 -#define ORD_WIN32RELEASEERASEPS 953 -#define ORD_WIN32SETPOINTEROWNER 971 -#define ORD_WIN32STRETCHPOINTER 968 -#define ORD_WIN32SETERRORINFO 977 -#define ORD_WIN32WAITEVENTSEM 978 -#define ORD_WIN32REQUESTMUTEXSEM 979 -#define ORD_WIN32WAITMUXWAITSEM 980 - - -#ifndef INCL_32 -#error Prototypes are for 32-bit compiler only -#endif - -HAB (APIENTRY *p_WinInitialize)(ULONG flOptions); -BOOL (APIENTRY *p_WinTerminate)(HAB hab); -HMQ (APIENTRY *p_WinCreateMsgQueue)(HAB hab, LONG cmsg); -BOOL (APIENTRY *p_WinDestroyMsgQueue)(HMQ hmq); -BOOL (APIENTRY *p_WinEmptyClipbrd)(HAB hab); -BOOL (APIENTRY *p_WinOpenClipbrd)(HAB hab); -BOOL (APIENTRY *p_WinCloseClipbrd)(HAB hab); -BOOL (APIENTRY *p_WinSetClipbrdData)(HAB hab, ULONG ulData, ULONG fmt, ULONG rgfFmtInfo); -ULONG (APIENTRY *p_WinQueryClipbrdData)(HAB hab, ULONG fmt); - -static struct impentry { - ULONG ordinal; - PFN *pointer; -} imported_functions[] = { - { ORD_WIN32INITIALIZE, (PFN *) &p_WinInitialize }, - { ORD_WIN32TERMINATE, (PFN *) &p_WinTerminate }, - { ORD_WIN32CREATEMSGQUEUE, (PFN *) &p_WinCreateMsgQueue }, - { ORD_WIN32DESTROYMSGQUEUE,(PFN *) &p_WinDestroyMsgQueue }, - { ORD_WIN32EMPTYCLIPBRD, (PFN *) &p_WinEmptyClipbrd }, - { ORD_WIN32OPENCLIPBRD, (PFN *) &p_WinOpenClipbrd }, - { ORD_WIN32CLOSECLIPBRD, (PFN *) &p_WinCloseClipbrd }, - { ORD_WIN32SETCLIPBRDDATA, (PFN *) &p_WinSetClipbrdData }, - { ORD_WIN32QUERYCLIPBRDDATA,(PFN *)&p_WinQueryClipbrdData }, - { 0, 0 } -}; - -/* - * Load PMWIN.DLL and get pointers to all reqd PM functions - */ - -static BOOL loadDLL(void) { - static BOOL loaded = FALSE; - static BOOL loaded_ok = FALSE; - static HMODULE pmwin; - - char error[200]; - - if (loaded == TRUE) - return loaded_ok; - - loaded = TRUE; - - if (DosLoadModule((PSZ)error, sizeof(error), (PSZ)"PMWIN.DLL", &pmwin) == 0) { - struct impentry *imp; - - for (imp = imported_functions; imp->ordinal; imp++) - if (DosQueryProcAddr(pmwin, imp->ordinal, NULL, imp->pointer) != 0) - return FALSE; - - loaded_ok = TRUE; - } - - return loaded_ok; -} - -/* - AccessPmClipboard: - Purpose: perform all necessary PM stuff and open clipboard for access; - Return : TRUE on success, FALSE on error; - Note : on error, clipboard is released automatically. - - LeavePmClipboard: - Purpose: releases previously opened clipboard and clear all PM stuff - Return : none - */ - -static struct { - PPIB ppib; - HAB hab; - HMQ hmq; - ULONG savedtype; - BOOL opened; -} PmInfo; - -static void LeavePmClipboard(void) { - - if (PmInfo.opened) - p_WinCloseClipbrd(PmInfo.hab); - if (PmInfo.hmq) - p_WinDestroyMsgQueue(PmInfo.hmq); - if (PmInfo.hab) - p_WinTerminate(PmInfo.hab); - PmInfo.ppib->pib_ultype = PmInfo.savedtype; -} - -static BOOL AccessPmClipboard(void) { - PTIB ptib; - - if (loadDLL() == FALSE) { - DosBeep(100, 1500); - return FALSE; - } - - memset(&PmInfo, 0, sizeof(PmInfo)); - - // mutate into PM application for clipboard (Win**) functions access - DosGetInfoBlocks(&ptib, &PmInfo.ppib); - PmInfo.savedtype = PmInfo.ppib->pib_ultype; - PmInfo.ppib->pib_ultype = PROG_PM; - - if ((PmInfo.hab = p_WinInitialize(0)) != NULLHANDLE) { - if ((PmInfo.hmq = p_WinCreateMsgQueue(PmInfo.hab, 0)) != NULLHANDLE) { - if (p_WinOpenClipbrd(PmInfo.hab) == TRUE) { - PmInfo.opened = TRUE; - } - } - } - if (PmInfo.opened != TRUE) { - LeavePmClipboard(); - DosBeep(100, 1500); - } - return PmInfo.opened; -} - -int GetClipText(ClipData *cd) { - int rc = -1; - char *text; - - cd->fLen = 0; - cd->fChar = 0; - - if (AccessPmClipboard() != TRUE) - return rc; - - if ((text = (char *) p_WinQueryClipbrdData(PmInfo.hab, CF_TEXT)) != 0) { - cd->fLen = strlen(text); - cd->fChar = strdup(text); - rc = 0; - } - - LeavePmClipboard(); - return rc; -} - -int PutClipText(ClipData *cd) { - ULONG len; - void *text; - int rc = -1; - - if (AccessPmClipboard() != TRUE) - return rc; - - p_WinEmptyClipbrd(PmInfo.hab); - len = cd->fLen; - - if (len) { - DosAllocSharedMem((void **)&text, - 0, - len + 1, - PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE); - strncpy((char *)text, cd->fChar, len + 1); - if (!p_WinSetClipbrdData(PmInfo.hab, (ULONG) text, CF_TEXT, CFI_POINTER)) - DosBeep(100, 1500); - else - rc = 0; - } - - LeavePmClipboard(); - return rc; -} diff --git a/src/clip_vio.cpp b/src/clip_vio.cpp deleted file mode 100644 index 49f0b41..0000000 --- a/src/clip_vio.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* clip_vio.cpp - * - * Copyright (c) 1994-1996, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -// OS/2 does not allow VIO programs to use the clipboard :-( - -#include "fte.h" -#include "clip.h" - -#define INCL_DOS -#include -#include -#include - -#define SEM_PREFIX "\\SEM32\\PMCLIPS\\" -#define MEM_PREFIX "\\SHAREMEM\\PMCLIPS\\" - -#define CMD_GET 1 -#define CMD_PUT 2 - -static HMTX hmtxSyn; -static HEV hevGet; -static HEV hevPut; -static HEV hevEnd; - -int GetClipText(ClipData *cd) { - int rc; - ULONG PostCount; - char *mem; - - rc = DosOpenMutexSem(SEM_PREFIX "CLIPSYN", &hmtxSyn); - if (rc != 0) return -1; - rc = DosOpenEventSem(SEM_PREFIX "CLIPGET", &hevGet); - if (rc != 0) return -1; -/* rc = DosOpenEventSem(SEM_PREFIX "CLIPPUT", &hevPut);*/ -/* if (rc != 0) return -1;*/ - rc = DosOpenEventSem(SEM_PREFIX "CLIPEND", &hevEnd); - if (rc != 0) return -1; - - DosRequestMutexSem(hmtxSyn, SEM_INDEFINITE_WAIT); - DosResetEventSem(hevEnd, &PostCount); - DosPostEventSem(hevGet); - DosWaitEventSem(hevEnd, SEM_INDEFINITE_WAIT); - if (0 == DosGetNamedSharedMem((void **)&mem, MEM_PREFIX "CLIPDATA", PAG_READ | PAG_WRITE)) { - cd->fLen = *(ULONG*)mem; - cd->fChar = strdup(mem + 4); - DosFreeMem(mem); - } else { - cd->fLen = 0; - cd->fChar = 0; - } - DosPostEventSem(hevGet); - DosReleaseMutexSem(hmtxSyn); -/* DosCloseEventSem(hevPut);*/ - DosCloseEventSem(hevGet); - DosCloseEventSem(hevEnd); - DosCloseMutexSem(hmtxSyn); - return 0; -} - -int PutClipText(ClipData *cd) { - int rc; - ULONG PostCount; - char *mem; - - rc = DosOpenMutexSem(SEM_PREFIX "CLIPSYN", &hmtxSyn); - if (rc != 0) return -1; -/* rc = DosOpenEventSem(SEM_PREFIX "CLIPGET", &hevGet);*/ -/* if (rc != 0) return -1;*/ - rc = DosOpenEventSem(SEM_PREFIX "CLIPPUT", &hevPut); - if (rc != 0) return -1; - rc = DosOpenEventSem(SEM_PREFIX "CLIPEND", &hevEnd); - if (rc != 0) return -1; - - DosRequestMutexSem(hmtxSyn, SEM_INDEFINITE_WAIT); - DosResetEventSem(hevEnd, &PostCount); - if (0 == DosAllocSharedMem((void **)&mem, - MEM_PREFIX "CLIPDATA", - cd->fLen + 5, - PAG_COMMIT | PAG_READ | PAG_WRITE)) - { - ULONG L = cd->fLen; - memcpy((void *)mem, (void *)&L, 4); - strcpy(mem + 4, cd->fChar); - } - DosPostEventSem(hevPut); - DosWaitEventSem(hevEnd, SEM_INDEFINITE_WAIT); - DosPostEventSem(hevPut); - DosReleaseMutexSem(hmtxSyn); - DosCloseEventSem(hevPut); -/* DosCloseEventSem(hevGet); */ - DosCloseEventSem(hevEnd); - DosCloseMutexSem(hmtxSyn); - if (mem) - DosFreeMem(mem); - return 0; - -} diff --git a/src/clip_x11.cpp b/src/clip_x11.cpp deleted file mode 100644 index 24fceac..0000000 --- a/src/clip_x11.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* clip_x11.cpp - * - * Copyright (c) 1994-1996, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -#include "fte.h" - -int GetXSelection(int *len, char **data); -int SetXSelection(int len, char *data); - -int GetPMClip() { - char *data; - int len; - int i,j, l, dx; - EPoint P; - - if (GetXSelection(&len, &data) == 0) { - SSBuffer->Clear(); - j = 0; - l = 0; - - for (i = 0; i < len; i++) { - if (data[i] == '\n') { - SSBuffer->AssertLine(l); - P.Col = 0; P.Row = l++; - dx = 0; - if ((i > 0) && (data[i-1] == '\r')) dx++; - SSBuffer->InsertLine(P, i - j - dx, data + j); - j = i + 1; - } - } - if (j < len) { // remainder - i = len; - SSBuffer->AssertLine(l); - P.Col = 0; P.Row = l++; - dx = 0; - if ((i > 0) && (data[i-1] == '\r')) dx++; - SSBuffer->InsText(P.Row, P.Col, i - j - dx, data + j); - j = i + 1; - } - free(data); - return 1; - } - return 0; -} - -int PutPMClip() { - PELine L; - char *p = NULL; - int rc = 0; - int l = 0; - - for (int i = 0; i < SSBuffer->RCount; i++) { - L = SSBuffer->RLine(i); - char *n = (char *)realloc(p, l + L->Count + 1); - if (n != NULL) { - for(int j = 0; j < L->Count; j++) { - if ((j < (L->Count - 1)) && (L->Chars[j + 1] == '\b')) - j++; - else - n[l++] = L->Chars[j]; - } - if (i < SSBuffer->RCount - 1) - n[l++] = '\n'; - else - n[l] = 0; - } else - break; - p = n; // if p already contains some address it will be freed - } - - if (p != NULL) { - // remove some 'UNWANTED' characters - sequence XX 0x08 YY -> YY - // this makes usable cut&paste from manpages - rc = (SetXSelection(l, p) == 0); - free(p); - } - return (rc)?1:0; -} diff --git a/src/clipprog.cpp b/src/clipprog.cpp deleted file mode 100644 index 7109eae..0000000 --- a/src/clipprog.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* clipprog.cpp - * - * Copyright (c) 1994-1996, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - - -#define INCL_DOS -#define INCL_PM -#include -#include -#include -#include -#include - -#define SEM_PREFIX "\\SEM32\\PMCLIPS\\" -#define MEM_PREFIX "\\SHAREMEM\\PMCLIPS\\" - -#define CMD_GET 1 -#define CMD_PUT 2 - -HAB hab; -HMQ hmq; -QMSG qmsg; -HMTX hmtxSyn; -HEV hevGet; -HEV hevPut; -HEV hevEnd; -HMUX hmuxWait; - -void clipsrv(void *foo) { - HAB hab; - HMQ hmq; - ULONG Cmd; - ULONG len; - char *text; - void *shmem = "the text"; - - hab = NULLHANDLE; - - if ((WinOpenClipbrd(hab) == TRUE) && - ((text = (char *) WinQueryClipbrdData(hab, CF_TEXT)) != 0)) - { - DosGetSharedMem(text, PAG_READ); - len = strlen(text); - puts(text); - } - WinCloseClipbrd(hab); - - len = strlen(shmem); - if (len) { - DosAllocSharedMem((void **)&text, - 0, - len + 1, - PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE | OBJ_GETTABLE); - strcpy(text, shmem); - } - - if (WinOpenClipbrd(hab) == TRUE) { - if (!WinSetClipbrdData(hab, (ULONG) text, CF_TEXT, CFI_POINTER)) - DosBeep(100, 1500); - WinCloseClipbrd(hab); - } -} - -int main() { - clipsrv(NULL); - return 0; -} - diff --git a/src/clipserv.cpp b/src/clipserv.cpp deleted file mode 100644 index f16fbae..0000000 --- a/src/clipserv.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* clipserv.cpp - * - * Copyright (c) 1994-1996, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -#define INCL_DOS -#define INCL_PM -#include -#include -#include -#include -#include -#include "sysdep.h" - -#define SEM_PREFIX "\\SEM32\\PMCLIPS\\" -#define MEM_PREFIX "\\SHAREMEM\\PMCLIPS\\" - -#define CMD_GET 1 -#define CMD_PUT 2 - -HAB hab; -HMQ hmq; -QMSG qmsg; -HMTX hmtxSyn; -HEV hevGet; -HEV hevPut; -HEV hevEnd; -HMUX hmuxWait; - -void _LNK_CONV clipsrv(void *foo) { - HAB hab; - HMQ hmq; - - hab = WinInitialize(0); - hmq = WinCreateMsgQueue(hab, 0); - - while (1) { - ULONG ulPostCount; - ULONG Cmd; - ULONG len; - char *text; - void *shmem; - - WinWaitMuxWaitSem(hmuxWait, SEM_INDEFINITE_WAIT, &Cmd); - switch (Cmd) { - case CMD_GET: - DosResetEventSem(hevGet, &ulPostCount); - - shmem = 0; - if ((WinOpenClipbrd(hab) == TRUE) && - ((text = (char *) WinQueryClipbrdData(hab, CF_TEXT)) != 0)) - { - len = strlen(text); - puts(text); - if (0 == DosAllocSharedMem(&shmem, - MEM_PREFIX "CLIPDATA", - len + 5, - PAG_COMMIT | PAG_WRITE | PAG_READ)) - { - memcpy(shmem, (void *)&len, 4); - memcpy((void *)(((char *)shmem) + sizeof(ULONG)), text, len + 1); - } else { - DosBeep(200, 500); - } - } else { - /*DosBeep(100, 1500);*/ - len = 0; - if (0 == DosAllocSharedMem(&shmem, - MEM_PREFIX "CLIPDATA", - 4, - PAG_COMMIT | PAG_WRITE | PAG_READ)) - { - memcpy(shmem, (void *)&len, 4); - } - } - WinCloseClipbrd(hab); - DosPostEventSem(hevEnd); - DosWaitEventSem(hevGet, SEM_INDEFINITE_WAIT); - DosResetEventSem(hevGet, &ulPostCount); - if (shmem) DosFreeMem(shmem); - break; - - case CMD_PUT: - DosResetEventSem(hevPut, &ulPostCount); - - if (0 == DosGetNamedSharedMem(&shmem, - MEM_PREFIX "CLIPDATA", - PAG_READ | PAG_WRITE)) - { - if (WinOpenClipbrd(hab) == TRUE) { - WinEmptyClipbrd(hab); - len = strlen((char *)shmem + 4); - if (len) { - DosAllocSharedMem((void **)&text, - 0, - len + 1, - PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE); - strcpy(text, ((char *)shmem) + 4); - if (!WinSetClipbrdData(hab, (ULONG) text, CF_TEXT, CFI_POINTER)) - DosBeep(100, 1500); - - } - WinCloseClipbrd(hab); - } else { - DosBeep(1500, 3500); - } - } else { - DosBeep(500, 7500); - } - DosPostEventSem(hevEnd); - DosWaitEventSem(hevPut, SEM_INDEFINITE_WAIT); - DosResetEventSem(hevPut, &ulPostCount); - if (shmem) DosFreeMem(shmem); - break; - } - } - WinDestroyMsgQueue(hmq); - WinTerminate(hab); -} - -int main() { - SEMRECORD sem[2]; - int rc; - - rc = DosCreateMutexSem(SEM_PREFIX "CLIPSYN", - &hmtxSyn, - 0, - 0); - if (rc != 0) return 1; - puts("CLIPSYN"); - - rc = DosCreateEventSem(SEM_PREFIX "CLIPEND", - &hevEnd, - 0, - 0); - if (rc != 0) return 1; - puts("CLIPEND"); - - rc = DosCreateEventSem(SEM_PREFIX "CLIPGET", - &hevGet, - 0, - 0); - if (rc != 0) return 1; - puts("CLIPGET"); - - rc = DosCreateEventSem(SEM_PREFIX "CLIPPUT", - &hevPut, - 0, - 0); - if (rc != 0) return 1; - puts("CLIPPUT"); - - sem[0].hsemCur = (PULONG) hevGet; - sem[0].ulUser = CMD_GET; - sem[1].hsemCur = (PULONG) hevPut; - sem[1].ulUser = CMD_PUT; - - rc = DosCreateMuxWaitSem(0, - &hmuxWait, - 2, - sem, - DCMW_WAIT_ANY); - if (rc != 0) return 1; - puts("CLIPMUX"); - - hab = WinInitialize(0); - - hmq = WinCreateMsgQueue(hab, 0); -#if defined(__EMX__) || defined(__TOS_OS2__) - _beginthread(clipsrv, NULL, 8192, 0); -#else - _beginthread(clipsrv, 8192, 0); -#endif - while (WinGetMsg (hab, &qmsg, 0, 0, 0)) - WinDispatchMsg (hab, &qmsg); - - - WinDestroyMsgQueue(hmq); - WinTerminate(hab); - return 0; -} diff --git a/src/clipserv.def b/src/clipserv.def deleted file mode 100644 index 23ae27a..0000000 --- a/src/clipserv.def +++ /dev/null @@ -1,3 +0,0 @@ -NAME clipserv WINDOWAPI -DESCRIPTION 'FTE Clipboard access server for VIO' -STACKSIZE 49152 diff --git a/src/cliputil.cpp b/src/cliputil.cpp deleted file mode 100644 index b05ca07..0000000 --- a/src/cliputil.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* cliputil.cpp - * - * Copyright (c) 1994-1996, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -#include "clip.h" -#include -#include -#include - -#define MAXCLIPTEXT 256 * 1024 /* just for demo */ - -char buffer[MAXCLIPTEXT]; - -int main(int argc, char **argv) { - ClipData cd; - int i; - - if ((argc == 2) && (strcmp(argv[1], "-s") == 0)) { - cd.fLen = fread(buffer, 1, MAXCLIPTEXT, stdin); - cd.fChar = buffer; - if (PutClipText(&cd) == -1) { - fprintf(stderr, "Coult not set clipboard text\n"); - return 1; - } - } else if (argc == 1) { - if (GetClipText(&cd) == 0) { - if ((cd.fLen != 0) && cd.fChar) { - printf("%s", cd.fChar); - } - } else { - fprintf(stderr, "Could not get clipboard text\n"); - return 1; - } - } else { - fprintf(stderr, - "Usage: %s {-s}\n" - "\n" - "Examples:\n" - " cliputil | more\n" - " dir | cliputil -s\n", - argv[0]); - return 1; - } - return 0; -} diff --git a/src/cliputil.def b/src/cliputil.def deleted file mode 100644 index b8e55df..0000000 --- a/src/cliputil.def +++ /dev/null @@ -1,3 +0,0 @@ -NAME ClipUtil WINDOWCOMPAT -DESCRIPTION 'Clipboard Utility - get/put clipboard text from command line' -STACKSIZE 49152 diff --git a/src/compkeys.cpp b/src/compkeys.cpp deleted file mode 100644 index 052a3e1..0000000 --- a/src/compkeys.cpp +++ /dev/null @@ -1,457 +0,0 @@ -/* - * compkeys.cpp - * - * Copyright (c) 1998 by István Váradi - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -#include -#include -#include -#include - -#include "console.h" -#include "conkbd.h" - -#define FTESL_KBDCTRL(x) ( x-'a'+ 1) - -static unsigned get_linux_keycode(TKeyCode kcode) -{ - static unsigned lnxkeycodes[] = { - /* 32 */ - 57, 2, 40, 4, 5, 6, 8, 40, - - /* 40 */ - 10, 11, 9, 13, 51, 12, 52, 53, - - /* 48 */ - 11, 2, 3, 4, 5, 6, 7, 8, - - /* 56 */ - 9 , 10, 39, 39, 51, 13, 52, 53, - - /* 64 */ - 3 , 30, 48, 46, 32, 18, 33, 34, - - /* 72 */ - 35, 23, 36, 37, 38, 50, 49, 24, - - /* 80 */ - 25, 16, 19, 31, 20, 22, 47, 17, - - /* 88 */ - 45, 21, 44, 26, 86, 27, 7, 12, - - /* 96 */ - 43, 30, 48, 46, 32, 18, 33, 34, - - /* 104 */ - 35, 23, 36, 37, 38, 50, 49, 24, - - /* 112 */ - 25, 16, 19, 31, 20, 22, 47, 17, - - /* 120 */ - 45, 21, 44, 26, 86, 27, 43, 0, - }; - - TKeyCode key = keyCode(kcode)|(kcode&kfGray); - - switch(key) { - case kbF1: - case kbF2: - case kbF3: - case kbF4: - case kbF5: - case kbF6: - case kbF7: - case kbF8: - case kbF9: - case kbF10: - return 59+key-kbF1; - break; - case kbF11: - return 87; - break; - case kbF12: - return 88; - break; - case kbHome: - return 102; - break; - case kbEnd: - return 107; - break; - case kbPgUp: - return 104; - break; - case kbPgDn: - return 109; - break; - case kbIns: - return 110; - break; - case kbDel: - return 111; - break; - case kbUp: - return 103; - break; - case kbDown: - return 108; - break; - case kbLeft: - return 105; - break; - case kbRight: - return 106; - break; - case kbEnter: - return 28; - break; - case kbEsc: - return 1; - break; - case kbBackSp: - return 14; - break; - case kbSpace: - return 57; - break; - case kbTab: - return 15; - break; - case kbCenter: - return 76; - break; - case kfGray|'/': - return 98; - break; - case kfGray|'*': - return 55; - break; - case kfGray|'+': - return 78; - break; - case kfGray|'-': - return 74; - break; - case kfGray|kbEnter: - return 96; - break; - case kfGray|'.': - return 83; - break; - case kfGray|'7': - case kfGray|kbHome: - return 71; - break; - case kfGray|'8': - case kfGray|kbUp: - return 72; - break; - case kfGray|'9': - case kfGray|kbPgUp: - return 73; - break; - case kfGray|'4': - case kfGray|kbLeft: - return 75; - break; - case kfGray|'5': - return 76; - break; - case kfGray|'6': - case kfGray|kbRight: - return 77; - break; - case kfGray|'1': - case kfGray|kbEnd: - return 79; - break; - case kfGray|'2': - case kfGray|kbDown: - return 80; - break; - case kfGray|'3': - case kfGray|kbPgDn: - return 81; - break; - default: - if (key<128 && key>32) return lnxkeycodes[key-32]; - else return 0; - } -} - -typedef struct keymapper -{ - TKeyCode kcode; - const char* kname; -} keymapper; - -static keymapper speckeymap[]={ - { kbHome, "Home" }, - { kbEnd, "End" }, - { kbPgUp, "PgUp" }, - { kbPgDn, "PgDn" }, - { kbIns, "Ins" }, - { kbDel, "Del" }, - { kbUp, "Up" }, - { kbDown, "Down" }, - { kbLeft, "Left" }, - { kbRight, "Right" }, - { kbEnter, "Enter" }, - { kbEsc, "Esc" }, - { kbBackSp, "BackSp" }, - { kbSpace, "Space" }, - { kbTab, "Tab" }, - { kbCenter, "Center" }, -}; - -TKeyCode ftesl_getkeycode(const char* key) -{ - TKeyCode kcode = 0; - - if ( (*key)=='\0') return 0; - - while (*(key+1)=='+') { - switch (*key) { - case 'A': - kcode|=kfAlt; break; - case 'C': - kcode|=kfCtrl; break; - case 'S': - kcode|=kfShift; break; - case 'G': - kcode|=kfGray; break; - default: - return 0; - break; - } - key+=2; - } - - if ( (*key)=='\0') return 0; - - if ( *(key+1)=='\0') { - kcode|=*(unsigned char *)key; - return kcode; - } - - for(unsigned i=0; i='1' && *key<='9' ) { - if ( *key == '1' && *(key+1)!='\0' ) { - key++; - switch (*key) { - case '1': - kcode|=kbF11; - break; - case '2': - kcode|=kbF12; - break; - default: - return 0; - break; - } - return kcode; - } - kcode|=kbF1+(*key-'1'); - return kcode; - } - } - - return 0; -} - -int ftesl_get_ctrlcode(TKeyCode key) -{ - TKeyCode kcode = keyCode(key); - - switch(kcode) { - case kbUp: - return FTESL_KBDCTRL('u'); - case kbDown: - return FTESL_KBDCTRL('d'); - case kbLeft: - return FTESL_KBDCTRL('l'); - case kbRight: - return FTESL_KBDCTRL('r'); - case kbCenter: - return FTESL_KBDCTRL('x'); - case kbHome: - return FTESL_KBDCTRL('b'); - case kbEnd: - return FTESL_KBDCTRL('e'); - case kbPgUp: - return FTESL_KBDCTRL('p'); - case kbPgDn: - return FTESL_KBDCTRL('n'); - case kbIns: - return FTESL_KBDCTRL('q'); - case kbDel: - return FTESL_KBDCTRL('z'); - case kbBackSp: - return FTESL_KBDCTRL('h'); - case kbTab: - return FTESL_KBDCTRL('i'); - case kbEnter: - return FTESL_KBDCTRL('m'); - } - if (kcode>=kbF1 && kcode<=kbF12) return FTESL_KBDCTRL('f'); - else return (int)kcode; - -} - - -int main(int argc, char* argv[]) -{ - FILE* fin; - FILE* fout; - char finname[255]; - char foutname[255]; - char linebuf[256]; - char* lptr; - char keyspecbuf[32]; - char* bufptr; - int err = 0; - unsigned linecnt = 0; - unsigned strcnt = 0; - //int opt; - - finname[0] = '\0'; - foutname[0] = '\0'; - - printf("Linux keymap compiler for SLang FTE, Copyright (c) 1998 by István Váradi\n\n"); - - if (argc<3) { - fprintf(stderr, "Usage: compkeys infile outfile\n\n"); - fprintf(stderr, " where:\n"); - fprintf(stderr, " infile: the file with the list of the keys\n"); - fprintf(stderr, " outfile: the name of the output keymap file\n"); - exit(-2); - } - - strcpy(finname, argv[1]); - strcpy(foutname, argv[2]); - - fin = fopen(finname, "rt"); - - if (fin==NULL) { - fprintf(stderr, "Can't open input file '%s' for reading.\n", finname); - return -1; - } - - fout = fopen(foutname, "wb"); - - if (fout==NULL) { - fprintf(stderr, "Can't open output file '%s' for writing.\n", foutname); - fclose(fin); - return -1; - } - - - printf("Compiling from '%s' into '%s'.\n", finname, foutname); - - fprintf(fout, "############################\n"); - fprintf(fout, "# Keytable to use with FTE #\n"); - fprintf(fout, "# generated by 'compkeys' #\n"); - fprintf(fout, "############################\n\n"); - - err = 0; - while(!err && fgets(linebuf, sizeof(linebuf), fin)==linebuf) { - linecnt++; - lptr = linebuf; - while(!err) { - while(*lptr!='\0' && strchr(" \t", *lptr)!=NULL) lptr++; - if (*lptr=='#' || *lptr=='\0' || *lptr=='\n') break; - - bufptr=keyspecbuf; - - while(*lptr!='\0' && strchr(" \t\n", *lptr)==NULL) - *(bufptr++)=*(lptr++); - *(bufptr++)='\0'; - - TKeyCode kcode = ftesl_getkeycode(keyspecbuf), kcode1; - - if (kcode==0) { - err = 2; - } else { - - fprintf(fout, "\n# %s\n", keyspecbuf); - if (kcode&kfShift) fprintf(fout, "shift "); - if (kcode&kfCtrl) fprintf(fout, "control "); - if (kcode&kfAlt) fprintf(fout, "alt "); - fprintf(fout, "keycode %3u = F%u\n", - get_linux_keycode(kcode), 100+strcnt); - fprintf(fout, "string F%u = \"\\033", 100+strcnt); - if (kcode&kfShift) fprintf(fout, "\\023"); - if (kcode&kfCtrl) fprintf(fout, "\\003"); - if (kcode&kfAlt) fprintf(fout, "\\001"); - - int ccode = ftesl_get_ctrlcode(kcode); - fprintf(fout, "\\%03o", ccode); - - - if (ccode==FTESL_KBDCTRL('f')) { - kcode1 = keyCode(kcode); - switch(kcode1) { - case kbF1: - case kbF2: - case kbF3: - case kbF4: - case kbF5: - case kbF6: - case kbF7: - case kbF8: - case kbF9: - fprintf(fout, "%c", (int)'1'+int(kcode1-kbF1)); - break; - case kbF10: - fprintf(fout, "0"); break; - case kbF11: - fprintf(fout, "a"); break; - case kbF12: - fprintf(fout, "b"); break; - } - } - - fprintf(fout, "\"\n"); - strcnt++; - } - } - } - - fclose(fout); - fclose(fin); - - if (err) { - fprintf(stderr, "line %u: ", linecnt); - switch (err) { - case 1: - fprintf(stderr, "syntax error"); - break; - case 2: - fprintf(stderr, "invalid key specification: '%s'", - keyspecbuf); - } - fprintf(stderr, "\n"); - remove(foutname); - } else { - printf("\nDone.\n"); - } - - if (err) return -1; else return 0; -} - - \ No newline at end of file diff --git a/src/con_i18n.cpp b/src/con_i18n.cpp deleted file mode 100644 index 548cfe8..0000000 --- a/src/con_i18n.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/* - * con_i18n.cpp - * - * Copyright (c) 1998, Zdenek Kabelac - * - * I18N support by kabi@fi.muni.cz - * - * written as plain 'C' module and might be used - * in other programs to implement I18N support - */ - - -#include -#include -#include -#include -#include -#include -#include - -#include "con_i18n.h" - -#define KEYMASK 0xff -#define KEYBYTEMAX 0xf00 - -#ifdef USE_HARD_REMAP -/* - * This part is used when your Xserver doesn't work well with XKB extension - */ - - -/* Keyboard definition file - currently only Czech national keyboard - * write your own keyboard for your language - * And remember - this is supposed to be used only if your Xserver - * is not supporting keyboard extension - */ -#include "con_ikcz.h" - -/* - * Quite a complex function to convert normal keys - * to dead-keys and remapped keys - */ -static int I18NKeyAnalyze(XKeyEvent * keyEvent, KeySym * key, /*fold00*/ - char *keyName, int nbytes) -{ - static long prev_state = 0, local_switch = 0, - keypos = 0, last_keypos = 0, remap = 0; - long i; - struct keyboardRec *kbdActual; - - /* Find the state of keyboard - * Check for different ISO group or modifier 5 - * So to activate remaping, you need to press at least - * ScrollLock which is usually mapped as modifier 5 - */ - i = ((keyEvent->state | local_switch) & 0xFFA0); - - if (i != prev_state) { - /* reset table position */ - last_keypos = keypos = 0; - prev_state = i; - } - - if (keyEvent->type == KeyPress) { - if (i && ((*key == XK_Pause) || (*key == XK_F21))) { - remap = !remap; - return 0; - } else if (*key == XK_F23) { - local_switch ^= (1UL<< 12); - return 0; - } - } - /* - * Check for already remapped ISO8859-X keys - * this should not normaly happen :-) - * as we need to use this hack - */ - - if ((*key > KEYMASK) && (*key < KEYBYTEMAX) || (*key > 0xffffff00)) { - *key &= KEYMASK; - keyName[0] = (char) *key; - return 1; - } - /* Select keyboard map */ - if (!i) - kbdActual = nationalKey[0]; - else if (!remap) - kbdActual = nationalKey[1]; - else - kbdActual = nationalKey[2]; - - if (keyEvent->type == KeyPress) { - long i = last_keypos; - - /* - * Search for DeadKey -> do loop over all tables. - * - * Note: We can define ONE DeadKey and use - * it for several tables sequentially - */ - for (;;) { - i++; - if ((kbdActual[0].tab == NULL) || kbdActual[i].tab == NULL) { - i = 0; - if (kbdActual[i].tab == NULL) { - /* Looks like empty table -> IGNORE */ - keypos = i; - return nbytes; - } - } - if (i == last_keypos) - break; - - if (kbdActual[i].deadkey == *key) { - keypos = kbdActual[i].next; - /* Found DeadKey -> delete it - * and mark actual position for next search */ - last_keypos = i; - keyName[0] = *key = 0; - return 0; - } - } - } else if (keypos) - return 0; /* ignore key release */ - - /* Now we know it is not a DeadKey and we - * are in selected remaping keyboard table */ - - /* printf("** key:%5d\tstatus:0x%x\n", *key, prev_state); */ - if (*key < KEYBYTEMAX) { - /* - * this is selected constant and will change when - * this editor will be able to write in japan :-) - */ - int i = 0; - - /* remaping only real keys */ - while (kbdActual[keypos].tab[i].key_english != 0) { - if (*key == kbdActual[keypos].tab[i].key_english) { - *key = kbdActual[keypos].tab[i].key_remap; - break; - } - i++; - } - last_keypos = keypos = kbdActual[keypos].next; - /* printf("** remap: %3d %3d\n", keypos, *key); */ - keyName[0] = *key && KEYMASK; - return 1; - } - return 0; -} - /*FOLD00*/ -#else - -/********************************************* - * * - * Standart methods for reading Keyboard * - * * - *********************************************/ - -/* ISO-8859-2 key-change - - * All these functions are for keyboard reading. - * Correct displaing of this text is another thing, - * but as I only need ISO-8859 encoding support, - * I don't care about this (for now). - */ -static int I18NKeyAnalyze(XKeyEvent * keyEvent, KeySym * key, /*fold00*/ - char *keyName, int nbytes) -{ - KeySym t = (unsigned char) keyName[0]; - - /* - * ISO-8859-2 is using some characters from 8859-1 and - * rest of them is located between 0x100 - 0x200 in 'X' so - * with ISO-8859-2 font we'll remap them down bellow < 0x100 - * This is mostly true for all Latin-X alphas, just - * special font to display them correctly is needed. - * This jobs does Xserver - and keysymbol is returned - * in the 1st. byte of keyName string. - */ - if ((nbytes == 1) && *key < KEYBYTEMAX) - *key = t; -#ifdef USE_HACK_FOR_BAD_XSERVER - /* - * this is really hack - but some Xservers are somewhat - * strange, so we remap character manually - */ - else if (!nbytes && (*key > KEYMASK) && (*key < KEYBYTEMAX)) { - *key &= KEYMASK; - keyName[0] = *key & KEYMASK; - nbytes = 1; - } -#endif - return nbytes; -} - /*FOLD00*/ -#endif - -/* - * Initialize I18N functions - took me hours to - * figure out how this works even though it was - * cut & pasted from 'xterm' sources, but as 'xterm' - * is using Xt Toolkit some things have to be made - * different - */ -XIC I18NInit(Display * display, Window win, unsigned long *mask) /*fold00*/ -{ - XIC xic = (XIC) NULL; -#if XlibSpecificationRelease >= 6 - XIM xim = (XIM) NULL; - XIMStyles *xim_styles; - XIMStyle input_style = 0; - char *s, tmp[256]; - int found = False; - - *mask = 0; - - /* Locale setting taken from XtSetLanguageProc */ - if (!(s = setlocale(LC_ALL, ""))) - fprintf(stderr, "I18N warning: Locale not supported by C library, " - "locale unchanged!\n"); - - if (!XSupportsLocale()) { - fprintf(stderr, "I18N warning: Locale not supported by Xlib, " - "locale set to C!\n"); - s = setlocale(LC_ALL, "C"); - } - if (!XSetLocaleModifiers("")) - fprintf(stderr, "I18N warning: X locale modifiers not supported, " - "using default\n"); - - xim = XOpenIM(display, NULL, NULL, NULL); - if (xim == NULL) { - // there are languages without Input Methods ???? - fprintf(stderr, "I18N warning: Input method not specified\n"); - return NULL; - } - - if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL) - || xim_styles == NULL) { - fprintf(stderr, "I18N error: Input method doesn't support any style\n"); - XCloseIM(xim); - return NULL; - } - - /* - * This is some kind of debugging message to inform user - * that something is wrong with his system - */ - if (s != NULL && (strstr(s, XLocaleOfIM(xim)) == NULL)) - fprintf(stderr, "I18N warning: System locale: \"%s\" differs from " - "IM locale: \"%s\"...\n", s, XLocaleOfIM(xim)); - - /* - * This part is cut&paste from other sources - * There is no reason to do it this way, because - * the only input style currently supported is Root - * but for the future extension I'll leave it here - */ - - strcpy(tmp, XIM_INPUT_STYLE); - for (s = tmp; s && !found;) { - char *ns, *end; - int i; - - while ((*s != 0) && isspace(*s)) - s++; - - if (*s == 0) - break; - - if ((ns = end = strchr(s, ',')) != 0) - ns++; - else - end = s + strlen(s); - - while (isspace(*end)) - end--; - *end = '\0'; - - if (!strcmp(s, "OverTheSpot")) - input_style = (XIMPreeditPosition | XIMStatusArea); - else if (!strcmp(s, "OffTheSpot")) - input_style = (XIMPreeditArea | XIMStatusArea); - else if (!strcmp(s, "Root")) - input_style = (XIMPreeditNothing | XIMStatusNothing); - - for (i = 0; (unsigned short) i < xim_styles->count_styles; i++) - if (input_style == xim_styles->supported_styles[i]) { - found = True; - break; - } - s = ns; - } - XFree(xim_styles); - - if (!found) { - fprintf(stderr, "I18N error: Input method doesn't support my " - "preedit type\n"); - XCloseIM(xim); - return NULL; - } - /* This program only understand the Root preedit_style yet */ - if (input_style != (XIMPreeditNothing | XIMStatusNothing)) { - fprintf(stderr, "I18N error: This program only supports the " - "'Root' preedit type\n"); - XCloseIM(xim); - return NULL; - } - xic = XCreateIC(xim, XNInputStyle, input_style, - XNClientWindow, win, - XNFocusWindow, win, - NULL); - if (xic == NULL) { - fprintf(stderr, "I18N error: Failed to create input context\n"); - XCloseIM(xim); - } else if (XGetICValues(xic, XNFilterEvents, mask, NULL)) - fprintf(stderr, "I18N error: Can't get Event Mask\n"); -#else - *mask = 0; -#endif - return xic; -} - /*FOLD00*/ - -void I18NFocusIn(XIC xic) /*fold00*/ -{ -#if XlibSpecificationRelease >= 6 - if (xic != NULL) - XSetICFocus(xic); -#endif -} - /*FOLD00*/ - -void I18NFocusOut(XIC xic) /*fold00*/ -{ -#if XlibSpecificationRelease >= 6 - if (xic != NULL) - XUnsetICFocus(xic); -#endif -} - /*FOLD00*/ - -/* - * Lookup correct keysymbol from keymap event - */ -int I18NLookupString(XKeyEvent * keyEvent, char *keyName, int keySize, /*FOLD00*/ - KeySym * key, XIC xic) -{ - static int showKeys = 0; - int nbytes = 0; - -#if XlibSpecificationRelease >= 6 - if (xic != NULL) { - if (keyEvent->type == KeyPress) { - Status status_return; - - /* No KeyRelease events here ! */ -#if 1 - nbytes = XmbLookupString(xic, keyEvent, keyName, keySize, - key, &status_return); -#else - wchar_t wk; - nbytes = XwcLookupString(xic, keyEvent, &wk, 1, key, &status_return); - printf("code=%0X\n", wk); - keySize = 1; - keyName[0] = wk & 0xFF; -#endif - } - } else -#endif - do { - static XComposeStatus compose_status = { NULL, 0 }; - nbytes = XLookupString(keyEvent, keyName, keySize, - key, &compose_status); - } while (0); - - - if (showKeys) { - fprintf(stderr, "Key: 0x%04lx '%s'\tKeyEventState:0x%x\t", - *key, XKeysymToString(*key), keyEvent->state); - if (nbytes && isprint(keyName[0])) { - keyName[nbytes] = 0; - fprintf(stderr, "String:'%s' Size:%2d ", keyName, nbytes); - } - fputs("\n", stderr); - } - if (((*key == XK_F1) || (*key == XK_F11)) - && ((keyEvent->state & (ShiftMask | ControlMask)) - == (ShiftMask | ControlMask)) - && (keyEvent->type == KeyPress)) - showKeys = !showKeys; - - return I18NKeyAnalyze(keyEvent, key, keyName, nbytes); -} - /*FOLD00*/ diff --git a/src/con_i18n.h b/src/con_i18n.h deleted file mode 100644 index cde3c2c..0000000 --- a/src/con_i18n.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __CONI18N_H__ -#define __CONI18N_H__ - -#include -#include - -/* - * For now the only supported input style is root !!! - * in future this should be read from resources - */ -#define XIM_INPUT_STYLE "Root" - -struct remapKey { - KeySym key_english; - KeySym key_remap; -}; - -struct keyboardRec { - struct remapKey *tab; - KeySym deadkey; - short next; -}; - -/* - * prototypes for I18N functions - */ -extern void I18NFocusOut(XIC); -extern void I18NFocusIn(XIC); -extern int I18NLookupString(XKeyEvent *, char *, int, KeySym *, XIC); -extern XIC I18NInit(Display *, Window, unsigned long *); - -#endif diff --git a/src/con_ikcz.h b/src/con_ikcz.h deleted file mode 100644 index a6964c9..0000000 --- a/src/con_ikcz.h +++ /dev/null @@ -1,390 +0,0 @@ -#ifndef __CON_IKCS_H -#define __CON_IKCS_H - -static struct remapKey keyboardStd[] = -{ - {0,} -}; - -static struct remapKey keyboardHalfCz[] = -{ - {XK_2, 0xff & 'ì'}, - {XK_3, 0xff & '¹'}, - {XK_4, 0xff & 'è'}, - {XK_5, 0xff & 'ø'}, - {XK_6, 0xff & '¾'}, - {XK_7, 0xff & 'ý'}, - {XK_8, 0xff & 'á'}, - {XK_9, 0xff & 'í'}, - {XK_0, 0xff & 'é'}, - {0,} -}; - -static struct remapKey keyboardFullCz[] = -{ - {XK_1, 0xff & '+'}, - {XK_exclam, XK_1}, - {XK_2, 0xff & 'ì'}, - {XK_at, XK_2}, - {XK_3, 0xff & '¹'}, - {XK_numbersign, XK_3}, - {XK_4, 0xff & 'è'}, - {XK_dollar, XK_4}, - {XK_5, 0xff & 'ø'}, - {XK_percent, XK_5}, - {XK_6, 0xff & '¾'}, - {XK_asciicircum, XK_6}, - {XK_7, 0xff & 'ý'}, - {XK_ampersand, XK_7}, - {XK_8, 0xff & 'á'}, - {XK_asterisk, XK_8}, - {XK_9, 0xff & 'í'}, - {XK_parenleft, XK_9}, - {XK_0, 0xff & 'é'}, - {XK_parenright, XK_0}, - - {XK_minus, XK_equal}, - {XK_underscore, XK_percent}, - - {XK_bracketleft, 0xff & 'ú'}, - {XK_braceleft, 0xff & '/'}, - {XK_bracketright, 0xff & ')'}, - {XK_braceright, 0xff & '('}, - - {XK_semicolon, 0xff & 'ù'}, - {XK_apostrophe, 0xff & '§'}, - {XK_colon, 0xff & '"'}, - {XK_quotedbl, 0xff & '!'}, - - {XK_comma, 0xff & ','}, - {XK_less, 0xff & '?'}, - {XK_period, 0xff & '.'}, - {XK_greater, 0xff & ':'}, - {XK_question, 0xff & '_'}, - {XK_slash, 0xff & '-'}, - - {0,} -}; - -static struct remapKey keyboardAcute[] = -{ - {XK_w, 0xff & 'ì'}, - {XK_W, 0xff & 'Ì'}, - {XK_e, 0xff & 'é'}, - {XK_E, 0xff & 'É'}, - {XK_r, 0xff & 'à'}, - {XK_R, 0xff & 'À'}, - {XK_t, 0xff & '»'}, - {XK_T, 0xff & '«'}, - {XK_y, 0xff & 'ý'}, - {XK_Y, 0xff & 'Ý'}, - {XK_u, 0xff & 'ú'}, - {XK_U, 0xff & 'Ú'}, - {XK_i, 0xff & 'í'}, - {XK_I, 0xff & 'Í'}, - {XK_o, 0xff & 'ó'}, - {XK_O, 0xff & 'Ó'}, - {XK_p, 0xff & '§'}, - {XK_P, 0xff & '§'}, - - {XK_a, 0xff & 'á'}, - {XK_A, 0xff & 'Á'}, - {XK_s, 0xff & '¶'}, - {XK_S, 0xff & '¦'}, - {XK_d, 0xff & 'ï'}, - {XK_D, 0xff & 'Ï'}, - {XK_h, 0xff & 'þ'}, - {XK_H, 0xff & 'Þ'}, - {XK_l, 0xff & 'å'}, - {XK_L, 0xff & 'Å'}, - - {XK_z, 0xff & '¼'}, - {XK_Z, 0xff & '¬'}, - {XK_x, 0xff & '×'}, - {XK_X, 0xff & '×'}, - {XK_c, 0xff & 'æ'}, - {XK_C, 0xff & 'Æ'}, - {XK_b, 0xff & 'ß'}, - {XK_B, 0xff & 'ß'}, - {XK_n, 0xff & 'ñ'}, - {XK_N, 0xff & 'Ñ'}, - - {XK_equal, 0xff & '´'}, - - {0,} -}; - -static struct remapKey keyboardCaron[] = -{ - {XK_e, 0xff & 'ì'}, - {XK_E, 0xff & 'Ì'}, - {XK_r, 0xff & 'ø'}, - {XK_R, 0xff & 'Ø'}, - {XK_t, 0xff & '»'}, - {XK_T, 0xff & '«'}, - {XK_u, 0xff & 'ù'}, - {XK_U, 0xff & 'Ù'}, - {XK_i, 0xff & 'î'}, - {XK_I, 0xff & 'Î'}, - {XK_o, 0xff & 'ö'}, - {XK_O, 0xff & 'Ö'}, - - {XK_a, 0xff & 'ä'}, - {XK_A, 0xff & 'Ä'}, - {XK_s, 0xff & '¹'}, - {XK_S, 0xff & '©'}, - {XK_d, 0xff & 'ï'}, - {XK_D, 0xff & 'Ï'}, - {XK_l, 0xff & 'µ'}, - {XK_L, 0xff & '¥'}, - - {XK_z, 0xff & '¾'}, - {XK_Z, 0xff & '®'}, - {XK_x, 0xff & '¤'}, - {XK_X, 0xff & '¤'}, - {XK_c, 0xff & 'è'}, - {XK_C, 0xff & 'È'}, - {XK_n, 0xff & 'ò'}, - {XK_N, 0xff & 'Ò'}, - - {XK_plus, 0xff & '·'}, - {0,} -}; - -static struct remapKey keyboardFirst[] = -{ - {XK_w, 0xff & 'ì'}, - {XK_W, 0xff & 'Ì'}, - {XK_e, 0xff & 'é'}, - {XK_E, 0xff & 'É'}, - {XK_r, 0xff & 'ø'}, - {XK_R, 0xff & 'Ø'}, - {XK_t, 0xff & '»'}, - {XK_T, 0xff & '«'}, - {XK_y, 0xff & 'ý'}, - {XK_Y, 0xff & 'Ý'}, - {XK_u, 0xff & 'ú'}, - {XK_U, 0xff & 'Ú'}, - {XK_i, 0xff & 'í'}, - {XK_I, 0xff & 'Í'}, - {XK_o, 0xff & 'ó'}, - {XK_O, 0xff & 'Ó'}, - {XK_p, 0xff & '§'}, - {XK_P, 0xff & '§'}, - - {XK_a, 0xff & 'á'}, - {XK_A, 0xff & 'Á'}, - {XK_s, 0xff & '¹'}, - {XK_S, 0xff & '©'}, - {XK_d, 0xff & 'ï'}, - {XK_D, 0xff & 'Ï'}, - {XK_h, 0xff & 'þ'}, - {XK_H, 0xff & 'Þ'}, - {XK_l, 0xff & 'å'}, - {XK_L, 0xff & 'Å'}, - - {XK_z, 0xff & '¾'}, - {XK_Z, 0xff & '®'}, - {XK_x, 0xff & '×'}, - {XK_X, 0xff & '×'}, - {XK_c, 0xff & 'è'}, - {XK_C, 0xff & 'È'}, - {XK_b, 0xff & 'ß'}, - {XK_B, 0xff & 'ß'}, - {XK_n, 0xff & 'ò'}, - {XK_N, 0xff & 'Ò'}, - - {0,} -}; - -static struct remapKey keyboardSecond[] = -{ - {XK_equal, 0xff & '´'}, - {XK_plus, 0xff & '·'}, - - {XK_e, 0xff & 'ì'}, - {XK_E, 0xff & 'Ì'}, - {XK_r, 0xff & 'à'}, - {XK_R, 0xff & 'À'}, - {XK_t, 0xff & 'þ'}, - {XK_T, 0xff & 'Þ'}, - {XK_u, 0xff & 'ù'}, - {XK_U, 0xff & 'Ù'}, - {XK_i, 0xff & 'î'}, - {XK_I, 0xff & 'Î'}, - {XK_o, 0xff & 'ö'}, - {XK_O, 0xff & 'Ö'}, - - {XK_a, 0xff & 'ä'}, - {XK_A, 0xff & 'Ä'}, - {XK_s, 0xff & '¶'}, - {XK_S, 0xff & '¦'}, - {XK_d, 0xff & 'ð'}, - {XK_D, 0xff & 'Ð'}, - {XK_l, 0xff & 'µ'}, - {XK_L, 0xff & '¥'}, - - {XK_z, 0xff & '¼'}, - {XK_Z, 0xff & '¬'}, - {XK_x, 0xff & '¤'}, - {XK_X, 0xff & '¤'}, - {XK_c, 0xff & 'æ'}, - {XK_C, 0xff & 'Æ'}, - {XK_n, 0xff & 'ñ'}, - {XK_N, 0xff & 'Ñ'}, - - {0,} -}; - - - -static struct remapKey keyboardThird[] = -{ - {XK_a, 0xff & 'â'}, - {XK_A, 0xff & 'Â'}, - {XK_e, 0xff & 'ë'}, - {XK_E, 0xff & 'Ë'}, - {XK_u, 0xff & 'ü'}, - {XK_U, 0xff & 'Ü'}, - {XK_o, 0xff & 'ô'}, - {XK_O, 0xff & 'Ô'}, - - {XK_s, 0xff & 'ß'}, - {XK_S, 0xff & 'ß'}, - {XK_l, 0xff & '³'}, - {XK_L, 0xff & '£'}, - - {XK_z, 0xff & '¿'}, - {XK_Z, 0xff & '¯'}, - {XK_c, 0xff & 'ç'}, - {XK_C, 0xff & 'Ç'}, - - {0,} -}; - -static struct remapKey keyboardFourth[] = -{ - {XK_a, 0xff & 'ã'}, - {XK_A, 0xff & 'Ã'}, - {XK_e, 0xff & 'ê'}, - {XK_E, 0xff & 'Ê'}, - {XK_u, 0xff & 'û'}, - {XK_U, 0xff & 'Ü'}, - {XK_o, 0xff & 'õ'}, - {XK_O, 0xff & 'Õ'}, - - {XK_l, 0xff & '£'}, - {XK_L, 0xff & '£'}, - - {0,} -}; - -static struct remapKey keyboardFifth[] = -{ - {XK_a, 0xff & '±'}, - {XK_A, 0xff & '¡'}, - {XK_o, 0xff & '§'}, - {XK_O, 0xff & '§'}, - - {XK_l, 0xff & '|'}, - {XK_L, 0xff & '|'}, - - {0,} -}; - -#define KEYMAPS_MACRO \ - {keyboardAcute, 0, 0}, /* 1 */ \ - {keyboardCaron, 0, 0}, /* 2 */ \ - {keyboardFirst, 0, 0}, /* 3 */ \ - {keyboardSecond, 0, 0}, /* 4 */ \ - {keyboardThird, 0, 0}, /* 5 */ \ - {keyboardFourth, 0, 0}, /* 6 */ \ - {keyboardFifth, 0, 0}, /* 7 */ - -#ifdef XK_dead_acute -#define XKB_DEAD_KEYS \ - {keyboardStd, XK_dead_acute, 1}, \ - {keyboardStd, XK_dead_caron, 2}, \ - {keyboardStd, XK_dead_iota, 3}, \ - {keyboardStd, XK_dead_iota, 4}, \ - {keyboardStd, XK_dead_iota, 5}, \ - {keyboardStd, XK_dead_iota, 6}, \ - {keyboardStd, XK_dead_iota, 7}, \ - {keyboardStd, XK_dead_iota, 0}, - -#else -#define XKB_DEAD_KEYS -#endif - -#ifdef XK_F22 -#define F22_DEAD_KEYS \ - {keyboardStd, XK_F22, 3}, \ - {keyboardStd, XK_F22, 4}, \ - {keyboardStd, XK_F22, 5}, \ - {keyboardStd, XK_F22, 6}, \ - {keyboardStd, XK_F22, 7}, \ - {keyboardStd, XK_F22, 0}, -#else -#define F22_DEAD_KEYS -#endif - -#define KBD_MACRO \ - {keyboardStd, XK_Print, 3}, \ - {keyboardStd, XK_Print, 4}, \ - {keyboardStd, XK_Print, 5}, \ - {keyboardStd, XK_Print, 6}, \ - {keyboardStd, XK_Print, 7}, \ - {keyboardStd, XK_Print, 0}, \ - XKB_DEAD_KEYS \ - F22_DEAD_KEYS - - -static struct keyboardRec kbdStdRec[] = -{ - {keyboardStd, 0, 0}, /* 0 */ - - KEYMAPS_MACRO - - KBD_MACRO - - {NULL,} -}; - -static struct keyboardRec kbdHalfCzRec[] = -{ - {keyboardHalfCz, 0, 0}, /* 0 */ - - KEYMAPS_MACRO - - KBD_MACRO - - {NULL,} -}; - -static struct keyboardRec kbdFullCzRec[] = -{ - {keyboardFullCz, 0, 0}, /* 0 */ - - KEYMAPS_MACRO - - {keyboardStd, XK_equal, 1}, - {keyboardStd, XK_plus, 2}, - - KBD_MACRO - - {NULL,} -}; - -/* - * one standart keyboard and two national keyboards - * (for programmers and for writers) - */ -static struct keyboardRec *nationalKey[] = -{ - kbdStdRec, - kbdHalfCzRec, - kbdFullCzRec, - 0 -}; - -#endif diff --git a/src/con_linux.cpp b/src/con_linux.cpp deleted file mode 100644 index aded0eb..0000000 --- a/src/con_linux.cpp +++ /dev/null @@ -1,1205 +0,0 @@ -/* con_linux.cpp - * - * Copyright (c) 1994-1996, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -// If you're searching for portability it is not here ;-) - -#define USE_GPM //uncomment here to use GPM -#define USE_SCRNMAP // use USER translation table instead of direct mapping - // The translation table is assumed to be invertible (more or less). - // How do we get other translation tables from kernel, the USER one - // is null mapping by default (not very useful)? - -// PROBLEM: we use raw mode, and this disables the console -// switching (consoles cannot be switched when the editor is busy). -// probably needs to be fixed in the kernel (IMO kernel should -// switch consoles when raw mode is used, unless console is under -// VT_PROCESS control). Why does kernel trust user processes to do it? - -// FIX: caps lock is ignored (I haven't pressed it in years, except by mistake). -// FIX: access GPM clipboard. how? - -// ... some more comments below - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef USE_GPM -extern "C" { -#include -} -#endif - -#include "console.h" -#include "gui.h" - -#define MAX_PIPES 4 -//#define PIPE_BUFLEN 4096 - -typedef struct { - int used; - int id; - int fd; - int pid; - int stopped; - EModel *notify; -} GPipe; - -static GPipe Pipes[MAX_PIPES] = { - { 0 }, { 0 }, { 0 }, { 0 } -}; - -#define die(s) { printf("%s\n", s); exit(1); } while(0); - -unsigned int VideoCols = 80; -unsigned int VideoRows = 25; -unsigned int CursorX = 0; -unsigned int CursorY = 0; -int CursorVisible = 1; -int VtNum = -1; -static int VtFd = -1; -static int VcsFd = -1; -struct termios Save_termios; -struct kbdiacrs diacr_table; -#ifdef USE_GPM -int GpmFd = -1; -#endif -int LastMouseX = 0, LastMouseY = 0; -int WindowChanged = 0; -int drawPointer = 1; -int mouseDrawn = 0; -TCell MousePosCell; -#ifdef USE_SCRNMAP -static int noCharTrans = 0; - -static unsigned char toScreen[256]; -static unsigned char fromScreen[256]; -#endif - -#define MEM_PAGE_SIZE 4096 -#define VIDEO_SIZE (VideoCols * VideoRows * 2) -#define VIDEO_MAP_SIZE ((VIDEO_SIZE | (MEM_PAGE_SIZE - 1)) + 1) - -int GetKeyEvent(TEvent *Event); -int GetMouseEvent(TEvent *Event); - -void mouseShow() { -#ifdef USE_GPM - if (GpmFd != -1 && VcsFd != -1 && drawPointer && mouseDrawn == 0) { - int pos = (LastMouseX + LastMouseY * VideoCols) * 2 + 4; - lseek(VcsFd, pos, SEEK_SET); - read(VcsFd, &MousePosCell, 2); - TCell newCell = MousePosCell ^ 0x7700; // correct ? - lseek(VcsFd, pos, SEEK_SET); - write(VcsFd, &newCell, 2); - mouseDrawn = 1; - } -#endif -} - -void mouseHide() { -#ifdef USE_GPM - if (GpmFd != -1 && VcsFd != -1 && drawPointer && mouseDrawn == 1) { - int pos = (LastMouseX + LastMouseY * VideoCols) * 2 + 4; - lseek(VcsFd, pos, SEEK_SET); - write(VcsFd, &MousePosCell, 2); - mouseDrawn = 0; - } -#endif -} - -void SigWindowChanged(int arg) { - signal(SIGWINCH, SigWindowChanged); - WindowChanged = 1; -} - -static void Cleanup() { - ConDone(); -} - -static void Die(int) { - ConDone(); - exit(66); -} - -int ConInit(int XSize, int YSize) { - int tmp; - int mode; - struct termios newt; - //char ttyname[20]; - char vcsname[20]; -// struct vt_mode vtm; - //long free_tty; -// struct winsize ws; - struct stat stb; - unsigned char vc_data[4]; -#ifdef USE_GPM - Gpm_Connect conn; -#endif - - VtFd = 2; /* try stderr as output */ - if (isatty(VtFd) == 0) { - die("not a terminal."); - } - if (fstat(VtFd, &stb) != 0) { - perror("stat"); - die("stat failed"); - } - VtNum = MINOR(stb.st_rdev); - if (MAJOR(stb.st_rdev) != TTY_MAJOR) - die("Not running in a virtual console."); - if (ioctl(VtFd, KDGKBMODE, &mode) != 0) - die("failed to get kbdmode"); -#if 0 - if (mode != K_XLATE) { // X, etc... - sprintf(ttyname, "/dev/console"); - if ((VtFd = open(ttyname, O_RDWR)) == -1) - die("failed to open /dev/console"); - if (ioctl(VtFd, VT_OPENQRY, &free_tty) < 0 || free_tty == -1) - die("could not find a free tty\n"); - close(VtFd); - VtNum = free_tty; - sprintf(ttyname, "/dev/tty%d", VtNum); - if ((VtFd = open(ttyname, O_RDWR)) == -1) - die("could not open tty"); - } -#endif - sprintf(vcsname, "/dev/vcsa%d", VtNum); - - /* - * This is the _only_ place that we use our extra privs if any, - * If there is an error, we drop them prior to calling recovery - * functions, if we succeed we go back as well. - * - * Ben Collins - */ - extern uid_t effuid; - extern gid_t effgid; - - seteuid(effuid); - setegid(effgid); - VcsFd = open(vcsname, O_RDWR); - setuid(getuid()); - setgid(getgid()); - - if (VcsFd == -1) { - perror("open"); - die("failed to open /dev/vcsa*"); - } - if (read(VcsFd, &vc_data, 4) != 4) { - perror("read"); - die("failed to read from /dev/vcsa*"); - } - VideoRows = vc_data[0]; - VideoCols = vc_data[1]; - CursorX = vc_data[2]; - CursorY = vc_data[3]; - -#ifdef USE_SCRNMAP - if (ioctl(VtFd, GIO_SCRNMAP, &toScreen) == -1) - die("could not get screen character mapping!"); - - { - int c; - for (c = 0; c < 256; c++) - fromScreen[c] = 0; - for (c = 0; c < 256; c++) - fromScreen[toScreen[c]] = c; - } -#endif - - tmp = tcgetattr(VtFd, &Save_termios); - if (tmp) fprintf(stderr, "tcsetattr = %d\n", tmp); - tmp = tcgetattr(VtFd, &newt); - if (tmp) fprintf(stderr, "tcsetattr = %d\n", tmp); - - newt.c_lflag &= ~ (ICANON | ECHO | ISIG); - newt.c_iflag = 0; - newt.c_cc[VMIN] = 16; - newt.c_cc[VTIME] = 1; - tmp = tcsetattr(VtFd, TCSAFLUSH, &newt); - if (tmp) fprintf(stderr, "tcsetattr = %d\n", tmp); - - /* set keyboard to return MEDIUMRAW mode */ - if (ioctl(VtFd, KDSKBMODE, K_MEDIUMRAW) != 0) { - perror("Could not activate K_MEDIUMRAW mode"); - tmp = tcsetattr(VtFd, 0, &Save_termios); - die("could not activate medium raw mode\n"); - } - - /* get keyboard diacritics table */ - if (ioctl(VtFd, KDGKBDIACR, &diacr_table) != 0) { - perror("Could not get diacritics table"); - diacr_table.kb_cnt=0; - } - - signal(SIGWINCH, SigWindowChanged); - signal(SIGSEGV, Die); - signal(SIGBUS, Die); - signal(SIGIOT, Die); - signal(SIGQUIT, Die); - signal(SIGTERM, Die); - signal(SIGPIPE, SIG_IGN); - signal(SIGALRM, SIG_IGN); - signal(SIGHUP, Die); - atexit(Cleanup); - -#ifdef USE_GPM - conn.eventMask = (unsigned short)~0U; - conn.defaultMask = GPM_DRAG; - conn.minMod = 0; - conn.maxMod = (unsigned short)~0U; - - GpmFd = Gpm_Open(&conn, 0); - mouseShow(); -#endif - return 0; -} - -int ConDone() { - if (VtFd != -1) { - int tmp; - -#ifdef USE_GPM - if (GpmFd != -1) { - mouseHide(); - Gpm_Close(); - GpmFd = -1; - } -#endif - ioctl(VtFd, KDSKBMODE, K_XLATE); - tmp = tcsetattr(VtFd, 0, &Save_termios); - if (tmp) fprintf(stderr, "tcsetattr = %d\n", tmp); - } - return 0; -} - -int ConSuspend() { - int tmp; -#ifdef USE_GPM - mouseHide(); - Gpm_Close(); - GpmFd = -1; -#endif - ioctl(VtFd, KDSKBMODE, K_XLATE); - tmp = tcsetattr(VtFd, 0, &Save_termios); - if (tmp) fprintf(stderr, "tcsetattr = %d\n", tmp); - return 0; -} - -int ConContinue() { -#ifdef USE_GPM - Gpm_Connect conn; -#endif - struct termios newt; - int tmp; - - newt.c_lflag &= ~ (ICANON | ECHO | ISIG); - newt.c_iflag = 0; - newt.c_cc[VMIN] = 16; - newt.c_cc[VTIME] = 1; - tmp = tcsetattr(VtFd, TCSAFLUSH, &newt); - if (tmp) fprintf(stderr, "tcsetattr = %d\n", tmp); - - /* set keyboard to return MEDIUMRAW mode */ - if (ioctl(VtFd, KDSKBMODE, K_MEDIUMRAW) != 0) { - perror("ioctl KDSKBMODE"); - die("could not activate medium raw mode\n"); - } -#ifdef USE_GPM - conn.eventMask = (unsigned short)~0U; - conn.defaultMask = GPM_DRAG; - conn.minMod = 0; - conn.maxMod = (unsigned short)~0U; - - GpmFd = Gpm_Open(&conn, 0); - mouseShow(); -#endif - return 0; -} - -#ifdef USE_SCRNMAP -int conread(int fd, void *p, int len) { // len should be a multiple of 2 - char buf[512]; - char *c = (char *)p; - char *s = buf; - - if (noCharTrans || (len > 512)) { - return read(fd, p, len); - } else { - int rlen = read(fd, buf, len); - for (int n = 0; n < rlen; n += 2) { - *c++ = fromScreen[(unsigned char)*s++]; - *c++ = *s++; - } - return rlen; - } -} - -int conwrite(int fd, void *p, int len) { // len should be a multiple of 2 - char buf[512]; - char *s = (char *)p; - char *c = buf; - - if (noCharTrans || (len > 512)) { - return write(fd, p, len); - } else { - for (int n = 0; n < len; n += 2) { - *c++ = toScreen[(unsigned char)*s++]; - *c++ = *s++; - } - return write(fd, buf, len); - } -} -#else -#define conread(fd,b,len) read(fd,b,len) -#define conwrite(fd,b,len) write(fd,b,len) -#endif - -int ConClear() { - int X, Y; - TCell Cell = ' ' | (0x07 << 8); - ConQuerySize(&X, &Y); - ConSetBox(0, 0, X, Y, Cell); - ConSetCursorPos(0, 0); - return 0; -} - -int ConSetTitle(char *Title, char *STitle) { - return 0; -} -int ConGetTitle(char *Title, int MaxLen, char *STitle, int SMaxLen) { - *Title = 0; - return 0; -} - -int ConPutBox(int X, int Y, int W, int H, PCell Cell) { - int i, hidden = 0; - - for (i = 0; i < H; i++) { - if (LastMouseY == Y + i) { mouseHide(); hidden = 1; } - lseek(VcsFd, 4 + ((Y + i) * VideoCols + X) * 2, SEEK_SET); - conwrite(VcsFd, Cell, 2 * W); - Cell += W; - if (hidden) mouseShow(); - } - return 0; -} - -int ConGetBox(int X, int Y, int W, int H, PCell Cell) { - int i, hidden = 0; - - for (i = 0; i < H; i++) { - if (LastMouseY == Y + i) { mouseHide(); hidden = 1; } - lseek(VcsFd, 4 + ((Y + i) * VideoCols + X) * 2, SEEK_SET); - conread(VcsFd, Cell, 2 * W); - Cell += W; - if (hidden) mouseShow(); - } - return 0; -} - -int ConPutLine(int X, int Y, int W, int H, PCell Cell) { - int i, hidden = 0; - - for (i = 0; i < H; i++) { - if (LastMouseY == Y + i) { mouseHide(); hidden = 1; } - lseek(VcsFd, 4 + ((Y + i) * VideoCols + X) * 2, SEEK_SET); - conwrite(VcsFd, Cell, 2 * W); - if (hidden) mouseShow(); - } - return 0; -} - -int ConSetBox(int X, int Y, int W, int H, TCell Cell) { - TDrawBuffer B; - MoveCh(B, Cell & 0xFF, Cell >> 8, W); - ConPutLine(X, Y, W, H, B); - return 0; -} - -int ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count) { - PCell C; - TDrawBuffer B; - - if (Count == 0 || Count > H) return 0; - C = (PCell)malloc(2 * W * H); - if (C == 0) - return -1; -#ifdef USE_SCRNMAP - noCharTrans = 1; -#endif - MoveCh(B, ' ', Fill, W); - ConGetBox(X, Y, W, H, C); - if (Way == csUp) { - ConPutBox(X, Y, W, H - Count, C + W * Count); - ConPutLine(X, Y + H - Count, W, Count, B); - } else { - ConPutBox(X, Y + Count, W, H - Count, C); - ConPutLine(X, Y, W, Count, B); - } -#ifdef USE_SCRNMAP - noCharTrans = 0; -#endif - free((void *)C); - return 0; -} - -int ConSetSize(int X, int Y) { - return -1; -} - -int ConQuerySize(int *X, int *Y) { - if (X) *X = VideoCols; - if (Y) *Y = VideoRows; - return 0; -} - -int ConSetCursorPos(int X, int Y) { - char pos[2]; - - if (X >= 0 && X < int(VideoCols)) CursorX = X; - if (Y >= 0 && Y < int(VideoRows)) CursorY = Y; - pos[0] = CursorX; - pos[1] = CursorY; - lseek(VcsFd, 2, SEEK_SET); - write(VcsFd, pos, 2); - return 0; -} - -int ConQueryCursorPos(int *X, int *Y) { - if (X) *X = CursorX; - if (Y) *Y = CursorY; - return 0; -} - -int ConShowCursor(void) { - return 0; -} - -int ConHideCursor(void) { - return 0; -} - -int ConCursorVisible(void) { - return 1; -} - -int ConSetMousePos(int X, int Y) { - return -1; -} - -int ConQueryMousePos(int *X, int *Y) { - if (X) *X = LastMouseX; - if (Y) *Y = LastMouseY; - return -1; -} - -int ConShowMouse(void) { - return -1; -} - -int ConHideMouse(void) { - return -1; -} - -int ConMouseVisible(void) { - return 0; -} - -int ConQueryMouseButtons(int *ButtonCount) { - if (ButtonCount) *ButtonCount = 0; - return 0; -} - -int GetEvent(TEvent *Event); -static TEvent Prev = { evNone }; - -int ConGetEvent(TEventMask EventMask, TEvent *Event, int WaitTime, int Delete) { - fd_set readfds; - struct timeval timeout; - - if (Prev.What != evNone) { - *Event = Prev; - if (Delete) Prev.What = evNone; - return 1; - } - Event->What = evNone; - - FD_ZERO(&readfds); - FD_SET(VtFd, &readfds); -#ifdef USE_GPM - if (GpmFd != -1) - FD_SET(GpmFd, &readfds); -#endif - for (int p = 0; p < MAX_PIPES; p++) - if (Pipes[p].used) - if (Pipes[p].fd != -1) - FD_SET(Pipes[p].fd, &readfds); - if (WaitTime == -1) { - if (select(sizeof(fd_set) * 8, &readfds, NULL, NULL, NULL) < 0) return -1; - } else { - timeout.tv_sec = WaitTime / 1000; - timeout.tv_usec = (WaitTime % 1000) * 1000; - if (select(sizeof(fd_set) * 8, &readfds, NULL, NULL, &timeout) < 0) return -1; - } - if (FD_ISSET(VtFd, &readfds)) { - GetKeyEvent(Event); - if (!Delete) - Prev = *Event; - return 1; -#ifdef USE_GPM - } else if (GpmFd != -1 && FD_ISSET(GpmFd, &readfds)) { - GetMouseEvent(Event); - if (!Delete) - Prev = *Event; - return 1; -#endif - } else { - for (int pp = 0; pp < MAX_PIPES; pp++) { - if (Pipes[pp].used) - if (Pipes[pp].fd != -1) - if (FD_ISSET(Pipes[pp].fd, &readfds)) { - if (Pipes[pp].notify) { - Event->What = evNotify; - Event->Msg.View = 0; - Event->Msg.Model = Pipes[pp].notify; - Event->Msg.Command = cmPipeRead; - Event->Msg.Param1 = pp; - Pipes[pp].stopped = 0; - } - //fprintf(stderr, "Pipe %d\n", Pipes[pp].fd); - return 0; - } - } - return -1; - } - return 0; -} - -int ConPutEvent(TEvent Event) { - Prev = Event; - return 0; -} - -int ConFlush(void) {return 0; } -int ConGrabEvents(TEventMask EventMask) { return 0; } - -int shift_state = 0; -int lock_state = 0; -int slock_state = 0; -char dead_key = 0; - -static const struct { - unsigned long KeySym; - unsigned long KeyCode; -} KeyTrans[] = { -{ K(KT_FN, K_F1), kbF1 }, -{ K(KT_FN, K_F2), kbF2 }, -{ K(KT_FN, K_F3), kbF3 }, -{ K(KT_FN, K_F4), kbF4 }, -{ K(KT_FN, K_F5), kbF5 }, -{ K(KT_FN, K_F6), kbF6 }, -{ K(KT_FN, K_F7), kbF7 }, -{ K(KT_FN, K_F8), kbF8 }, -{ K(KT_FN, K_F9), kbF9 }, -{ K(KT_FN, K_F10), kbF10 }, -{ K(KT_FN, K_F11), kbF11 }, -{ K(KT_FN, K_F12), kbF12 }, -{ K(KT_FN, K_INSERT), kbIns | kfGray }, -{ K(KT_FN, K_REMOVE), kbDel | kfGray }, -{ K(KT_FN, K_FIND), kbHome | kfGray }, -{ K(KT_FN, K_SELECT), kbEnd | kfGray }, -{ K(KT_FN, K_PGUP), kbPgUp | kfGray }, -{ K(KT_FN, K_PGDN), kbPgDn | kfGray }, -{ K(KT_CUR, K_UP), kbUp | kfGray }, -{ K(KT_CUR, K_DOWN), kbDown | kfGray }, -{ K(KT_CUR, K_LEFT), kbLeft | kfGray }, -{ K(KT_CUR, K_RIGHT), kbRight | kfGray }, -{ K(KT_SPEC, K_ENTER), kbEnter }, -{ K(KT_PAD, K_PENTER), kbEnter | kfGray }, -{ K(KT_PAD, K_PPLUS), '+' | kfGray }, -{ K(KT_PAD, K_PMINUS), '-' | kfGray }, -{ K(KT_PAD, K_PSTAR), '*' | kfGray }, -{ K(KT_PAD, K_PSLASH), '/' | kfGray }, -{ K(KT_PAD, K_P0), kbIns }, -{ K(KT_PAD, K_PDOT), kbDel }, -{ K(KT_PAD, K_P1), kbEnd }, -{ K(KT_PAD, K_P2), kbDown }, -{ K(KT_PAD, K_P3), kbPgDn }, -{ K(KT_PAD, K_P4), kbLeft }, -{ K(KT_PAD, K_P5), kbCenter }, -{ K(KT_PAD, K_P6), kbRight }, -{ K(KT_PAD, K_P7), kbHome }, -{ K(KT_PAD, K_P8), kbUp }, -{ K(KT_PAD, K_P9), kbPgUp }, -{ K(KT_FN, K_PAUSE), kbPause }, -{ K(KT_LATIN, 27), kbEsc }, -{ K(KT_LATIN, 13), kbEnter }, -{ K(KT_LATIN, 8), kbBackSp }, -{ K(KT_LATIN, 127), kbDel }, -{ K(KT_LATIN, 9), kbTab }, -{ K(KT_SHIFT, KG_SHIFT), kbShift | kfSpecial | kfModifier }, -{ K(KT_SHIFT, KG_SHIFTL), kbShift | kfSpecial | kfModifier }, -{ K(KT_SHIFT, KG_SHIFTR), kbShift | kfSpecial | kfModifier | kfGray }, -{ K(KT_SHIFT, KG_CTRL), kbCtrl | kfSpecial | kfModifier }, -{ K(KT_SHIFT, KG_CTRLL), kbCtrl | kfSpecial | kfModifier }, -{ K(KT_SHIFT, KG_CTRLR), kbCtrl | kfSpecial | kfModifier | kfGray }, -{ K(KT_SHIFT, KG_ALT), kbAlt | kfSpecial | kfModifier }, -{ K(KT_SHIFT, KG_ALTGR), kbAlt | kfSpecial | kfModifier | kfGray }, -{ 0, 0 } -}; - -struct { - unsigned long KeySym; - char Diacr; -} DeadTrans[] = { -{ K_DGRAVE, '`' }, -{ K_DACUTE, '\'' }, -{ K_DCIRCM, '^' }, -{ K_DTILDE, '~' }, -{ K_DDIERE, '"' }, -{ K_DCEDIL, ',' } -}; - -int GetKeyEvent(TEvent *Event) { - char keycode; - - Event->What = evNone; - - if (read(VtFd, &keycode, 1) != 1) - return -1; - - int key = keycode & 0x7F; - int press = (keycode & 0x80) ? 0 : 1; - unsigned int keysym; - int rc; - struct kbentry kbe; - int shift_final; - int ShiftFlags; - TKeyCode KeyCode; - - kbe.kb_index = key; - kbe.kb_table = 0; - rc = ioctl(VtFd, KDGKBENT, &kbe); - keysym = kbe.kb_value; - - //printf("rc = %d, value = %04X, ktype=%d, kval=%d\n", - // rc, keysym, KTYP(keysym), KVAL(keysym)); - - int ksv = KVAL(keysym); - - switch(KTYP(keysym)) { - case KT_SHIFT: - // :-(((, have to differentiate between shifts. - if (ksv == KG_SHIFT) { - if (key == 54) - ksv = KG_SHIFTR; - else - ksv = KG_SHIFTL; - } else if (ksv == KG_CTRL) { - if (key == 97) - ksv = KG_CTRLR; - else - ksv = KG_CTRLL; - } - if (press) - shift_state |= (1 << ksv); - else - shift_state &= ~(1 << ksv); - break; - case KT_LOCK: -// if (press) -// lock_state |= (1 << ksv); -// else -// lock_state &= ~(1 << ksv); - if (press) lock_state ^= (1 << ksv); - break; - case KT_SLOCK: - if (press) - slock_state |= (1 << ksv); - else - slock_state &= ~(1 << ksv); - break; - } - - shift_final = shift_state ^ lock_state ^ slock_state; - - if (shift_final & ((1 << KG_SHIFT) | - (1 << KG_SHIFTL) | - (1 << KG_SHIFTR))) - { - shift_final |= (1 << KG_SHIFT); - shift_final &= ~( (1 << KG_SHIFTL) | (1 << KG_SHIFTR) ); - } - if (shift_final & ((1 << KG_CTRL) | - (1 << KG_CTRLL) | - (1 << KG_CTRLR))) - { - shift_final |= (1 << KG_CTRL); - shift_final &= ~( (1 << KG_CTRLL) | (1 << KG_CTRLR) ); - } - - ShiftFlags = 0; - if ((shift_final & (1 << KG_SHIFT)) || - (shift_final & (1 << KG_SHIFTL)) || - (shift_final & (1 << KG_SHIFTR))) - ShiftFlags |= kfShift; - if ((shift_final & (1 << KG_CTRL)) || - (shift_final & (1 << KG_CTRLL)) || - (shift_final & (1 << KG_CTRLR))) - ShiftFlags |= kfCtrl; -// if ((shift_final & (1 << KG_ALT)) || -// (shift_final & (1 << KG_ALTGR))) - if (shift_final & (1 << KG_ALT)) - ShiftFlags |= kfAlt; - - // printf("shift: %X, lock: %X, slock: %X, final: %X, ShiftFlags: %X\n", - // shift_state, lock_state, slock_state, shift_final, ShiftFlags); - - if (KTYP(keysym) != KT_SLOCK) - slock_state = 0; - - KeyCode = 0; - if (key == 14 && keysym == K(KT_LATIN,127)) { - // we are running on a system with broken backspace key - KeyCode = kbBackSp; - } else for(unsigned int i = 0; i < sizeof(KeyTrans) / sizeof(KeyTrans[0]); i++) { - if (KeyTrans[i].KeySym == keysym) { - KeyCode = KeyTrans[i].KeyCode; - break; - } - } - if (KeyCode == 0) { - switch (KTYP(keysym)) { - case KT_CONS: - case KT_FN: - //case KT_SPEC: - case KT_LOCK: - case KT_SLOCK: - //case KT_META: - case KT_CUR: - - default: - //if (!(shift_final & KG_ALTGR)) - // break; - dead_key = 0; - break; - - case KT_SHIFT: - break; - case KT_LETTER: - // take caps into account - if (0) { - ShiftFlags ^= kfShift; - shift_final ^= (1 << KG_SHIFT); - } - // no break - case KT_LATIN: -// if (shift_final & (1 << KG_ALTGR)) -// ShiftFlags &= ~kfAlt; - - if (ShiftFlags & kfAlt) - shift_final &= - ~(1 << KG_SHIFT); - - kbe.kb_index = key; - kbe.kb_table = shift_final; - rc = ioctl(VtFd, KDGKBENT, &kbe); - if (rc != 0) - break; - - keysym = kbe.kb_value; - - //if (KTYP(keysym) != KT_LATIN && - // KTYP(keysym) != KT_LETTER && - // KTYP(keysym) != KT_ASCII) - // break; - - KeyCode = KVAL(keysym); - if (ShiftFlags & kfAlt) - KeyCode = toupper(KeyCode); - - if (KTYP(keysym) == KT_DEAD) { - for (int i = 0;(unsigned) i < sizeof(DeadTrans) / sizeof(DeadTrans[0]); i++) { - if (DeadTrans[i].KeySym == keysym) { - dead_key = DeadTrans[i].Diacr; - return -1; - } - } - dead_key = 0; - return -1; - } - if (! (ShiftFlags & (kfAlt | kfCtrl)) && dead_key) { - for (int i = 0; (unsigned) i < diacr_table.kb_cnt; i++) { - if (diacr_table.kbdiacr[i].base == KeyCode && - diacr_table.kbdiacr[i].diacr == dead_key) { - KeyCode=diacr_table.kbdiacr[i].result; - break; - } - } - } - dead_key = 0; - - break; - } - } - - if (KeyCode == 0) - return -1; - - if (ShiftFlags & kfCtrl) - if (KeyCode < 32) - KeyCode += 64; - - KeyCode |= ShiftFlags; - - if (!press) - KeyCode |= kfKeyUp; - - if (KeyCode != 0) { - - if (KTYP(keysym) != KT_SHIFT) - dead_key = 0; - - if (KeyCode & kfKeyUp) - Event->What = evKeyUp; - else - Event->What = evKeyDown; - Event->Key.Code = KeyCode & ~kfKeyUp; - - - // switching consoles should be done by the kernel, but - // it is not (why, since I am not using VT_PROCESS??). - // this has a delay if the app is working. - // there is also a problem with shift-states (should update it - // after getting back, but how to know when that happens, without - // using VT_PROCESS?). - { - int vc = -1; - -// switch (kbCode(Event->Key.Code) | kfCtrl) { - switch (kbCode(Event->Key.Code)) { - case kfAlt | kfCtrl | kbF1: vc = 1; break; - case kfAlt | kfCtrl | kbF2: vc = 2; break; - case kfAlt | kfCtrl | kbF3: vc = 3; break; - case kfAlt | kfCtrl | kbF4: vc = 4; break; - case kfAlt | kfCtrl | kbF5: vc = 5; break; - case kfAlt | kfCtrl | kbF6: vc = 6; break; - case kfAlt | kfCtrl | kbF7: vc = 7; break; - case kfAlt | kfCtrl | kbF8: vc = 8; break; - case kfAlt | kfCtrl | kbF9: vc = 9; break; - case kfAlt | kfCtrl | kbF10: vc = 10; break; - case kfAlt | kfCtrl | kbF11: vc = 11; break; - case kfAlt | kfCtrl | kbF12: vc = 12; break; - } - if (vc != -1) { - /* perform the console switch */ - ioctl(VtFd, VT_ACTIVATE, vc); - Event->What = evNone; -// shift_state = lock_state = slock_state = 0; // bad - shift_state = slock_state = 0; // bad - return -1; - } - } - - return 0; - } - return -1; -} - -int GetMouseEvent(TEvent *Event) { -#ifdef USE_GPM - Gpm_Event e; - - Event->What = evNone; - int rc = Gpm_GetEvent(&e); - if (rc == 0) { - Gpm_Close(); - GpmFd = -1; - } else if (rc == -1) { - } else { - //Gpm_FitEvent(&e); - if ((e.type & GPM_MOVE) || (e.type & GPM_DRAG)) - Event->What = evMouseMove; - else if (e.type & GPM_DOWN) - Event->What = evMouseDown; - else if (e.type & GPM_UP) - Event->What = evMouseUp; - else return 0; - - Event->Mouse.Count = (e.type & GPM_SINGLE) ? 1 - : (e.type & GPM_DOUBLE) ? 2 - : (e.type & GPM_TRIPLE) ? 3 : 1; - Event->Mouse.Buttons = - ((e.buttons & GPM_B_LEFT) ? 1 : 0) | - ((e.buttons & GPM_B_RIGHT) ? 2 : 0) | - ((e.buttons & GPM_B_MIDDLE) ? 4 : 0); - - e.x--; - e.y--; - - if (e.x < 0) e.x = 0; - if (e.y < 0) e.y = 0; - if (e.x >= int(VideoCols)) e.x = VideoCols - 1; - if (e.y >= int(VideoRows)) e.y = VideoRows - 1; - - Event->Mouse.X = e.x; - Event->Mouse.Y = e.y; - - Event->Mouse.KeyMask = - ((e.modifiers & 1) ? kfShift : 0) | - ((e.modifiers & (2 | 8)) ? kfAlt : 0) | - ((e.modifiers & 4) ? kfCtrl : 0); - - if (LastMouseX != e.x || - LastMouseY != e.y) - { - mouseHide(); - LastMouseX = e.x; - LastMouseY = e.y; - mouseShow(); - } - } - -#else - Event->What = evNone; -#endif - return 0; -} - -int ConSetCursorSize(int Start, int End) { - return 0; -} - -static PCell -SavedScreen = 0; -static int SavedX, SavedY, SaveCursorPosX, SaveCursorPosY; - -int SaveScreen() { - if (SavedScreen) - free(SavedScreen); - - ConQuerySize(&SavedX, &SavedY); - - SavedScreen = (PCell) malloc(SavedX * SavedY * sizeof(PCell)); - - if (SavedScreen) - ConGetBox(0, 0, SavedX, SavedY, SavedScreen); - ConQueryCursorPos(&SaveCursorPosX, &SaveCursorPosY); - return 0; -} - -int RestoreScreen() { - if (SavedScreen) { - ConPutBox(0, 0, SavedX, SavedY, SavedScreen); - ConSetCursorPos(SaveCursorPosX, SaveCursorPosY); - } - return 1; -} - -GUI::GUI(int &argc, char **argv, int XSize, int YSize) { - fArgc = argc; - fArgv = argv; - ::ConInit(-1, -1); - SaveScreen(); - ::ConSetSize(XSize, YSize); - gui = this; -} - -GUI::~GUI() { - RestoreScreen(); - ::ConDone(); - - if(SavedScreen) - { - free(SavedScreen); - SavedScreen = 0; - } - - gui = 0; -} - -int GUI::ConSuspend(void) { - RestoreScreen(); - return ::ConSuspend(); -} - -int GUI::ConContinue(void) { - SaveScreen(); - return ::ConContinue(); -} - -int GUI::ShowEntryScreen() { - TEvent E; - - ConHideMouse(); - RestoreScreen(); - do { gui->ConGetEvent(evKeyDown, &E, -1, 1, 0); } while (E.What != evKeyDown); - ConShowMouse(); - if (frames) - frames->Repaint(); - return 1; -} - -int GUI::OpenPipe(char *Command, EModel *notify) { - int i; - - for (i = 0; i < MAX_PIPES; i++) { - if (Pipes[i].used == 0) { - int pfd[2]; - - Pipes[i].id = i; - Pipes[i].notify = notify; - Pipes[i].stopped = 1; - - if (pipe((int *)pfd) == -1) - return -1; - - switch (Pipes[i].pid = fork()) { - case -1: /* fail */ - return -1; - case 0: /* child */ - signal(SIGPIPE, SIG_DFL); - VtFd = -1; // for atexit handler - close(VtFd); - close(pfd[0]); - close(0); - dup2(pfd[1], 1); - dup2(pfd[1], 2); - close(pfd[1]); - exit(system(Command)); - default: - close(pfd[1]); - fcntl(pfd[0], F_SETFL, O_NONBLOCK); - Pipes[i].fd = pfd[0]; - } - Pipes[i].used = 1; - //fprintf(stderr, "Pipe Open: %d\n", i); - return i; - } - } - return -1; -} - -int GUI::SetPipeView(int id, EModel *notify) { - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - //fprintf(stderr, "Pipe View: %d %08X\n", id, notify); - Pipes[id].notify = notify; - return 0; -} - -int GUI::ReadPipe(int id, void *buffer, int len) { - int rc; - - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - //fprintf(stderr, "Pipe Read: Get %d %d\n", id, len); - - rc = read(Pipes[id].fd, buffer, len); - //fprintf(stderr, "Pipe Read: Got %d %d\n", id, len); - if (rc == 0) { - close(Pipes[id].fd); - Pipes[id].fd = -1; - return -1; - } - if (rc == -1) { - Pipes[id].stopped = 1; - return 0; - } - return rc; -} - -int GUI::ClosePipe(int id) { - int status = -1; - - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - if (Pipes[id].fd != -1) - close(Pipes[id].fd); - kill(Pipes[id].pid, SIGHUP); - alarm(1); - waitpid(Pipes[id].pid, &status, 0); - alarm(0); - //fprintf(stderr, "Pipe Close: %d\n", id); - Pipes[id].used = 0; - return WEXITSTATUS(status); -} - -int GUI::RunProgram(int mode, char *Command) { - int rc, W, H, W1, H1; - - ConQuerySize(&W, &H); - ConHideMouse(); - ConSuspend(); - - if (*Command == 0) // empty string = shell - Command = getenv("SHELL"); - - rc = system(Command); - - ConContinue(); - ConShowMouse(); - ConQuerySize(&W1, &H1); - - if (W != W1 || H != H1) { - frames->Resize(W1, H1); - } - frames->Repaint(); - return rc; -} - -char ConGetDrawChar(int index) { - static const char tab[] = "Ú¿ÀÙijÂôÁÅ\x1Aúı°\x1B\x1A"; - static const char tab_iso[] = "++++-|+++++>.*-^v :[>"; - //static char tab[] = "\x0D\x0C\x0E\x0B\x12\x19____+>\x1F\x01\x12 "; - static int use = 0; - - assert(index >= 0 && index < int(strlen(tab))); - - if (use == 0) { - char * c = getenv("ISOCONSOLE"); - use = (c == NULL) ? 1 : 2; - } - - if (use == 2) - return tab_iso[index]; - -#ifdef USE_SCRNMAP - return fromScreen[tab[index]]; -#else - return tab[index]; -#endif -} diff --git a/src/con_nt.cpp b/src/con_nt.cpp deleted file mode 100644 index 0281fd7..0000000 --- a/src/con_nt.cpp +++ /dev/null @@ -1,1925 +0,0 @@ -/* con_nt.cpp - * - * Copyright (c) 1994-1996, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -/* some functionality is now shared with g_text.cpp and g_draw.cpp */ -/* new os/2 code needs to be merged with this */ -/* the console APIs on win'95 seem to be really screwed up */ - -/* - * 10/13/96 Jal: - * Rebuilt for Windows NT, generic; no port/Watcom code should - * be needed to compile (jal). - * Removed most mouse handling code (unnecessary), added pipe handler by - * porting the OS/2 version to NT. - * Solved some bugs with regard to the TCell problem. - * - * 10/28/96 Jal: - * Started to replace threaded pipe code with nonthreaded code, using - * overlapped I/O. - * - * Wed Jan 15 1997 (Jal): - * - The Grey-Alt-+ key and some other keys were not recognised. This - * was because NT didn't mark these as "enhanced" keys. Now the code - * translates some (scancode,ascii) pairs to the enhanced keyboard. - * The table was already present! - * - To solve the "flashing cursor" problem: now doesn't enter FTE - * mainloop when console returns empty action.. - * - */ -//#define WIN32_LEAN_AND_MEAN 1 -#include "windows.h" -#include - -#include -#include "sysdep.h" -#include "console.h" -#include "gui.h" - -#define True 1 -#define False 0 - - -static int Initialized = 0; -static int MousePresent = 0; -static int CursorVisible = 1; /* 1 means visible */ -static int MouseVisible = 0; /* 0 means hidden */ -static TEvent MouseEv = { evNone }; -static TEvent EventBuf = { evNone }; -static TEventMask EventMask; - -static HANDLE ConOut; -static HANDLE ConIn; -static HANDLE OurConOut; -static DWORD OldConsoleMode; - -static int LastMouseX = 0; -static int LastMouseY = 0; -//static int isWin95 = 0; - -int codepage; - -#define dbm(x) //printf(x), Sleep(3000) - - -#if 0 -void dbg(const char* s, ...) /*FOLD00*/ -{ -} -#else - -void dbg(const char* s, ...) /*FOLD00*/ -{ - char buf[256]; - va_list args; - - va_start(args, s); - vsprintf(buf, s, args); - va_end(args); - OutputDebugString(buf); -} -#endif - - -static void DrawCursor(int Show) { /*FOLD00*/ - CONSOLE_CURSOR_INFO cci; - - GetConsoleCursorInfo(OurConOut, &cci); - cci.bVisible = Show ? TRUE : FALSE; - SetConsoleCursorInfo(OurConOut, &cci); -} - -#define NUMITEMS(x) (sizeof(x) / sizeof(x[0])) - -#if 1 -/* - * Translation table 1: translate (scan,asciicode) of the input event to a - * valid FTE keystroke. This is used because NT sometimes "forgets" to flag - * special keys as "enhanced" (grey) keys.. - */ -static struct { - USHORT CharScan; - TKeyCode KeyCode; -} TransCharScan[] = { - { 0x0100, kbEsc }, { 0x011B, kbEsc }, - { 0x1C0D, kbEnter }, { 0x1C0A, kbEnter }, - { 0x1C00, kbEnter }, { 0xE00D, kbEnter | kfGray }, - { 0xA600, kbEnter | kfGray }, { 0xE00A, kbEnter | kfGray }, - { 0x0E08, kbBackSp }, { 0x0E7F, kbBackSp }, - { 0x0E00, kbBackSp }, { 0x0F09, kbTab }, - { 0x9400, kbTab }, { 0xA500, kbTab }, - { 0x0F00, kbTab }, { 0x4E00, '+' | kfGray }, - { 0x9000, '+' | kfGray }, { 0x4E2B, '+' | kfGray }, - { 0x4A00, '-' | kfGray }, { 0x8E00, '-' | kfGray }, - { 0x4A2D, '-' | kfGray }, { 0x3700, '*' | kfGray }, - { 0x9600, '*' | kfGray }, { 0x372A, '*' | kfGray }, - { 0xE02F, '/' | kfGray }, { 0xA400, '/' | kfGray }, - { 0x9500, '/' | kfGray }, { 0x0300, 0 } -}; -#endif - -#if 0 -static struct { - int ScanCode; - TKeyCode KeyCode; -} TransScan[] = { - { 0x78, '1' }, { 0x79, '2' }, { 0x7A, '3' }, { 0x7B, '4' }, { 0x7C, '5' }, - { 0x7D, '6' }, { 0x7E, '7' }, { 0x7F, '8' }, { 0x80, '9' }, { 0x81, '0' }, - - { 0x10, 'Q' }, { 0x11, 'W' }, { 0x12, 'E' }, { 0x13, 'R' }, { 0x14, 'T' }, - { 0x15, 'Y' }, { 0x16, 'U' }, { 0x17, 'I' }, { 0x18, 'O' }, { 0x19, 'P' }, - - { 0x1E, 'A' }, { 0x1F, 'S' }, { 0x20, 'D' }, { 0x21, 'F' }, { 0x22, 'G' }, - { 0x23, 'H' }, { 0x24, 'J' }, { 0x25, 'K' }, { 0x26, 'L' }, - - { 0x2C, 'Z' }, { 0x2D, 'X' }, { 0x2E, 'C' }, { 0x2F, 'V' }, { 0x30, 'B' }, - { 0x31, 'N' }, { 0x32, 'M' }, - - { 0x29, '`' }, { 0x82, '-' }, { 0x83, '=' }, { 0x2B, '\\' }, { 0x1A, '[' }, - { 0x1B, ']' }, { 0x27, ';' }, { 0x28, '\'' }, { 0x33, ',' }, { 0x34, '.' }, - { 0x35, '/' }, { 0x37, '*' }, { 0x4E, '+' }, { 0x4A, '-' }, - - { 0x3B, kbF1 }, { 0x3C, kbF2 }, { 0x3D, kbF3 }, - { 0x3E, kbF4 }, { 0x3F, kbF5 }, { 0x40, kbF6 }, - { 0x41, kbF7 }, { 0x42, kbF8 }, { 0x43, kbF9 }, - { 0x44, kbF10 }, { 0x85, kbF11 }, { 0x86, kbF12 }, - - { 0x54, kbF1 }, { 0x55, kbF2 }, { 0x56, kbF3 }, - { 0x57, kbF4 }, { 0x58, kbF5 }, { 0x59, kbF6 }, - { 0x5A, kbF7 }, { 0x5B, kbF8 }, { 0x5C, kbF9 }, - { 0x5D, kbF10 }, { 0x87, kbF11 }, { 0x88, kbF12 }, - - { 0x5E, kbF1 }, { 0x5F, kbF2 }, { 0x60, kbF3 }, - { 0x61, kbF4 }, { 0x62, kbF5 }, { 0x63, kbF6 }, - { 0x64, kbF7 }, { 0x65, kbF8 }, { 0x66, kbF9 }, - { 0x67, kbF10 }, { 0x89, kbF11 }, { 0x8A, kbF12 }, - - { 0x68, kbF1 }, { 0x69, kbF2 }, { 0x6A, kbF3 }, - { 0x6B, kbF4 }, { 0x6C, kbF5 }, { 0x6D, kbF6 }, - { 0x6E, kbF7 }, { 0x6F, kbF8 }, { 0x70, kbF9 }, - { 0x71, kbF10 }, { 0x8B, kbF11 }, { 0x8C, kbF12 }, - - { 0x47, kbHome }, { 0x48, kbUp }, { 0x49, kbPgUp }, - { 0x4B, kbLeft }, { 0x4C, kbCenter}, { 0x4D, kbRight }, - { 0x4F, kbEnd }, { 0x50, kbDown }, { 0x51, kbPgDn }, - { 0x52, kbIns }, { 0x53, kbDel }, - - { 0x77, kbHome }, { 0x8D, kbUp }, { 0x84, kbPgUp }, - { 0x73, kbLeft }, { 0x74, kbRight }, - { 0x75, kbEnd }, { 0x91, kbDown }, { 0x76, kbPgDn }, - { 0x92, kbIns }, { 0x93, kbDel }, - - { 0x97, kbHome | kfGray }, { 0x98, kbUp | kfGray }, { 0x99, kbPgUp | kfGray }, - { 0x9B, kbLeft | kfGray }, { 0x9D, kbRight | kfGray }, - { 0x9F, kbEnd | kfGray }, { 0xA0, kbDown | kfGray }, { 0xA1, kbPgDn | kfGray }, - { 0xA2, kbIns | kfGray }, { 0xA3, kbDel | kfGray } -}; -#endif - - -struct { - SHORT VirtCode; - unsigned long KeyCode; -} VirtTab[] = -{ - { 112, kbF1 }, - { 113, kbF2 }, - { 114, kbF3 }, - { 115, kbF4 }, - { 116, kbF5 }, - { 117, kbF6 }, - { 118, kbF7 }, - { 119, kbF8 }, - { 120, kbF9 }, - { 121, kbF10 }, - { 122, kbF11 }, - { 123, kbF12 }, - - { 35, kbEnd }, - { 36, kbHome }, - { 33, kbPgUp }, - { 34, kbPgDn }, - { 38, kbUp }, - { 37, kbLeft }, - { 39, kbRight }, - { 40, kbDown }, - { 45, kbIns }, - { 46, kbDel }, - - { 27, kbEsc }, - { 13, kbEnter }, - { 8, kbBackSp }, - { 32, kbSpace }, - { 9, kbTab }, - - { 0, 0 } -}; - -char shftwrng[] = "~!@#$%^&*()_+{}|:\"<>?"; -char shftright[] = "`1234567890-=[]\\;',./"; - -int ReadConsoleEvent(TEvent *E) /*FOLD00*/ -{ - /* - * Reads and interprets the console event. It is called when console input - * handle is signalled. To prevent flashing cursors this routine returns - * F if there's nothing to do; this causes the caller to loop without - * returning to the FTE mainloop. - */ - INPUT_RECORD inp; - DWORD nread; - TKeyCode Ch = 0; - TKeyCode flg = 0; - ULONG flags; - int I, i; - - ReadConsoleInput(ConIn, &inp, 1, &nread); - if (nread != 1) return False; // Nothing read after signal?? - - switch (inp.EventType) - { - case WINDOW_BUFFER_SIZE_EVENT: - //** Resized the window. Make FTE use the new size.. - frames->Resize(inp.Event.WindowBufferSizeEvent.dwSize.X, inp.Event.WindowBufferSizeEvent.dwSize.Y); - frames->Repaint(); - return True; - - case KEY_EVENT: - if (inp.Event.KeyEvent.bKeyDown) { - if ((inp.Event.KeyEvent.dwControlKeyState & CAPSLOCK_ON) && - inp.Event.KeyEvent.wVirtualKeyCode != 106 && - inp.Event.KeyEvent.wVirtualKeyCode != 109 && - inp.Event.KeyEvent.wVirtualKeyCode != 107) - { - if (!(inp.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED)) { - for (i=0; shftwrng[i]; i++) { - if (inp.Event.KeyEvent.uChar.AsciiChar == shftwrng[i]) { - inp.Event.KeyEvent.uChar.AsciiChar = shftright[i]; - break; - } - } - } - else { - for (i=0; shftright[i]; i++) { - if (inp.Event.KeyEvent.uChar.AsciiChar == shftright[i]) { - inp.Event.KeyEvent.uChar.AsciiChar = shftwrng[i]; - break; - } - } - } - } - } - //** Skip shift, control and alt key stuff. - switch(inp.Event.KeyEvent.wVirtualKeyCode) - { case VK_SHIFT: case VK_CONTROL: case VK_MENU: case VK_PAUSE: - case VK_CAPITAL: case VK_LWIN: case VK_RWIN: case VK_APPS: - return False; - } - - //** Distill FTE flags from the NT flags. This fails for some keys - //** because NT has an oddity with enhanced keys (Alt-Grey-+ etc). - flags = inp.Event.KeyEvent.dwControlKeyState; - if (flags & (/*RIGHT_ALT_PRESSED |*/ LEFT_ALT_PRESSED)) flg |= kfAlt; - if (flags & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) flg |= kfCtrl; - if (flags & (RIGHT_ALT_PRESSED)) flg &= ~kfCtrl; - if (flags & SHIFT_PRESSED) flg |= kfShift; - if (flags & ENHANCED_KEY) flg |= kfGray; - -#if 0 - dbg("key1: %s, vk=%x, vscan=%x, flags=%x, rep=%d, ascii=%x (%c).\n", - inp.Event.KeyEvent.bKeyDown ? "down" : "up", - inp.Event.KeyEvent.wVirtualKeyCode, - inp.Event.KeyEvent.wVirtualScanCode, - flags, - inp.Event.KeyEvent.wRepeatCount, - inp.Event.KeyEvent.uChar.AsciiChar, - inp.Event.KeyEvent.uChar.AsciiChar); -#endif - - Ch = 0; - - // handle special case when user with scandinavian keyboard presses - // alt-gr + special key and then spacebar - if (inp.Event.KeyEvent.bKeyDown) { - if ((inp.Event.KeyEvent.wVirtualKeyCode == 0x20) && - (inp.Event.KeyEvent.wVirtualScanCode == 0x39)) - { - switch(inp.Event.KeyEvent.uChar.AsciiChar) - { - case '~': Ch = '~'; break; - case '^': Ch = '^'; break; - case '`': Ch = '`'; break; - case 'ï': Ch = 'ï'; break; - } - } - } - - //** Translate VK codes to FTE codes, - if (Ch == 0) - { - for (I = 0; I < sizeof(VirtTab)/sizeof(VirtTab[0]); I++) - if (VirtTab[I].VirtCode == inp.Event.KeyEvent.wVirtualKeyCode) - { - Ch = VirtTab[I].KeyCode; - break; - } - } - - //** Not a virtual key-> do charscan translation, if needed; - if(Ch == 0) - { - unsigned int cc = ((inp.Event.KeyEvent.wVirtualScanCode << 8) | (unsigned char)inp.Event.KeyEvent.uChar.AsciiChar); - for(I = 0; I < NUMITEMS(TransCharScan); I++) - { - if(cc == TransCharScan[I].CharScan) - { - Ch = TransCharScan[I].KeyCode; - break; - } - } - } - if (Ch == 0) - { - if ((Ch = (TKeyCode) (unsigned char)inp.Event.KeyEvent.uChar.AsciiChar) != 0) - { - if (flg & kfAlt) Ch = toupper(Ch); - } - } - - if (Ch == 0) //** Odd: cannot distill keycode. - return False; - - if (flg & kfCtrl) - if (Ch < 32) - Ch += 64; - - E->Key.Code = Ch | flg; // Set FTE keycode, - E->What = inp.Event.KeyEvent.bKeyDown ? evKeyDown : evKeyUp; - return True; - - case MOUSE_EVENT: - LastMouseX = E->Mouse.X = inp.Event.MouseEvent.dwMousePosition.X; - LastMouseY = E->Mouse.Y = inp.Event.MouseEvent.dwMousePosition.Y; - flags = inp.Event.MouseEvent.dwControlKeyState; - if (flags & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED)) flg |= kfAlt; - if (flags & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) flg |= kfCtrl; - if (flags & SHIFT_PRESSED) flg |= kfShift; - E->Mouse.KeyMask = flg; - E->Mouse.Buttons = (unsigned short)inp.Event.MouseEvent.dwButtonState; - E->Mouse.Count = 1; - if (inp.Event.MouseEvent.dwEventFlags & DOUBLE_CLICK) - E->Mouse.Count = 2; - if (inp.Event.MouseEvent.dwEventFlags == MOUSE_MOVED) - { - E->What = evMouseMove; - //puts("Move"); - } - else - { - static unsigned short mb = 0; - - if (inp.Event.MouseEvent.dwButtonState & ~mb) - { - E->What = evMouseDown; - E->Mouse.Buttons = ((unsigned short)inp.Event.MouseEvent.dwButtonState) & ~mb; - //puts("Down"); - } - else - { - E->What = evMouseUp; - E->Mouse.Buttons = mb & ~((unsigned short)inp.Event.MouseEvent.dwButtonState); - //puts("Up"); - } - mb = (unsigned short)inp.Event.MouseEvent.dwButtonState; - } - return True; - } - return False; -} - - -int ConInit(int /*XSize*/, int /*YSize*/) { /*FOLD00*/ - if (Initialized) return 0; - - EventBuf.What = evNone; - MousePresent = 0; //MOUSInit(); - - //** Get NT/Win95 flag, - OSVERSIONINFO oi; - - oi.dwOSVersionInfoSize = sizeof(oi); - GetVersionEx((LPOSVERSIONINFO) &oi); - //isWin95 = (oi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); - - ConOut = GetStdHandle(STD_OUTPUT_HANDLE); - ConIn = GetStdHandle(STD_INPUT_HANDLE); - codepage = GetConsoleCP(); - GetConsoleMode(ConIn, &OldConsoleMode); - SetConsoleMode(ConIn, - ENABLE_WINDOW_INPUT | - ENABLE_MOUSE_INPUT); - OurConOut = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, - 0, NULL, - CONSOLE_TEXTMODE_BUFFER, NULL); - ConContinue(); - - Initialized = 1; - return 0; -} - -int ConDone(void) { /*FOLD00*/ - ConSuspend(); - CloseHandle(OurConOut); - return 0; -} - -int ConSuspend(void) { /*FOLD00*/ - SetConsoleActiveScreenBuffer(ConOut); - SetConsoleMode(ConIn, OldConsoleMode); - return 0; -} - -int ConContinue(void) { /*FOLD00*/ - SetConsoleActiveScreenBuffer(OurConOut); - GetConsoleMode(ConIn, &OldConsoleMode); - SetConsoleMode(ConIn, ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT); - { - SetConsoleOutputCP(codepage); - SetConsoleCP(codepage); - } - return 0; -} - -int ConClear(void) { /*FOLD00*/ - int W, H; - TDrawBuffer B; - - MoveChar(B, 0, ConMaxCols, ' ', 0x07, 1); - if ((ConQuerySize(&W, &H) == 0) && - ConSetBox(0, 0, W, H, B[0])) return 0; - return -1; -} - - -#if 0 // Mouse control not necessary when using console functions. -/*--------------------------------------------------------------------------*/ -/* CLASS: tMouHelp is used to control mouse cursor visibility during */ -/* screen updates. */ -/*--------------------------------------------------------------------------*/ -class tMouHelp -{ -protected: - int mh_x, mh_y; // Current mouse position / 0 - int mh_valid; - int mh_disabled; // T if mouse should be re-enabled. - -public: - tMouHelp() : mh_x(0), mh_y(0), mh_valid(FALSE), mh_disabled(FALSE) {} - ~tMouHelp() - { if(MouseVisible && mh_disabled) DrawMouse(1); - } - - void disIfLine(int x, int w, int y) - { - if(mh_disabled) return; - if(! mh_valid) - { - ConQueryMousePos(&mh_x, &mh_y); - mh_valid = TRUE; - } - if(y == mh_y && mh_x >= x && mh_x < x+y) - { - mh_disabled= TRUE; - DrawMouse(0); - } - } -}; -#endif - -int ConPutBox(int X, int Y, int W, int H, PCell Cell) /*FOLD00*/ -{ - int I; - PCell p = Cell; - COORD corg, csize; - SMALL_RECT rcl; - BOOL rc; - - for (I = 0; I < H; I++) - { - corg.X = corg.Y = 0; - csize.X = W; - csize.Y = 1; - rcl.Left= X; - rcl.Top = I + Y; - rcl.Bottom = I + Y;// + (isWin95 ? 1 : 0); - rcl.Right = X + W - 1;// + (isWin95 ? 1 : 0); - - rc = WriteConsoleOutput(OurConOut, (PCHAR_INFO)p, csize, corg, &rcl); - if (rc != TRUE) { - //("WriteConsoleOutput %d\n", rc); - } - p += W; - } - return 0; -} - -int ConGetBox(int X, int Y, int W, int H, PCell Cell) /*FOLD00*/ -{ - int I; - USHORT WW = W << 1; - PCell p = Cell; - COORD corg, csize; - SMALL_RECT rcl; - - for (I = 0; I < H; I++) - { - corg.X = corg.Y = 0; - csize.X = W; - csize.Y = 1; - rcl.Left = X; - rcl.Top = I + Y; - rcl.Bottom = I + Y;// + (isWin95 ? 1 : 0); - rcl.Right = X + W - 1;// + (isWin95 ? 1 : 0); - - ReadConsoleOutput(OurConOut, (PCHAR_INFO)p, csize, corg, &rcl); - p += W; - } - return 0; -} - -int ConPutLine(int X, int Y, int W, int H, PCell Cell) /*FOLD00*/ -{ - int I; - COORD corg, csize; - SMALL_RECT rcl; - BOOL rc; - - for (I = 0; I < H; I++) - { - corg.X = corg.Y = 0; - csize.X = W; - csize.Y = 1; - rcl.Left = X; - rcl.Top = I + Y; - rcl.Bottom = I + Y;// + (isWin95 ? 1 : 0); - rcl.Right = X + W - 1;// + (isWin95 ? 1 : 0); - - rc = WriteConsoleOutput(OurConOut, (PCHAR_INFO)Cell, csize, corg, &rcl); - if (rc != TRUE) { - //printf("WriteConsoleOutput %d\n", rc); - } - } - return 0; -} - -int ConSetBox(int X, int Y, int W, int H, TCell Cell) /*FOLD00*/ -{ - int I; - COORD corg, csize; - SMALL_RECT rcl; - TDrawBuffer B; - - I = W; - while (I-- > 0) B[I] = Cell; - - for (I = 0; I < H; I++) - { - corg.X = corg.Y = 0; - csize.X = W; - csize.Y = 1; - rcl.Left = X; - rcl.Top = I + Y; - rcl.Bottom = I + Y;// - (isWin95 ? 1 : 0); - rcl.Right = X + W - 1;// - (isWin95 ? 1 : 0); - - WriteConsoleOutput(OurConOut, (PCHAR_INFO)B, csize, corg, &rcl); - } - return 0; -} - -int ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count) /*FOLD00*/ -{ - TCell FillCell; - SMALL_RECT rect, clip; - COORD dest; - - MoveCh(&FillCell, ' ', Fill, 1); - - clip.Left = X; - clip.Top = Y; - clip.Right = X + W - 1; - clip.Bottom = Y + H - 1; - - rect = clip; - dest.X = X; - dest.Y = Y; - - switch (Way) { - case csUp: - rect.Top += Count; - break; - case csDown: - rect.Bottom -= Count; - dest.Y += Count; - break; - case csLeft: - rect.Left += Count; - break; - case csRight: - rect.Right += Count; - dest.X += Count; - break; - } - - ScrollConsoleScreenBuffer(OurConOut, &rect, &clip, dest, (PCHAR_INFO)&FillCell); - return 0; -} - -int ConSetSize(int X, int Y) { /*FOLD00*/ - return -1; -} - -int ConQuerySize(int *X, int *Y) { /*FOLD00*/ - CONSOLE_SCREEN_BUFFER_INFO csbi; - - GetConsoleScreenBufferInfo(OurConOut, &csbi); - *X = csbi.dwSize.X; - *Y = csbi.dwSize.Y; - - dbg("Console size (%u,%u)\n", *X, *Y); - return 0; -} - -int ConSetCursorPos(int X, int Y) { /*FOLD00*/ - COORD xy; - - xy.X = X; - xy.Y = Y; - SetConsoleCursorPosition(OurConOut, xy); - return 0; -} - -int ConQueryCursorPos(int *X, int *Y) { /*FOLD00*/ - CONSOLE_SCREEN_BUFFER_INFO csbi; - - GetConsoleScreenBufferInfo(OurConOut, &csbi); - *X = csbi.dwCursorPosition.X; - *Y = csbi.dwCursorPosition.Y; - return 0; -} - -int ConShowCursor(void) { /*FOLD00*/ - CursorVisible = 1; - DrawCursor(1); - return 0; -} - -int ConHideCursor(void) { /*FOLD00*/ - CursorVisible = 0; - DrawCursor(0); - return 0; -} - -int ConCursorVisible() { /*FOLD00*/ - return (CursorVisible == 1); -} - -int ConSetCursorSize(int Start, int End) { /*FOLD00*/ - return -1; -} - -int ConSetMousePos(int X, int Y) { /*FOLD00*/ - return -1; -} - -int ConQueryMousePos(int *X, int *Y) { /*FOLD00*/ - *X = LastMouseX; - *Y = LastMouseY; - - // NT does not have this ? (not needed anyway, but check mouse hiding above). - return 0; -} - -int ConShowMouse(void) { /*FOLD00*/ - MouseVisible = 1; - if (!MousePresent) return -1; - return 0; -} - -int ConHideMouse(void) { /*FOLD00*/ - MouseVisible = 0; - if (!MousePresent) return -1; - return 0; -} - -int ConMouseVisible() { /*FOLD00*/ - return (MouseVisible == 1); -} - -int ConQueryMouseButtons(int *ButtonCount) { /*FOLD00*/ - return 0; -} - -int ConPutEvent(TEvent Event) { /*FOLD00*/ - EventBuf = Event; - return 0; -} - -int ConFlush(void) { /*FOLD00*/ - return 0; -} - -int ConGrabEvents(TEventMask EventMask) { /*FOLD00*/ - return 0; -} - - -static PCell SavedScreen = 0; -static int SavedX, SavedY, SaveCursorPosX, SaveCursorPosY; - -int SaveScreen() { /*FOLD00*/ - if (SavedScreen) - free(SavedScreen); - - ConQuerySize(&SavedX, &SavedY); - - SavedScreen = (PCell) malloc(SavedX * SavedY * sizeof(TCell)); - - if (SavedScreen) - ConGetBox(0, 0, SavedX, SavedY, SavedScreen); - ConQueryCursorPos(&SaveCursorPosX, &SaveCursorPosY); - return 0; -} - -int RestoreScreen() { /*FOLD00*/ - if (SavedScreen) { - ConPutBox(0, 0, SavedX, SavedY, SavedScreen); - ConSetCursorPos(SaveCursorPosX, SaveCursorPosY); - } - return 1; -} - - -GUI::GUI(int &argc, char **argv, int XSize, int YSize) { /*FOLD00*/ - fArgc = argc; - fArgv = argv; - ::ConInit(-1, -1); - SaveScreen(); - ::ConSetSize(XSize, YSize); - gui = this; -} - -GUI::~GUI() { /*FOLD00*/ - RestoreScreen(); - - if (SavedScreen) - free(SavedScreen); - - ::ConDone(); - gui = 0; -} - -int GUI::ConSuspend(void) { /*FOLD00*/ - RestoreScreen(); - return ::ConSuspend(); -} - -int GUI::ConContinue(void) { /*FOLD00*/ - SaveScreen(); - return ::ConContinue(); -} - -int GUI::ShowEntryScreen() { /*FOLD00*/ - TEvent E; - - ConHideMouse(); - RestoreScreen(); - SetConsoleActiveScreenBuffer(ConOut); - do { gui->ConGetEvent(evKeyDown, &E, -1, 1, 0); } while (E.What != evKeyDown); - SetConsoleActiveScreenBuffer(OurConOut); - ConShowMouse(); - if (frames) - frames->Repaint(); - return 1; -} - -char ConGetDrawChar(int index) { /*FOLD00*/ - static char tab[] = "Ú¿ÀÙijÂôÁÅ\x1Aúı°\x1B\x1A"; - - assert(index >= 0 && index < (int)strlen(tab)); - - return tab[index]; -} - - -int GUI::RunProgram(int mode, char *Command) { /*FOLD00*/ - int rc, W, H, W1, H1; - - ConQuerySize(&W, &H); - ConHideMouse(); - ConSuspend(); - - if (*Command == 0) // empty string = shell - Command = getenv( - "COMSPEC" - ); - - rc = system(Command); - - ConContinue(); - ConShowMouse(); - ConQuerySize(&W1, &H1); - - if (W != W1 || H != H1) { - frames->Resize(W1, H1); - } - frames->Repaint(); - return rc; -} - -int ConSetTitle(char *Title, char *STitle) { /*FOLD00*/ - return 0; -} - -int ConGetTitle(char *Title, int MaxLen, char *STitle, int SMaxLen) { /*FOLD00*/ - strcpy(Title, "FTE"); - strcpy(STitle, "FTE"); - return 0; -} - - - -#if 0 -/****************************************************************************/ -/* */ -/* CODING: Pipe handler. */ -/* */ -/****************************************************************************/ -/*--------------------------------------------------------------------------*/ -/* STATIC GLOBALS. */ -/*--------------------------------------------------------------------------*/ -#define MAX_PIPES 4 -#define PIPE_BUFLEN 4096 -#define PIPEBUF_SZ 4096 - -class NTHandle -{ -protected: - HANDLE nth_h; - -public: - operator HANDLE() - { return nth_h; - } - - void close() - { if(nth_h != INVALID_HANDLE_VALUE) - { - CloseHandle(nth_h); - nth_h = INVALID_HANDLE_VALUE; - } - } - - - NTHandle() { nth_h = INVALID_HANDLE_VALUE; } - - ~NTHandle() - { close(); - } - - NTHandle(const HANDLE& h) : nth_h(h) {} - NTHandle(const NTHandle& nth); // UNDEFINED (no assgn) - NTHandle& operator =(const NTHandle& nth); // UNDEFINED (no assgn) - NTHandle& operator =(const HANDLE nth) - { close(); - nth_h = nth; - return *this; - } -}; - - -class GPipe -{ -public: - int p_used; - int p_id; - char* p_buffer; - int p_buflen; - int p_bufused; - int p_bufpos; - EModel* p_notify; - char* p_command; - int p_retcode; - int p_doterm; - - //** NT specific. - HANDLE p_proc_h; // Handle of spawned process, - HANDLE pipeDataRead; - HANDLE pipeStartRead; - HANDLE pipeMutex; - HANDLE p_pipe_ph; // Input pipe (read by FTE) - HANDLE p_child_ph; // Client side's handle (written to by spawned) - DWORD p_read_len; // #bytes read in overlapped I/O - int p_io_posted; // T when overlapped I/O is posted, - int p_completed; // T when client process closed down. - int p_has_data; // T when OVERLAPPED completed. - - static GPipe pipe_ar[MAX_PIPES]; - - -public: - int open(char *Command, EModel *notify); - int close(); - int read(void *buffer, int len); - int getEvent(TEvent* event); - - -protected: - int createPipe(); - void releasePipe(); - int runCommand(); - void closeProc(); - int handlePost(); - int postRead(); - - - -public: - static GPipe* getFreePipe(); - static GPipe* getPipe(int id); - -}; - -GPipe GPipe::pipe_ar[MAX_PIPES]; - - -/* - * getFreePipe() locates an unused GPipe structure. It also assigns it's ID. - */ -GPipe* GPipe::getFreePipe() /*FOLD00*/ -{ - int i; - - for(i = 0; i < MAX_PIPES; i++) - { - if(! pipe_ar[i].p_used) - { - pipe_ar[i].p_id = i; // Set pipenr, - return pipe_ar + i; - } - } - return NULL; // No free pipe -} - - -GPipe* GPipe::getPipe(int id) /*FOLD00*/ -{ - if (id < 0 || id > MAX_PIPES) return NULL; - if(! pipe_ar[id].p_used) return NULL; - return pipe_ar + id; -} - - -int GPipe::createPipe() /*FOLD00*/ -{ - /* - * Called from open() to create and open the server and the client pipes. - */ - static int PCount = 0; - //HANDLE hchild; - char pipename[50]; - int ok; - SECURITY_ATTRIBUTES sa; - - sa.nLength = sizeof(sa); // Security descriptor for INHERIT. - sa.lpSecurityDescriptor = 0; - sa.bInheritHandle = 1; - -#if 1 - if (CreatePipe(&p_pipe_ph, &p_child_ph, &sa, 0) == FALSE) - return FALSE; - - Pipes[i].tid = _beginthread(PipeThread, - FAKE_BEGINTHREAD_NULL - 16384, &Pipes[i]); -#else - - //** Create the named pipe, and handle the SERVER (edit)'s end... - sprintf(pipename, "\\\\.\\pipe\\fte%d\\child%d", getpid(), PCount); - p_pipe_ph = CreateNamedPipe(pipename, - PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, - 1, // nMaxInstances, - 0, PIPEBUF_SZ, - 1000, - 0); - if(p_pipe_ph == INVALID_HANDLE_VALUE) - return FALSE; - PCount++; - - /* - * Client side: get a connection to the server's pipe. Do this before the - * call to ConnectNamedPipe() to prevent it from blocking. - */ - -#if 1 - p_child_ph = CreateFile(pipename, GENERIC_WRITE, 0, &sa, - OPEN_EXISTING, 0, 0); -#else - p_child_ph = CreateFile("_test", GENERIC_WRITE|GENERIC_READ, 0, &sa, - CREATE_ALWAYS, 0, 0); -#endif - if(p_child_ph == INVALID_HANDLE_VALUE) - dbm("CreateFile(client_side_pipe) has failed"); - else - { - //** Server side: aquire connection.. - ok = TRUE; - if(! ConnectNamedPipe(p_pipe_ph, 0)) // Get connect; - { - if(GetLastError() != ERROR_PIPE_CONNECTED) - ok = FALSE; - } - - //** Connect worked? - if(!ok) - dbm("ConnectNmPipe() has failed"); - else - return TRUE; // All opened & ready for action! - - //** Something went wrong. - CloseHandle(p_child_ph); // Close child: was inh. - DisconnectNamedPipe(p_pipe_ph); // Force disconnection of client (-) - CloseHandle(p_child_ph); - } - CloseHandle(p_pipe_ph); -#endif - return FALSE; // Something has failed. -} - - -void GPipe::releasePipe() /*FOLD00*/ -{ - /* - * releasePipe() releases all that createPipe() allocates. It's usually - * called when an error causes the process to abort. - */ - if(p_child_ph != INVALID_HANDLE_VALUE) - { - CloseHandle(p_child_ph); - p_child_ph = INVALID_HANDLE_VALUE; - } - - if(p_pipe_ph != 0) - { - //DisconnectNamedPipe(p_pipe_ph); - CloseHandle(p_pipe_ph); - p_pipe_ph = INVALID_HANDLE_VALUE; - } -} - - -int GPipe::runCommand() /*FOLD00*/ -{ - /* - * runCommand() takes the child pipe, dups it onto stdout and stderr while - * saving their old assignments, then it spawns - */ - int ok; - char* comspec, *args, tbuf[256]; - HANDLE errh; - PROCESS_INFORMATION pi; - STARTUPINFO si; - const char nt4[] = "4nt.exe"; - - ok = FALSE; - comspec = getenv("COMSPEC"); - - /* - * BUG workaround: When using 4NT, it doesn't properly reassign stderr! - * This is a bug in 4NT, so if comspec *is* 4nt use cmd.exe instead... - */ - if(comspec == 0) return -1; - int l = strlen(comspec); - if(strnicmp(comspec + (l- sizeof(nt4)+1), nt4, sizeof(nt4)-1) == 0) - { - //** It's 4DOS all right.. - args = getenv("SystemRoot"); - if(args== 0) return -1; - strcpy(tbuf, args); // Get to c:\winnt - strcat(tbuf, "\\system32\\cmd.exe"); - comspec = tbuf; - } - - args = (char *)malloc(strlen(comspec) + strlen(p_command) + 120); - if(args == 0) - dbm("malloc() failed for command line.."); - else - { - //** Form a command line for the process; - strcpy(args, comspec); - strcat(args, " /c "); - strcat(args, p_command); - - //** Dup the child handle to get separate handles for stdout and err, - if (DuplicateHandle(GetCurrentProcess(), p_child_ph, // Source, - GetCurrentProcess(), &errh, // Destination, - 0, True, // Same access, inheritable - DUPLICATE_SAME_ACCESS)); - - { - /* Set up members of STARTUPINFO structure. */ - memset(&si, 0, sizeof(si)); - si.cb = sizeof(STARTUPINFO); - si.lpReserved = NULL; - si.lpReserved2 = NULL; - si.cbReserved2 = 0; - si.lpDesktop = NULL; -/* si.dwFlags = STARTF_USESTDHANDLES; -#if 1 - si.hStdOutput = p_child_ph; - si.hStdError = errh; - si.hStdInput = INVALID_HANDLE_VALUE; -#else - si.hStdOutput = errh; - si.hStdError = p_child_ph; - si.hStdInput = INVALID_HANDLE_VALUE; -#endif*/ - if(CreateProcess(NULL, args, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) - { - ok = TRUE; - CloseHandle(pi.hThread); // Thread handle not needed - p_proc_h = pi.hProcess; // Return process handle (to get RC) - } - CloseHandle(errh); // Close error handle, - } - else - dbm("DupHandle for stderr failed."); - - free(args); // Release command line. - } - - // SetConsoleMode(horgout, ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT); - - //** And last but not least: close the child handle. - CloseHandle(p_child_ph); - p_child_ph = INVALID_HANDLE_VALUE; - return ok; -} - - -void GPipe::closeProc() /*FOLD00*/ -{ - /* - * closeProc() gets called when a read fails. It assumes the process has - * ended, retrieves the process return code, then it closes all handles. - * The state is set to p_completed. - */ - DWORD ec; - - dbg("[closeProc] "); - - if(! GetExitCodeProcess(p_proc_h, &ec)) ec = 0xabcd; - p_retcode = ec; // Save return code of process, - if(p_proc_h != INVALID_HANDLE_VALUE) // Close process, - { - CloseHandle(p_proc_h); - p_proc_h = INVALID_HANDLE_VALUE; - } - - //** Close the main pipe, - if(p_pipe_ph != INVALID_HANDLE_VALUE) - { - CloseHandle(p_pipe_ph); - p_pipe_ph = INVALID_HANDLE_VALUE; - } - p_completed = TRUE; - p_has_data = TRUE; -} - - -int GPipe::startRead() /*FOLD00*/ -{ - /* - * postRead() checks if an overlapped READ needs to be posted by checking - * the io_posted flag. If that's clear and no termination or closed flag - * is set then a new overlapped I/O request is issued. - */ - p_has_data = FALSE; - dbg("[postRead "); - if(p_io_posted || p_completed) - dbg("no action: %s] ", p_io_posted ? "posted" : "complete"); - else - { - p_ovl.hEvent = p_data_evh; // Signal this when done, - if(!ReadFile(p_pipe_ph, p_buffer, p_buflen, &p_read_len, NULL)) - { - DWORD ec = GetLastError(); - if(ec != ERROR_IO_PENDING) - { - //** Something's wrong. Treat as closed pipe for now. - closeProc(); // Close pipe, complete stuff... - dbg("postfail] "); - return FALSE; // And return failure. - } - } - p_io_posted = TRUE; // Handle pending ioresult. - dbg("posted] "); - } - return TRUE; -} - - -int GPipe::open(char* command, EModel* notify) /*FOLD00*/ -{ - memset(&p_ovl, 0, sizeof(p_ovl)); // Clear overlapped, - p_bufused = 0; - p_bufpos = 0; - p_io_posted = FALSE; - p_has_data = FALSE; - p_completed = FALSE; // T if client closed. - p_doterm = FALSE; - p_buflen = PIPE_BUFLEN; - p_notify = notify; - p_doterm = FALSE; - - p_pipe_ph = INVALID_HANDLE_VALUE; - p_child_ph = INVALID_HANDLE_VALUE; - if( (p_command = strdup(command)) == 0) - return -1; - - //** Allocate the read buffer; - if ((p_buffer = (char*) malloc(p_buflen)) != 0) { - if ((pipeDataRead = CreateEvent(0, 1, 0, 0)) == 0) { - dbm("CreateEvent(data_evh) failed."); - goto fail; - } - if ((pipeStartRead = CreateEvent(0, 1, 0, 0)) == 0) { - dbm("CreateEvent(data_evh) failed."); - goto fail; - } - if ((pipeMutex = CreateMutex(NULL, FALSE, NULL)) == NULL) { - dbm("Failed pipe mutex"); - goto fail; - } - - - else - { - if(createPipe()) // Create server & client pipe. - { - if(! postRead()) - dbm("postRead() initial failed."); - else - { - if(runCommand()) - { - p_used = TRUE; - return p_id; - } - } - releasePipe(); // Release pipes, - } - CloseHandle(p_data_evh); - } - free(p_buffer); - } - free(p_command); - return -1; -} - - -int GPipe::close() /*FOLD00*/ -{ - /* - * close() disconnects from the spawned task, closes the pipe and releases - * all stuff. - */ - if(! p_used) return -1; - if(! p_completed) // Overlapped I/O not complete yet? - { - //** We *must* wait till the overlapped I/O completes, - if(p_io_posted) - { - GetOverlappedResult(p_pipe_ph, &p_ovl, &p_read_len, TRUE); - p_io_posted = FALSE; - } - } - p_completed= TRUE; - - //** Now close all that might be pending, - free(p_buffer); - free(p_command); - - releasePipe(); // Close all pipe stuff, - if(p_proc_h != INVALID_HANDLE_VALUE) - { - CloseHandle(p_proc_h); - p_proc_h = INVALID_HANDLE_VALUE; - } - - CloseHandle(pipeStartRead); - CloseHandle(pipeDataRead); - CloseHandle(pipeMutex); - - p_used = FALSE; - return p_retcode; -} - - -int GPipe::read(void *buffer, int len) /*FOLD00*/ -{ - /* - * read() is called to get the current data from the pipe. It takes the - * #bytes read and returns them. It returns data till the buffer is - * exhausted. If the process is completed it returns -1; else it returns - * the #bytes read. It returns 0 if the buffer's empty. - */ - dbg("[read "); - if(p_has_data) - { - if(p_bufpos < p_read_len) // Data in buffer? - { - unsigned l; - - l = p_read_len - p_bufpos; // Try to output all, - if(l > len) l = len; - memcpy(buffer, p_buffer+p_bufpos, l); // Copy data from the buffer, - p_bufpos += l; - dbg("%u data] ", l); - return l; // Data returned, - } - - //** There's nothing left in the buffer. Is the task complete? - if(p_completed) - { - dbg("no data, complete] "); - return -1; - } - - if(! postRead()) - { - dbg("post failed-> complete] "); - return -1; - } - - dbg("nodata, post] "); - return 0; - } - else if(p_completed) - { - dbg("completed] "); - return -1; - } - - dbg("nothing] "); - return 0; -} - - -int GPipe::getEvent(TEvent* event) /*FOLD00*/ -{ - dbg("[getpipeevent: "); - event->What = evNone; - - if(! p_used || p_notify == 0) return 0; // No data. - if(! handlePost()) return 0; // Again: no data, - //** This pipe has data! - event->What = evNotify; - event->Msg.View = 0; - event->Msg.Model = p_notify; - event->Msg.Command = cmPipeRead; - event->Msg.Param1 = p_id; - dbg("ok] "); - return 1; -} - - -/* - * NT Pipe handler - overview - * ========================== - * The NT pipe handler uses overlapped I/O to read console events. - * - * OpenPipe(): - * When the pipe is opened, one of the pipe structures is allocated and set - * to used. Then an event semaphore (reset_manual) is created. This semaphore - * will be signalled when data is available on the input pipe which gathers - * the spawned tasks's output. - * - * Then a pipe is created, opened for the client side and stdout and stderr - * are redirected therein. After that the client task is spawned. - * - * If the spawn succeeds an overlapped READ is posted for the pipe; then the - * OpenPipe function returns. - * - * ConGetEvent(): - * The ConGetEvent() handler does a WaitForMultipleObjects() on the console - * handle and all pipe handles currently active. If a pipe has data the - * overlapped result is gotten, and the output is sent to the message window. - * Then, if the thread didn't finish, a new overlapped read is posted. - * - * - */ -int GUI::OpenPipe(char *Command, EModel *notify) /*FOLD00*/ -{ - GPipe* gp; - - if( (gp = GPipe::getFreePipe()) == 0) - return -1; // Out of pipes. - return gp->open(Command, notify); // And ask the pipe to init. -} - - -int GUI::SetPipeView(int id, EModel *notify) /*FOLD00*/ -{ - GPipe* p; - - if( (p = GPipe::getPipe(id)) == 0) return -1; - p->lock(); - p->p_notify = notify; - p->unlock(); - return 0; -} - - -int GUI::ReadPipe(int id, void *buffer, int len) /*FOLD00*/ -{ - //int l; - GPipe* p; - - if( (p = GPipe::getPipe(id)) == 0) return -1; - return p->read(buffer, len); -} - - -int GUI::ClosePipe(int id) /*FOLD00*/ -{ - GPipe* p; - - if( (p = GPipe::getPipe(id)) == 0) return -1; - return p->close(); -} - - -static int GetPipeEvent(int id, TEvent *Event) /*FOLD00*/ -{ - //int i; - GPipe* p; - - if( (p = GPipe::getPipe(id)) == 0) return -1; - return p->getEvent(Event); -} - -#else - -#define MAX_PIPES 4 -#define PIPE_BUFLEN 4096 - -typedef struct { - int used; - int id; - int reading, stopped; - HANDLE Thread; - HANDLE Access; - HANDLE ResumeRead; - HANDLE NewData; - char *buffer; - int buflen; - int bufused; - int bufpos; - EModel *notify; - char *Command; - DWORD RetCode; - int DoTerm; -} GPipe; - -static GPipe Pipes[MAX_PIPES] = { - { 0 }, { 0 }, { 0 }, { 0 } -}; - -static int CreatePipeChild(HANDLE &child, HANDLE &hPipe, char *Command) { - static int PCount = 0; - int arglen = 0; - HANDLE hChildPipe; - BOOL rc; - - SECURITY_ATTRIBUTES sa; - - sa.nLength = sizeof(sa); // Security descriptor for INHERIT. - sa.lpSecurityDescriptor = 0; - sa.bInheritHandle = 1; - - rc = CreatePipe(&hPipe, &hChildPipe, &sa, 0); - if (rc != TRUE) - return -1; - - int ok; - char* comspec, *args, tbuf[256]; - //HANDLE errh; - PROCESS_INFORMATION pi; - STARTUPINFO si; - HANDLE hNul; - const char nt4[] = "4nt.exe"; - - ok = FALSE; - comspec = getenv("COMSPEC"); - - /* - * BUG workaround: When using 4NT, it doesn't properly reassign stderr! - * This is a bug in 4NT, so if comspec *is* 4nt use cmd.exe instead... - */ - if (comspec == 0) - return -1; - int l = strlen(comspec); - if (strnicmp(comspec + (l- sizeof(nt4)+1), nt4, sizeof(nt4)-1) == 0) - { - //** It's 4DOS all right.. - args = getenv("SystemRoot"); - if(args== 0) return -1; - strcpy(tbuf, args); // Get to c:\winnt - strcat(tbuf, "\\system32\\cmd.exe"); - comspec = tbuf; - } - - args = (char *)malloc(strlen(comspec) + strlen(Command) + 120); - if(args == 0) - dbm("malloc() failed for command line.."); - else - { - //** Form a command line for the process; - strcpy(args, comspec); - strcat(args, " /c "); - strcat(args, Command); - - //** Dup the child handle to get separate handles for stdout and err, - /*if (DuplicateHandle(GetCurrentProcess(), hChildPipe, - GetCurrentProcess(), &errh, - 0, True, DUPLICATE_SAME_ACCESS))*/ - //fprintf(stderr, "open NUL\n"); - - hNul = CreateFile("NUL", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, OPEN_EXISTING, - 0, - NULL); - //fprintf(stderr, "starting %s\n", args); - - if (hNul != NULL) { - /* Set up members of STARTUPINFO structure. */ - memset(&si, 0, sizeof(si)); - si.cb = sizeof(STARTUPINFO); - si.lpReserved = NULL; - si.lpReserved2 = NULL; - si.cbReserved2 = 0; - si.lpDesktop = NULL; - si.dwFlags = STARTF_USESTDHANDLES; -#if 1 - si.hStdOutput = hChildPipe; - si.hStdError = hChildPipe; - si.hStdInput = hNul;//INVALID_HANDLE_VALUE; -#else - si.hStdOutput = errh; - si.hStdError = hChildPipe; - si.hStdInput = INVALID_HANDLE_VALUE; -#endif - if (CreateProcess(NULL, args, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi) == TRUE) - { - ok = TRUE; - CloseHandle(pi.hThread); // Thread handle not needed - //fprintf(stderr, "create process success\n"); - child = pi.hProcess; // Return process handle (to get RC) - } else - //fprintf(stderr, "create process failed %d\n" + GetLastError()); - CloseHandle(hNul); // Close error handle, - } - else - dbm("DupHandle for stderr failed."); - - free(args); - } - - CloseHandle(hChildPipe); - return 0; -} - -static DWORD __stdcall PipeThread(void *p) { - GPipe *pipe = (GPipe *)p; - BOOL rc; - DWORD used; - HANDLE child; - HANDLE hfPipe; - - rc = CreatePipeChild(child, hfPipe, pipe->Command); - - if (rc != 0) { - //fprintf(stderr, "Failed CreatePipeChild\n"); - WaitForSingleObject(pipe->Access, INFINITE); - pipe->reading = 0; - SetEvent(pipe->NewData); - ReleaseMutex(pipe->Access); - return 0xFFFFFFFF; - } - - //fprintf(stderr, "Pipe: Begin: %d %s\n", pipe->id, pipe->Command); - while (1) { - //fprintf(stderr, "Waiting on pipe\n"); - rc = ReadFile(hfPipe, pipe->buffer, pipe->buflen, &used, NULL); - if (rc != TRUE) { - //fprintf(stderr, "ReadFile failed %d %ld", GetLastError(), used); - used = 0; - } - - WaitForSingleObject(pipe->Access, INFINITE); - //fprintf(stderr, "Waiting on mutex\n"); - pipe->bufused = used; - //fprintf(stderr, "Pipe: fread: %d %d\n", pipe->id, pipe->bufused); - ResetEvent(pipe->ResumeRead); - if (pipe->bufused == 0) - break; - if (pipe->notify) { - SetEvent(pipe->NewData); - pipe->stopped = 0; - } - ReleaseMutex(pipe->Access); - if (pipe->DoTerm) - break; - //fprintf(stderr, "Waiting on sem\n"); - WaitForSingleObject(pipe->ResumeRead, INFINITE); - //fprintf(stderr, "Read: Released mutex\n"); - if (pipe->DoTerm) - break; - } - CloseHandle(hfPipe); - //fprintf(stderr, "Pipe: pClose: %d\n", pipe->id); - rc = WaitForSingleObject(child, INFINITE); - GetExitCodeProcess(child, &pipe->RetCode); - CloseHandle(child); - pipe->reading = 0; - SetEvent(pipe->NewData); - ReleaseMutex(pipe->Access); - //fprintf(stderr, "Read: Released mutex\n"); - return 0; -} - -int GUI::OpenPipe(char *Command, EModel *notify) { - int i; - - for (i = 0; i < MAX_PIPES; i++) { - if (Pipes[i].used == 0) { - Pipes[i].reading = 1; - Pipes[i].stopped = 1; - Pipes[i].id = i; - Pipes[i].bufused = 0; - Pipes[i].bufpos = 0; - Pipes[i].buflen = PIPE_BUFLEN; - Pipes[i].Command = strdup(Command); - Pipes[i].notify = notify; - Pipes[i].DoTerm = 0; - if ((Pipes[i].buffer = (char *)malloc(PIPE_BUFLEN)) == 0) - return -1; - - if ((Pipes[i].Access = CreateMutex(NULL, FALSE, NULL)) == NULL) { - free(Pipes[i].Command); - free(Pipes[i].buffer); - return -1; - } - - if ((Pipes[i].ResumeRead = CreateEvent(0, 1, 0, 0)) == NULL) { - free(Pipes[i].Command); - free(Pipes[i].buffer); - CloseHandle(Pipes[i].Access); - return -1; - } - - if ((Pipes[i].NewData = CreateEvent(0, 1, 0, 0)) == NULL) { - free(Pipes[i].Command); - free(Pipes[i].buffer); - CloseHandle(Pipes[i].ResumeRead); - CloseHandle(Pipes[i].Access); - return -1; - } - - DWORD tid; - - if ((Pipes[i].Thread = CreateThread(NULL, 32768, - &PipeThread, &Pipes[i], - 0, &tid)) == NULL) - { - free(Pipes[i].Command); - free(Pipes[i].buffer); - CloseHandle(Pipes[i].ResumeRead); - CloseHandle(Pipes[i].Access); - CloseHandle(Pipes[i].NewData); - return -1; - } - Pipes[i].used = 1; - //fprintf(stderr, "Pipe Open: %d\n", i); - return i; - } - } - return -1; -} - -int GUI::SetPipeView(int id, EModel *notify) { - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - WaitForSingleObject(Pipes[id].Access, INFINITE); - //fprintf(stderr, "Pipe View: %d %08X\n", id, notify); - Pipes[id].notify = notify; - ReleaseMutex(Pipes[id].Access); - return 0; -} - -int GUI::ReadPipe(int id, void *buffer, int len) { - int l; - //ULONG ulPostCount; - - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - //fprintf(stderr, "Read: Waiting on mutex\n"); - //ConContinue(); - WaitForSingleObject(Pipes[id].Access, INFINITE); - //fprintf(stderr, "Pipe Read: Get %d %d\n", id, len); - if (Pipes[id].bufused - Pipes[id].bufpos > 0) { - l = len; - if (l > Pipes[id].bufused - Pipes[id].bufpos) { - l = Pipes[id].bufused - Pipes[id].bufpos; - } - memcpy(buffer, - Pipes[id].buffer + Pipes[id].bufpos, - l); - Pipes[id].bufpos += l; - if (Pipes[id].bufpos == Pipes[id].bufused) { - Pipes[id].bufused = 0; - Pipes[id].bufpos = 0; - //fprintf(stderr, "Pipe Resume Read: %d\n", id); - Pipes[id].stopped = 1; - //fprintf(stderr, "Read: posting sem\n"); - SetEvent(Pipes[id].ResumeRead); - } - } else if (Pipes[id].reading == 0) - l = -1; - else { - l = 0; -// DosBeep(200, 200); - } - //fprintf(stderr, "Pipe Read: Got %d %d\n", id, l); - ReleaseMutex(Pipes[id].Access); - //fprintf(stderr, "Read: Released mutex\n"); - return l; -} - -int GUI::ClosePipe(int id) { - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - if (Pipes[id].reading == 1) { - Pipes[id].DoTerm = 1; - SetEvent(Pipes[id].ResumeRead); - WaitForSingleObject(&Pipes[id].Thread, INFINITE); - } - free(Pipes[id].buffer); - free(Pipes[id].Command); - CloseHandle(Pipes[id].NewData); - CloseHandle(Pipes[id].ResumeRead); - CloseHandle(Pipes[id].Access); - CloseHandle(Pipes[id].Thread); - //fprintf(stderr, "Pipe Close: %d\n", id); - Pipes[id].used = 0; - //ConContinue(); - return Pipes[id].RetCode; -} - -int GetPipeEvent(int i, TEvent *Event) { - Event->What = evNone; - if (Pipes[i].used == 0) return 0; - if (Pipes[i].notify == 0) return 0; - ResetEvent(Pipes[i].NewData); - //fprintf(stderr, "Pipe New Data: %d\n", i); - Event->What = evNotify; - Event->Msg.View = 0; - Event->Msg.Model = Pipes[i].notify; - Event->Msg.Command = cmPipeRead; - Event->Msg.Param1 = i; - return 1; -} - -#endif - -int ConGetEvent(TEventMask EventMask, TEvent *Event, int WaitTime, int Delete) /*FOLD00*/ -{ - //** Any saved events left? - if (EventBuf.What != evNone) - { - *Event = EventBuf; - if (Delete) EventBuf.What = evNone; - return 0; - } - if (MouseEv.What != evNone) - { - *Event = MouseEv; - if (Delete) MouseEv.What = evNone; - return 0; - } - - //** Now block and wait for a new event on the console handle and all pipes, - HANDLE o_ar[1 + MAX_PIPES]; - DWORD rc; - int i, nh; - - EventBuf.What = evNone; - Event->What = evNone; - - //** Fill the handle array with all active handles for pipes && console, - o_ar[0] = ConIn; - for(i = 0, nh = 1; i < MAX_PIPES; i++) // For all possible pipes - { - if (Pipes[i].used) - o_ar[nh++] = Pipes[i].NewData; - } - - for(;;) - { - rc = WaitForMultipleObjects(nh, o_ar, FALSE, WaitTime); - if(rc != WAIT_FAILED && (rc >= WAIT_OBJECT_0 && rc < WAIT_OBJECT_0+nh)) - { - i = rc - WAIT_OBJECT_0; // Get item that signalled new data - if(i == 0) // Was console? - { - if(ReadConsoleEvent(Event)) // Get console, - return 0; // And exit if valid, - } - else - { - GetPipeEvent(i - 1, Event); // Read data from pipe. - return 0; - } - } - else - return -1; // Something's wrong! - } -} - -#include "clip.h" - -int GetClipText(ClipData *cd) { - int rc = -1; - cd->fLen = 0; - cd->fChar = NULL; - if (OpenClipboard(NULL)) { - HANDLE hmem; - - if ((hmem = GetClipboardData(CF_TEXT)) != NULL) { - LPVOID data; - - if ((data = GlobalLock(hmem)) != NULL) { - int len = strlen((char *)data); - - cd->fChar = (char *)malloc(len); - if (cd->fChar != NULL) { - cd->fLen = len; - memcpy(cd->fChar, data, len); - rc = 0; - } - GlobalUnlock(hmem); - } - } - CloseClipboard(); - } - return rc; -} - -int PutClipText(ClipData *cd) { - int rc = -1; - if (OpenClipboard(NULL)) { - if (EmptyClipboard()) { - HGLOBAL hmem; - - if ((hmem = GlobalAlloc(GMEM_MOVEABLE, cd->fLen + 1)) != NULL) { - LPVOID data; - - if ((data = GlobalLock(hmem)) != NULL) { - memcpy(data, cd->fChar, cd->fLen); - ((char *)data)[cd->fLen] = 0; - GlobalUnlock(hmem); - if (SetClipboardData(CF_TEXT, hmem)) { - rc = 0; - } - } - } - } - CloseClipboard(); - } - return rc; -} diff --git a/src/con_os2.cpp b/src/con_os2.cpp deleted file mode 100644 index 6ab4869..0000000 --- a/src/con_os2.cpp +++ /dev/null @@ -1,1226 +0,0 @@ -/* con_os2.cpp - * - * Copyright (c) 1994-1998, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -// include - -#include -#include -#include -#include -#include - -#include "sysdep.h" -#include "console.h" -#include "gui.h" - -extern int ShowVScroll; - -//#define INCL_NOPM -//#define INCL_WINSWITCHLIST -#define INCL_WIN -#define INCL_SUB -#define INCL_KBD -#define INCL_VIO -#define INCL_MOU -#define INCL_BASE -#define INCL_DOS -#define INCL_DOSDEVIOCTL - -#include -#include - -#ifndef OS2_INCLUDED -#include -#endif - -#define MAX_PIPES 4 -#define PIPE_BUFLEN 4096 - -typedef struct { - int used; - int id; - int reading, stopped; - TID tid; - HMTX Access; - HEV ResumeRead; - HEV NewData; - char *buffer; - int buflen; - int bufused; - int bufpos; - EModel *notify; - char *Command; - int RetCode; - int DoTerm; -} GPipe; - -static GPipe Pipes[MAX_PIPES] = { - { 0 }, { 0 }, { 0 }, { 0 } -}; - -static long MouseAutoDelay = 400; -static long MouseAutoRepeat = 5; -static long MouseMultiClick = 300; - -static int Initialized = 0; -static int MousePresent = 0; -static int CursorVisible = 1; /* 1 means visible */ -static int MouseVisible = 0; /* 0 means hidden */ -static TEvent MouseEv = { evNone }; -static TEvent EventBuf = { evNone }; -static HMOU MouseHandle = 0; -static KBDINFO SaveKbdState; - -// misc - -static void DrawCursor(int Show) { - VIOCURSORINFO vci; - VioGetCurType(&vci, 0); - if (Show == 1) - vci.attr = 1; - else - vci.attr = (SHORT)-1; - VioSetCurType(&vci, 0); -} - -static void DrawMouse(int Show) { - if (!MousePresent) return; - if (Show == 1) { - MouDrawPtr(MouseHandle); - } else { - NOPTRRECT npr; - int W, H; - - npr.row = 0; - npr.col = 0; - ConQuerySize(&W, &H); - npr.cCol = (USHORT) (W - 1); - npr.cRow = (USHORT) (H - 1); - MouRemovePtr(&npr, MouseHandle); - } -} - -static struct { // TransCharScan - USHORT CharScan; - TKeyCode KeyCode; -} TransCharScan[] = { - { 0x0100, kbEsc }, { 0x011B, kbEsc }, - { 0x1C0D, kbEnter }, { 0x1C0A, kbEnter }, - { 0x1C00, kbEnter }, { 0xE00D, kbEnter | kfGray }, - { 0xA600, kbEnter | kfGray }, { 0xE00A, kbEnter | kfGray }, - { 0x0E08, kbBackSp }, { 0x0E7F, kbBackSp }, - { 0x0E00, kbBackSp }, { 0x0F09, kbTab }, - { 0x9400, kbTab }, { 0xA500, kbTab }, - { 0x0F00, kbTab }, { 0x4E00, '+' | kfGray }, - { 0x9000, '+' | kfGray }, { 0x4E2B, '+' | kfGray }, - { 0x4A00, '-' | kfGray }, { 0x8E00, '-' | kfGray }, - { 0x4A2D, '-' | kfGray }, { 0x3700, '*' | kfGray }, - { 0x9600, '*' | kfGray }, { 0x372A, '*' | kfGray }, - { 0xE02F, '/' | kfGray }, { 0xA400, '/' | kfGray }, - { 0x9500, '/' | kfGray }, { 0x0300, 0 } -}; - -static struct { // TransScan - int ScanCode; - TKeyCode KeyCode; -} TransScan[] = { - { 0x78, '1' }, { 0x79, '2' }, { 0x7A, '3' }, { 0x7B, '4' }, { 0x7C, '5' }, - { 0x7D, '6' }, { 0x7E, '7' }, { 0x7F, '8' }, { 0x80, '9' }, { 0x81, '0' }, - - { 0x10, 'Q' }, { 0x11, 'W' }, { 0x12, 'E' }, { 0x13, 'R' }, { 0x14, 'T' }, - { 0x15, 'Y' }, { 0x16, 'U' }, { 0x17, 'I' }, { 0x18, 'O' }, { 0x19, 'P' }, - - { 0x1E, 'A' }, { 0x1F, 'S' }, { 0x20, 'D' }, { 0x21, 'F' }, { 0x22, 'G' }, - { 0x23, 'H' }, { 0x24, 'J' }, { 0x25, 'K' }, { 0x26, 'L' }, - - { 0x2C, 'Z' }, { 0x2D, 'X' }, { 0x2E, 'C' }, { 0x2F, 'V' }, { 0x30, 'B' }, - { 0x31, 'N' }, { 0x32, 'M' }, - - { 0x29, '`' }, { 0x82, '-' }, { 0x83, '=' }, { 0x2B, '\\' }, { 0x1A, '[' }, - { 0x1B, ']' }, { 0x27, ';' }, { 0x28, '\'' }, { 0x33, ',' }, { 0x34, '.' }, - { 0x35, '/' }, { 0x37, '*' }, { 0x4E, '+' }, { 0x4A, '-' }, - - { 0x3B, kbF1 }, { 0x3C, kbF2 }, { 0x3D, kbF3 }, - { 0x3E, kbF4 }, { 0x3F, kbF5 }, { 0x40, kbF6 }, - { 0x41, kbF7 }, { 0x42, kbF8 }, { 0x43, kbF9 }, - { 0x44, kbF10 }, { 0x85, kbF11 }, { 0x86, kbF12 }, - - { 0x54, kbF1 }, { 0x55, kbF2 }, { 0x56, kbF3 }, - { 0x57, kbF4 }, { 0x58, kbF5 }, { 0x59, kbF6 }, - { 0x5A, kbF7 }, { 0x5B, kbF8 }, { 0x5C, kbF9 }, - { 0x5D, kbF10 }, { 0x87, kbF11 }, { 0x88, kbF12 }, - - { 0x5E, kbF1 }, { 0x5F, kbF2 }, { 0x60, kbF3 }, - { 0x61, kbF4 }, { 0x62, kbF5 }, { 0x63, kbF6 }, - { 0x64, kbF7 }, { 0x65, kbF8 }, { 0x66, kbF9 }, - { 0x67, kbF10 }, { 0x89, kbF11 }, { 0x8A, kbF12 }, - - { 0x68, kbF1 }, { 0x69, kbF2 }, { 0x6A, kbF3 }, - { 0x6B, kbF4 }, { 0x6C, kbF5 }, { 0x6D, kbF6 }, - { 0x6E, kbF7 }, { 0x6F, kbF8 }, { 0x70, kbF9 }, - { 0x71, kbF10 }, { 0x8B, kbF11 }, { 0x8C, kbF12 }, - - { 0x47, kbHome }, { 0x48, kbUp }, { 0x49, kbPgUp }, - { 0x4B, kbLeft }, { 0x4C, kbCenter}, { 0x4D, kbRight }, - { 0x4F, kbEnd }, { 0x50, kbDown }, { 0x51, kbPgDn }, - { 0x52, kbIns }, { 0x53, kbDel }, - - { 0x77, kbHome }, { 0x8D, kbUp }, { 0x84, kbPgUp }, - { 0x73, kbLeft }, { 0x74, kbRight }, - { 0x75, kbEnd }, { 0x91, kbDown }, { 0x76, kbPgDn }, - { 0x92, kbIns }, { 0x93, kbDel }, - - { 0x97, kbHome | kfGray }, { 0x98, kbUp | kfGray }, { 0x99, kbPgUp | kfGray }, - { 0x9B, kbLeft | kfGray }, { 0x9D, kbRight | kfGray }, - { 0x9F, kbEnd | kfGray }, { 0xA0, kbDown | kfGray }, { 0xA1, kbPgDn | kfGray }, - { 0xA2, kbIns | kfGray }, { 0xA3, kbDel | kfGray } -}; - -int ReadKbdEvent(TEvent *Event, int Wait) { - KBDKEYINFO ki; - UCHAR CharCode, ScanCode; - ULONG KeyCode, KeyFlags; - USHORT CharScan, Flags; - static USHORT PrevFlags = 0; - unsigned int I; - - Event->What = evNone; - KbdCharIn(&ki, IO_NOWAIT, 0); - if (!(ki.fbStatus & 0x40)) return 0; - - Event->What = evKeyDown; - - CharCode = ki.chChar; - ScanCode = ki.chScan; - CharScan = (USHORT)((((USHORT)ScanCode) << 8) | ((USHORT)CharCode)); - Flags = ki.fsState; - KeyCode = 0; - KeyFlags = 0; - -/* printf("Key: %X %X %X %X %X \n", (unsigned long) ki.bNlsShift, (unsigned long) ki.fbStatus, (unsigned long) Flags, (unsigned long) CharCode, (unsigned long) ScanCode);*/ - - if ((Flags & (LEFTSHIFT | RIGHTSHIFT)) != 0) KeyFlags |= kfShift; - if ((Flags & (LEFTCONTROL | RIGHTCONTROL)) != 0) KeyFlags |= kfCtrl; - -/* cpCount = sizeof(cpList);*/ -/* rc = DosQueryCp(sizeof(cpList), cpList, &cpCount); // get active code page*/ - if (CharCode != 0) { - if ((Flags & (LEFTALT)) != 0) KeyFlags |= kfAlt; - } else { - if ((Flags & (LEFTALT | RIGHTALT)) != 0) KeyFlags |= kfAlt; - } -/* if (rc != 0) printf("rc = %d\n", rc);*/ - - if (CharScan == 0) { /* shift/alt/ctrl/caps/scroll/num */ - - } else if (ScanCode == 0) { /* alt numeric */ - KeyCode = CharCode; - KeyFlags |= kfAltXXX; - } else { /* now check special combinations */ - for (I = 0; I < sizeof(TransCharScan)/sizeof(TransCharScan[0]); I++) - if (TransCharScan[I].CharScan == CharScan) { - KeyCode = TransCharScan[I].KeyCode; - break; - } - if (KeyCode == 0) { - if ((CharCode == 0) || (CharCode == 0xE0)) { - if (CharCode == 0xE0) - KeyFlags |= kfGray; - for (I = 0; I < sizeof(TransScan)/sizeof(TransScan[0]); I++) - if (TransScan[I].ScanCode == ScanCode) { - KeyCode = TransScan[I].KeyCode; - break; - } - } else { - if (CharCode < 32) - if (KeyFlags & kfCtrl) - CharCode += 64; - KeyCode = CharCode; - } - } - } - Event->Key.Code = KeyCode | KeyFlags; - PrevFlags = Flags; - return 1; -} - -#define TM_DIFF(x,y) ((long)(((long)(x) < (long)(y)) ? ((long)(y) - (long)(x)) : ((long)(x) - (long)(y)))) - -int ReadMouseEvent(TEvent *Event, ULONG EventMask) { - static unsigned short PrevState = 0; - static unsigned short PrevButtons = 0; - static TEvent LastMouseEvent = { evNone }; - static ULONG LastEventTime = 0; - static ULONG LastClick = 0; - static ULONG LastClickTime = 0; - static ULONG LastClickCount = 0; - MOUEVENTINFO mi; - unsigned short Buttons, State, Btn; - USHORT fWait = MOU_NOWAIT; - MOUQUEINFO mq; - ULONG CurTime; - - DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &CurTime, 4); - - Event->What = evNone; - MouGetNumQueEl(&mq, MouseHandle); - if (mq.cEvents == 0) { - if (LastMouseEvent.What == evMouseAuto && (EventMask & evMouseAuto)) { - if (TM_DIFF(CurTime, LastEventTime) >= MouseAutoRepeat) { - *Event = LastMouseEvent; - DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &LastEventTime, 4); - return 1; - } - } - if ((LastMouseEvent.What == evMouseDown || LastMouseEvent.What == evMouseMove) - && - (LastMouseEvent.Mouse.Buttons) - && (EventMask & evMouseAuto)) - { - if (TM_DIFF(CurTime, LastEventTime) >= MouseAutoDelay) { - LastMouseEvent.What = evMouseAuto; - *Event = LastMouseEvent; - DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &LastEventTime, 4); - return 1; - } - } - return 0; - } - - if (MouReadEventQue(&mi, &fWait, MouseHandle) != 0) return 0; - Event->Mouse.X = mi.col; - Event->Mouse.Y = mi.row; - State = mi.fs; - Btn = Buttons = ((State & (2 | 4))?1:0) | - ((State & (8 | 16))?2:0) | - ((State & (32 | 64))?4:0); - if (Buttons != PrevButtons) { - Buttons ^= PrevButtons; - if (PrevButtons & Buttons) - Event->What = evMouseUp; - else - Event->What = evMouseDown; - } else { - Event->What = evMouseMove; - if (Event->Mouse.X == LastMouseEvent.Mouse.X && - Event->Mouse.Y == LastMouseEvent.Mouse.Y) - return 0; - } - Event->Mouse.Buttons = Buttons; - Event->Mouse.Count = 1; - PrevState = State; - PrevButtons = Btn; - - if (Event->What == evMouseDown) { - if (LastClickCount) { - if (LastClick == Event->Mouse.Buttons) { - if (TM_DIFF(CurTime, LastClickTime) <= MouseMultiClick) { - Event->Mouse.Count = ++LastClickCount; - } else { - LastClickCount = 0; - } - } else { - LastClick = 0; - LastClickCount = 0; - LastClickTime = 0; - } - } - - LastClick = Event->Mouse.Buttons; - if (LastClickCount == 0) - LastClickCount = 1; - DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &LastClickTime, 4); - } -/* if (Event->What == evMouseMove) { - LastClick = 0; - LastClickCount = 0; - LastClickTime = 0; - }*/ - { - KBDINFO ki; - USHORT Flags; - TKeyCode KeyFlags = 0; - - ki.cb = sizeof(ki); - KbdGetStatus(&ki, 0); - Flags = ki.fsState; - - if ((Flags & (LEFTSHIFT | RIGHTSHIFT)) != 0) KeyFlags |= kfShift; - if ((Flags & (LEFTCONTROL | RIGHTCONTROL)) != 0) KeyFlags |= kfCtrl; - if ((Flags & (LEFTALT | RIGHTALT)) != 0) KeyFlags |= kfAlt; - - Event->Mouse.KeyMask = KeyFlags; - } - - LastMouseEvent = *Event; - DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &LastEventTime, 4); - return 1; -} - - -int ConClear() { - int W, H; - TDrawBuffer B; - - MoveChar(B, 0, ConMaxCols, ' ', 0x07, 1); - if ((ConQuerySize(&W, &H) == 0) && - ConSetBox(0, 0, W, H, B[0])) return 0; - return -1; -} - -int ConPutBox(int X, int Y, int W, int H, PCell Cell) { - int I; - int MX, MY; - int MouseHidden = 0; - unsigned char *p = (unsigned char *) Cell; - if (MouseVisible) - ConQueryMousePos(&MX, &MY); - - for (I = 0; I < H; I++) { - if (MouseVisible) - if (Y + I == MY) - if ((MX >= X) && (MX <= X + W)) { - DrawMouse(0); - MouseHidden = 1; - } - VioWrtCellStr((PCH)p, (USHORT)(W << 1), (USHORT)(Y + I), (USHORT)X, 0); - - if (MouseHidden) { - DrawMouse(1); - MouseHidden = 0; - } - p += W << 1; - } - return 0; -} - -int ConGetBox(int X, int Y, int W, int H, PCell Cell) { - int I; - int MX, MY; - int MouseHidden = 0; - USHORT WW = (USHORT)(W << 1); - unsigned char *p = (unsigned char *) Cell; - - if (MouseVisible) - ConQueryMousePos(&MX, &MY); - - for (I = 0; I < H; I++) { - if (MouseVisible) - if (Y + I == MY) - if (MX >= X && MX < X + W) { - DrawMouse(0); - MouseHidden = 1; - } - VioReadCellStr((PCH)p, &WW, (USHORT)(Y + I), (USHORT)X, 0); - - if (MouseHidden) { - DrawMouse(1); - MouseHidden = 0; - } - p += W << 1; - } - return 0; -} - -int ConPutLine(int X, int Y, int W, int H, PCell Cell) { - int I; - int MX, MY; - int MouseHidden = 0; - unsigned char *p = (unsigned char *) Cell; - if (MouseVisible) - ConQueryMousePos(&MX, &MY); - - for (I = 0; I < H; I++) { - if (MouseVisible) - if (Y + I == MY) - if (MX >= X && MX < X + W) { - DrawMouse(0); - MouseHidden = 1; - } - VioWrtCellStr((PCH)p, (USHORT)(W << 1), (USHORT)(Y + I), (USHORT)X, 0); - - if (MouseHidden) { - DrawMouse(1); - MouseHidden = 0; - } - } - return 0; -} - -int ConSetBox(int X, int Y, int W, int H, TCell Cell) { - int I; - int MX, MY; - int MouseHidden = 0; - unsigned char *p = (unsigned char *) &Cell; - if (MouseVisible) - ConQueryMousePos(&MX, &MY); - - for (I = 0; I < H; I++) { - if (MouseVisible) - if (Y + I == MY) - if (MX >= X && MX < X + W) { - DrawMouse(0); - MouseHidden = 1; - } - VioWrtNCell((PCH)p, (USHORT)(W), (USHORT)(Y + I), (USHORT)X, 0); - - if (MouseHidden) { - DrawMouse(1); - MouseHidden = 0; - } - } - return 0; -} - -int ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count) { - int MX, MY; - int MouseHidden = 0; - TCell FillCell = (TCell)(Fill << 8); - - if (MousePresent && MouseVisible) { - ConQueryMousePos(&MX, &MY); - if (MX >= X && MX < X + W && MY >= Y && MY < Y + H) { - DrawMouse(0); - MouseHidden = 1; - } - } - - switch (Way) { - case csUp: - VioScrollUp((USHORT)Y, (USHORT)X, (USHORT)(Y + H - 1), (USHORT)(X + W - 1), (USHORT)Count, (PBYTE)&FillCell, 0); - break; - case csDown: - VioScrollDn((USHORT)Y, (USHORT)X, (USHORT)(Y + H - 1), (USHORT)(X + W - 1), (USHORT)Count, (PBYTE)&FillCell, 0); - break; - case csLeft: - VioScrollLf((USHORT)Y, (USHORT)X, (USHORT)(Y + H - 1), (USHORT)(X + W - 1), (USHORT)Count, (PBYTE)&FillCell, 0); - break; - case csRight: - VioScrollRt((USHORT)Y, (USHORT)X, (USHORT)(Y + H - 1), (USHORT)(X + W - 1), (USHORT)Count, (PBYTE)&FillCell, 0); - break; - } - if (MouseHidden) - DrawMouse(1); - return 0; -} - -int ConSetSize(int X, int Y) { - VIOMODEINFO vmi; - int rc; - - vmi.cb = sizeof(VIOMODEINFO); - VioGetMode(&vmi, 0); - vmi.col = (USHORT)X; - vmi.row = (USHORT)Y; - vmi.cb = 2 + 1 + 1 + 2 + 2; - rc = VioSetMode(&vmi, 0); - if (rc == 0) return 0; - return -1; -} - -int ConQuerySize(int *X, int *Y) { - VIOMODEINFO vmi; - - vmi.cb = sizeof(VIOMODEINFO); - VioGetMode(&vmi, 0); - if (X) *X = vmi.col; - if (Y) *Y = vmi.row; - return 0; -} - -int ConSetCursorPos(int X, int Y) { - VioSetCurPos((USHORT)Y, (USHORT)X, 0); - return 0; -} - -int ConQueryCursorPos(int *X, int *Y) { - USHORT AX, AY; - - VioGetCurPos(&AY, &AX, 0); - if (X) *X = AX; - if (Y) *Y = AY; - return 0; -} - -int ConShowCursor() { - CursorVisible = 1; - DrawCursor(1); - return 0; -} - -int ConHideCursor() { - CursorVisible = 0; - DrawCursor(0); - return 0; -} - -int ConSetCursorSize(int Start, int End) { - VIOCURSORINFO ci; - - VioGetCurType(&ci, 0); - ci.yStart = -Start; - ci.cEnd = -End; - ci.cx = 0; - VioSetCurType(&ci, 0); - return 0; -} - -int ConSetMousePos(int X, int Y) { - PTRLOC mp; - - if (!MousePresent) return -1; - mp.col = (USHORT)X; - mp.row = (USHORT)Y; - MouSetPtrPos(&mp, MouseHandle); - return 0; -} - -int ConQueryMousePos(int *X, int *Y) { - PTRLOC mp; - - if (!MousePresent) return -1; - MouGetPtrPos(&mp, MouseHandle); - if (X) *X = mp.col; - if (Y) *Y = mp.row; - return 0; -} - -int ConShowMouse() { - MouseVisible = 1; - if (!MousePresent) return -1; - DrawMouse(1); - return 0; -} - -int ConHideMouse() { - MouseVisible = 0; - if (!MousePresent) return -1; - DrawMouse(0); - return 0; -} - -int ConMouseVisible() { - return (MouseVisible == 1); -} - -int ConQueryMouseButtons(int *ButtonCount) { - USHORT Count; - if (MouGetNumButtons(&Count, MouseHandle) != 0) return -1; - if (ButtonCount) *ButtonCount = Count; - return 0; -} - - - -int ConInit(int XSize, int YSize) { - USHORT MevMask = 127; - - if (Initialized) - return 0; - - EventBuf.What = evNone; - MousePresent = (MouOpen(NULL, &MouseHandle) == 0) ?1:0; - - if (MousePresent) - MouSetEventMask(&MevMask, MouseHandle); - - memset(&SaveKbdState, 0, sizeof(SaveKbdState)); - SaveKbdState.cb = sizeof(SaveKbdState); - assert(KbdGetStatus(&SaveKbdState, 0) == 0); - ConContinue(); - - Initialized = 1; - - return 0; -} - -int ConDone() { - return ConSuspend(); -} - -int ConSuspend() { - VIOINTENSITY vi; - static KBDINFO ki; - - vi.cb = 6; - vi.type = 2; - vi.fs = 0; - VioSetState(&vi, 0); - - ki = SaveKbdState; - ki.fsMask &= ~(KEYBOARD_ECHO_OFF | KEYBOARD_BINARY_MODE); - ki.fsMask |= (KEYBOARD_ECHO_ON | KEYBOARD_ASCII_MODE); - assert(0 == KbdSetStatus(&ki, 0)); - - ConHideMouse(); - - signal(SIGBREAK, SIG_DFL); - signal(SIGINT, SIG_DFL); - - return 0; -} - -int ConContinue() { - VIOINTENSITY vi; - static KBDINFO ki; - - signal(SIGBREAK, SIG_IGN); - signal(SIGINT, SIG_IGN); - - ki = SaveKbdState; - ki.fsMask &= ~(KEYBOARD_ECHO_ON | KEYBOARD_ASCII_MODE); - ki.fsMask |= (KEYBOARD_ECHO_OFF | KEYBOARD_BINARY_MODE); - assert(KbdSetStatus (&ki, 0) == 0); - - vi.cb = 6; - vi.type = 2; - vi.fs = 1; - VioSetState(&vi, 0); - ConShowMouse(); - return 0; -} - -int GetPipeEvent(TEvent *Event) { - ULONG ulPostCount; - int i; - - Event->What = evNone; - for (i = 0; i < MAX_PIPES; i++) { - if (Pipes[i].used == 0) continue; - if (Pipes[i].notify == 0) continue; - if (DosResetEventSem(Pipes[i].NewData, &ulPostCount) != 0) - continue; - if (ulPostCount > 0) { - //fprintf(stderr, "Pipe New Data: %d\n", i); - Event->What = evNotify; - Event->Msg.View = 0; - Event->Msg.Model = Pipes[i].notify; - Event->Msg.Command = cmPipeRead; - Event->Msg.Param1 = i; - return 1; - } - } - return 0; -} - -int ConGetEvent(TEventMask EventMask, TEvent *Event, int WaitTime, int Delete) { - KBDINFO ki; - - if (EventBuf.What != evNone) { - *Event = EventBuf; - if (Delete) EventBuf.What = evNone; - return 0; - } - if (MouseEv.What != evNone) { - *Event = MouseEv; - if (Delete) MouseEv.What = evNone; - return 0; - } - EventBuf.What = evNone; - Event->What = evNone; - - ki = SaveKbdState; - ki.fsMask &= ~(KEYBOARD_ECHO_ON | KEYBOARD_ASCII_MODE); - ki.fsMask |= (KEYBOARD_ECHO_OFF | KEYBOARD_BINARY_MODE); - assert(KbdSetStatus (&ki, 0) == 0); - - while ((WaitTime == -1) || (WaitTime >= 0)) { - if ((ReadKbdEvent(Event, WaitTime) == 1) && (EventMask & evKeyboard)) break; - else if (MousePresent && (ReadMouseEvent(Event, EventMask) == 1) && (EventMask & evMouse)) break; - else if (GetPipeEvent(Event) == 1) break; - - if (WaitTime == 0) return -1; - DosSleep(5); - if (WaitTime > 0) { - WaitTime -= 5; - if (WaitTime <= 0) return -1; - } - } - if (Event->What != evNone) { - if (Event->What == evMouseMove) { - while (ReadMouseEvent(&MouseEv, EventMask) == 1) { - if (MouseEv.What == evMouseMove) { - *Event = MouseEv; - MouseEv.What = evNone; - } else break; - } - } - EventBuf = *Event; - if (Delete) EventBuf.What = evNone; - return 0; - } - return -1; -} - -static PCell SavedScreen = 0; -static int SavedX, SavedY, SaveCursorPosX, SaveCursorPosY; - -int SaveScreen() { - if (SavedScreen) - free(SavedScreen); - - ConQuerySize(&SavedX, &SavedY); - - SavedScreen = (PCell) malloc(SavedX * SavedY * sizeof(PCell)); - - if (SavedScreen) - ConGetBox(0, 0, SavedX, SavedY, SavedScreen); - ConQueryCursorPos(&SaveCursorPosX, &SaveCursorPosY); - return 0; -} - -int RestoreScreen() { - if (SavedScreen) { - ConPutBox(0, 0, SavedX, SavedY, SavedScreen); - ConSetCursorPos(SaveCursorPosX, SaveCursorPosY); - } - return 1; -} - -GUI::GUI(int &argc, char **argv, int XSize, int YSize) { - fArgc = argc; - fArgv = argv; - ::ConInit(-1, -1); - SaveScreen(); - ::ConSetSize(XSize, YSize); - gui = this; -} - -GUI::~GUI() { - RestoreScreen(); - - if (SavedScreen) - free(SavedScreen); - - ::ConDone(); - gui = 0; -} - -int GUI::ConSuspend(void) { - RestoreScreen(); - return ::ConSuspend(); -} - -int GUI::ConContinue(void) { - SaveScreen(); - return ::ConContinue(); -} - -int GUI::ShowEntryScreen() { - TEvent E; - - ConHideMouse(); - RestoreScreen(); - do { gui->ConGetEvent(evKeyDown, &E, -1, 1, 0); } while (E.What != evKeyDown); - ConShowMouse(); - if (frames) - frames->Repaint(); - return 1; -} - -static int CreatePipeChild(PID &pid, HPIPE &hfPipe, char *Command) { - static int PCount = 0; - char szPipe[32]; - char FailBuf[256]; - char *Args; - int arglen = 0; - char *Prog; - RESULTCODES rc_code; - ULONG ulAction; - //ULONG ulNew; - HPIPE hfChildPipe; - HFILE hfNewStdOut = (HFILE)-1, hfNewStdErr = (HFILE)-1; - HFILE hfStdOut = 1, hfStdErr = 2; - int rc; - - sprintf(szPipe, "\\PIPE\\FTE%d\\CHILD%d", getpid(), PCount); - PCount++; - - rc = DosCreateNPipe(szPipe, &hfPipe, - NP_NOINHERIT | NP_ACCESS_INBOUND, - NP_NOWAIT | NP_TYPE_BYTE | NP_READMODE_BYTE | 1, - 0, 4096, 0); - if (rc != 0) - return -1; - - rc = DosConnectNPipe (hfPipe); - if (rc != 0 && rc != ERROR_PIPE_NOT_CONNECTED) { - DosClose(hfPipe); - return -1; - } - - rc = DosSetNPHState (hfPipe, NP_WAIT | NP_READMODE_BYTE); - if (rc != 0) { - DosClose(hfPipe); - return -1; - } - - rc = DosOpen (szPipe, &hfChildPipe, &ulAction, 0, - FILE_NORMAL, - OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW, - OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYREADWRITE, - NULL); - if (rc != 0) { - DosClose (hfPipe); - return -1; - } - - // Duplicate handles - DosDupHandle(hfStdOut, &hfNewStdOut); - DosDupHandle(hfStdErr, &hfNewStdErr); - // Close existing handles for current process - DosClose(hfStdOut); - DosClose(hfStdErr); - // Redirect existing handles to new file - DosDupHandle(hfChildPipe, &hfStdOut); - DosDupHandle(hfChildPipe, &hfStdErr); - // Let started program inherit handles from parent - - Prog = getenv("COMSPEC"); - - Args = (char *)malloc(strlen(Prog) + 1 - + 3 + strlen(Command) + 1 - + 1); - if (Args == NULL) { - DosClose(hfPipe); - return -1; - } - - strcpy(Args, Prog); - arglen = strlen(Args) + 1; - strcpy(Args + arglen, "/c "); - arglen += 3; - strcpy(Args + arglen, Command); - arglen += strlen(Command) + 1; - Args[arglen] = '\0'; - - rc = DosExecPgm(FailBuf, sizeof(FailBuf), - EXEC_ASYNCRESULT, // | EXEC_BACKGROUND, - Args, - 0, - &rc_code, - Prog); - - free(Args); - - // Get back original handles - DosDupHandle(hfNewStdOut, &hfStdOut); - DosDupHandle(hfNewStdErr, &hfStdErr); - // Close the duplicated handles - no longer needed - DosClose(hfNewStdOut); - DosClose(hfNewStdErr); - - DosClose(hfChildPipe); // pipe one way, close out write end - - if (rc != 0) { - DosClose(hfPipe); - return -1; - } - - pid = rc_code.codeTerminate; // get pid when successful - - return 0; -} - -static void _LNK_CONV PipeThread(void *p) { - GPipe *pipe = (GPipe *)p; - int rc; - ULONG ulPostCount; - ULONG used; - PID pid; - HPIPE hfPipe; - RESULTCODES rc_code; - - rc = CreatePipeChild(pid, hfPipe, pipe->Command); - - if (rc != 0) { - //fprintf(stderr, "Failed createpipe"); - DosRequestMutexSem(pipe->Access, SEM_INDEFINITE_WAIT); - pipe->reading = 0; - DosPostEventSem(pipe->NewData); - DosReleaseMutexSem(pipe->Access); - return; - } - - //fprintf(stderr, "Pipe: Begin: %d %s\n", pipe->id, Args); - while (1) { - //fprintf(stderr, "Waiting on pipe\n"); - //fread(pipe->buffer, 1, pipe->buflen, fp); - rc = DosRead(hfPipe, pipe->buffer, pipe->buflen, &used); - if (rc < 0) - used = 0; - - DosRequestMutexSem(pipe->Access, SEM_INDEFINITE_WAIT); - //fprintf(stderr, "Waiting on mutex\n"); - pipe->bufused = used; - //fprintf(stderr, "Pipe: fread: %d %d\n", pipe->id, pipe->bufused); - DosResetEventSem(pipe->ResumeRead, &ulPostCount); - if (pipe->bufused == 0) - break; - if (pipe->notify) { - DosPostEventSem(pipe->NewData); - pipe->stopped = 0; - } - DosReleaseMutexSem(pipe->Access); - if (pipe->DoTerm) - break; - //fprintf(stderr, "Waiting on sem\n"); - DosWaitEventSem(pipe->ResumeRead, SEM_INDEFINITE_WAIT); - //fprintf(stderr, "Read: Released mutex\n"); - if (pipe->DoTerm) - break; - } - DosClose(hfPipe); - //fprintf(stderr, "Pipe: pClose: %d\n", pipe->id); - rc = DosWaitChild(DCWA_PROCESS, DCWW_WAIT, - &rc_code, - &pid, - pid); - pipe->RetCode = rc_code.codeResult; - // pclose(fp); - pipe->reading = 0; - DosPostEventSem(pipe->NewData); - DosReleaseMutexSem(pipe->Access); - //fprintf(stderr, "Read: Released mutex\n"); - return; -} - -int GUI::OpenPipe(char *Command, EModel *notify) { - int i; - - for (i = 0; i < MAX_PIPES; i++) { - if (Pipes[i].used == 0) { - Pipes[i].reading = 1; - Pipes[i].stopped = 1; - Pipes[i].id = i; - Pipes[i].bufused = 0; - Pipes[i].bufpos = 0; - Pipes[i].buflen = PIPE_BUFLEN; - Pipes[i].Command = strdup(Command); - Pipes[i].notify = notify; - Pipes[i].DoTerm = 0; - if ((Pipes[i].buffer = (char *)malloc(PIPE_BUFLEN)) == 0) - { - free(Pipes[i].Command); - return -1; - } - - if (0 != DosCreateMutexSem(0, &Pipes[i].Access, 0, 0)) { - free(Pipes[i].Command); - free(Pipes[i].buffer); - return -1; - } - - if (0 != DosCreateEventSem(0, &Pipes[i].ResumeRead, 0, 0)) { - free(Pipes[i].Command); - free(Pipes[i].buffer); - DosCloseMutexSem(Pipes[i].Access); - return -1; - } - - if (0 != DosCreateEventSem(0, &Pipes[i].NewData, 0, 0)) { - free(Pipes[i].Command); - free(Pipes[i].buffer); - DosCloseEventSem(Pipes[i].ResumeRead); - DosCloseMutexSem(Pipes[i].Access); - return -1; - } - -#if defined(__MT__) || defined(__MULTI__) - Pipes[i].tid = _beginthread(PipeThread, - FAKE_BEGINTHREAD_NULL - 16384, &Pipes[i]); -#else - DosCreateThread(Pipes[i].tid, - (PFNTHREAD)PipeThread, - &Pipes[i], - 0, /* immediate */ - 16384); -#endif - Pipes[i].used = 1; - //fprintf(stderr, "Pipe Open: %d\n", i); - return i; - } - } - return -1; -} - -int GUI::SetPipeView(int id, EModel *notify) { - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - DosRequestMutexSem(Pipes[id].Access, SEM_INDEFINITE_WAIT); - //fprintf(stderr, "Pipe View: %d %08X\n", id, notify); - Pipes[id].notify = notify; - DosReleaseMutexSem(Pipes[id].Access); - return 0; -} - -int GUI::ReadPipe(int id, void *buffer, int len) { - int l; - //ULONG ulPostCount; - - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - //fprintf(stderr, "Read: Waiting on mutex\n"); - //ConContinue(); - DosRequestMutexSem(Pipes[id].Access, SEM_INDEFINITE_WAIT); - //fprintf(stderr, "Pipe Read: Get %d %d\n", id, len); - if (Pipes[id].bufused - Pipes[id].bufpos > 0) { - l = len; - if (l > Pipes[id].bufused - Pipes[id].bufpos) { - l = Pipes[id].bufused - Pipes[id].bufpos; - } - memcpy(buffer, - Pipes[id].buffer + Pipes[id].bufpos, - l); - Pipes[id].bufpos += l; - if (Pipes[id].bufpos == Pipes[id].bufused) { - Pipes[id].bufused = 0; - Pipes[id].bufpos = 0; - //fprintf(stderr, "Pipe Resume Read: %d\n", id); - Pipes[id].stopped = 1; - //fprintf(stderr, "Read: posting sem\n"); - DosPostEventSem(Pipes[id].ResumeRead); - } - } else if (Pipes[id].reading == 0) - l = -1; - else { - l = 0; -// DosBeep(200, 200); - } - //fprintf(stderr, "Pipe Read: Got %d %d\n", id, l); - DosReleaseMutexSem(Pipes[id].Access); - //fprintf(stderr, "Read: Released mutex\n"); - return l; -} - -int GUI::ClosePipe(int id) { - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - if (Pipes[id].reading == 1) { - Pipes[id].DoTerm = 1; - DosPostEventSem(Pipes[id].ResumeRead); - DosWaitThread(&Pipes[id].tid, DCWW_WAIT); - } - free(Pipes[id].buffer); - free(Pipes[id].Command); - DosCloseEventSem(Pipes[id].NewData); - DosCloseEventSem(Pipes[id].ResumeRead); - DosCloseMutexSem(Pipes[id].Access); -// fprintf(stderr, "Pipe Close: %d\n", id); - Pipes[id].used = 0; - //ConContinue(); - return Pipes[id].RetCode; -} - -int GUI::RunProgram(int mode, char *Command) { - int rc, W, H, W1, H1; - - ConQuerySize(&W, &H); - ConHideMouse(); - ConSuspend(); - - if (Command == 0 || *Command == 0) // empty string = shell - Command = getenv( - "COMSPEC" - ); - - rc = system(Command); - - ConContinue(); - ConShowMouse(); - ConQuerySize(&W1, &H1); - - if (W != W1 || H != H1) { - frames->Resize(W1, H1); - } - frames->Repaint(); - return rc; -} - -int ConSetTitle(char *Title, char *STitle) { -/* HSWITCH hsw; - SWCNTRL sw; - HAB hab; - PID pid; - TID tid; - - static PVOID Shmem = NULL; - - if (Shmem == NULL) - DosAllocSharedMem(&Shmem, NULL, 4096, - PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_GIVEABLE); - - strcpy(Shmem, Title); - - hab = WinInitialize(0); - - hsw = WinQuerySwitchHandle(NULLHANDLE, getpid()); - - if (WinQuerySwitchEntry(hsw, &sw) != 0) - printf("\x7\n"); - else { - - strncpy (sw.szSwtitle, Title, MAXNAMEL - 1); - sw.szSwtitle[MAXNAMEL-1] = 0; - - printf("hwnd: %X, hwndIcon: %X, pid: %d\n", - sw.hwnd, - sw.hwndIcon, - sw.idProcess); - - WinQueryWindowProcess(sw.hwnd, &pid, &tid); - - DosGiveSharedMem(Shmem, pid, PAG_READ | PAG_WRITE); - - printf("txt 1: %d\n", WinSetWindowText(sw.hwnd, Shmem)); -// printf("txt 2: %d\n", WinSetWindowText(Wsw.hwndIcon, Shmem)); - - WinChangeSwitchEntry(hsw, &sw); - } - - WinTerminate(hab); - */ - return 0; -} - -int ConGetTitle(char *Title, int MaxLen, char *STitle, int SMaxLen) { - strcpy(Title, "FTE"); - strcpy(STitle, "FTE"); - return 0; -} - -int ConCursorVisible() { - return (CursorVisible == 1); -} - -int ConPutEvent(TEvent Event) { - EventBuf = Event; - return 0; -} - -extern int SevenBit; - -char ConGetDrawChar(int index) { - static char tab[] = "Ú¿ÀÙijÂôÁÅ\x1Aúı°\x1B\x1A"; - static char tab7[] = "++++-|+++++\x1A.-++#+\x1B\x1A"; - - assert(index >= 0 && index < (int)strlen(tab)); - - if (SevenBit) - return tab7[index]; - else - return tab[index]; -} diff --git a/src/con_slang.cpp b/src/con_slang.cpp deleted file mode 100644 index eb4f284..0000000 --- a/src/con_slang.cpp +++ /dev/null @@ -1,1057 +0,0 @@ -/* con_slang.cpp - * - * Copyright (c) 1998, István Váradi - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -int use_esc_hack = 0; - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "console.h" -// #include "slangkbd.h" -#include "gui.h" - -#define MAX_PIPES 4 -//#define PIPE_BUFLEN 4096 - -typedef struct { - int used; - int id; - int fd; - int pid; - int stopped; - EModel *notify; -} GPipe; - -static GPipe Pipes[MAX_PIPES] = -{ - {0}, - {0}, - {0}, - {0} -}; - -/* These characters cannot appear on a console, so we can detect - * them in the output routine. - */ -#define DCH_SLANG_C1 128 -#define DCH_SLANG_C2 129 -#define DCH_SLANG_C3 130 -#define DCH_SLANG_C4 131 -#define DCH_SLANG_H 132 -#define DCH_SLANG_V 133 -#define DCH_SLANG_M1 134 -#define DCH_SLANG_M2 135 -#define DCH_SLANG_M3 136 -#define DCH_SLANG_M4 137 -#define DCH_SLANG_X 138 -#define DCH_SLANG_RPTR 139 -#define DCH_SLANG_EOL 140 -#define DCH_SLANG_EOF 141 -#define DCH_SLANG_END 142 -#define DCH_SLANG_AUP 143 -#define DCH_SLANG_ADOWN 144 -#define DCH_SLANG_HFORE 145 -#define DCH_SLANG_HBACK 146 -#define DCH_SLANG_ALEFT 147 -#define DCH_SLANG_ARIGHT 148 - -static char slang_dchs[] = -{ - 'l', - 'k', - 'm', - 'j', - 'q', - 'x', - 'f', - 'f', - 'f', - 'f', - 'f', - '+', - '~', - '`', - 'q', - '-', - '.', - ' ', - 'a', - ',', - '+' -}; - -static char raw_dchs[sizeof(slang_dchs)]; - -unsigned char ftesl_get_dch(char raw) -{ - for (int i = 0; i < (int) sizeof(slang_dchs); i++) - if (raw_dchs[i] == raw) - return DCH_SLANG_C1 + i; - return DCH_SLANG_EOL; -} - -static const char *slang_colors[] = -{ - "black", - "blue", - "green", - "cyan", - "red", - "magenta", - "brown", - "lightgray", - "gray", - "brightblue", - "brightgreen", - "brightcyan", - "brightred", - "brightmagenta", - "yellow", - "white", -}; - -/* - * Definitions for keyboard handling under SLang. - */ - -#define FTESL_KEY 0x00001000 // A key defined by me -#define FTESL_KEY_SHIFT 0x00002000 // Key with Shift -#define FTESL_KEY_CTRL 0x00004000 // Key with Ctrl -#define FTESL_KEY_ALT 0x00008000 // Key with Alt -#define FTESL_KEY_GRAY 0x00010000 // Gray Key - -#define FTESL_KEY_ENTER 13 -#define FTESL_KEY_TAB 9 -#define FTESL_KEY_ESC 27 -#define FTESL_KEY_BACKSP 8 - -#define FTESL_KEY_CTRLAND(x) (x+1-'a') - -static TKeyCode speckeys[] = -{ - kbF1, - kbF2, - kbF3, - kbF4, - kbF5, - kbF6, - kbF7, - kbF8, - kbF9, - kbF10, - kbF11, - kbF12, - kbHome, - kbEnd, - kbPgUp, - kbPgDn, - kbIns, - kbDel, - kbUp, - kbDown, - kbLeft, - kbRight, - kbEnter, - kbEsc, - kbBackSp, - kbSpace, - kbTab, - kbCenter, -}; - -/* -static int ftesl_getkeysym(TKeyCode keycode) -{ - unsigned key = keyCode(keycode); - int ksym = -1; - - for (unsigned i = 0; i < sizeof(speckeys) / sizeof(TKeyCode); i++) { - if (key == speckeys[i]) { - ksym = (int) i; - break; - } - } - - if (ksym < 0 && key < 256) { - ksym = (int) key; - } - - if (ksym < 0) - return ksym; - - if (keycode & kfAlt) - ksym |= FTESL_KEY_ALT; - if (keycode & kfCtrl) - ksym |= FTESL_KEY_CTRL; - if (keycode & kfShift) - ksym |= FTESL_KEY_SHIFT; - if (keycode & kfGray) - ksym |= FTESL_KEY_GRAY; - - ksym |= FTESL_KEY; - return ksym; -} -*/ - -int ConInit(int /*XSize */ , int /*YSize */ ) -{ - unsigned i; - unsigned short linebuf[sizeof(slang_dchs)]; - - SLtt_get_terminfo(); - - if (SLkp_init() == -1) { - return -1; - } - if (SLang_init_tty(0, 1, 1) == -1) { - return -1; - } - - if (SLsmg_init_smg() == -1) { - SLang_reset_tty(); - return -1; - } - - SLang_set_abort_signal(NULL); - - SLtty_set_suspend_state(0); - - for (i = 0; i < 128; i++) { - SLtt_set_color(i, NULL, (char *) slang_colors[i & 0x0f], - (char *) slang_colors[((i >> 4) + 0) & 0x07]); - } - - SLsmg_gotorc(0, 0); - SLsmg_set_char_set(1); - - SLsmg_write_nchars(slang_dchs, sizeof(slang_dchs)); - - SLsmg_gotorc(0, 0); - SLsmg_read_raw(linebuf, sizeof(slang_dchs)); - for (i = 0; i < sizeof(slang_dchs); i++) - raw_dchs[i] = (linebuf[i]) & 0xff; - - SLsmg_set_char_set(0); - - use_esc_hack = (getenv("FTESL_ESC_HACK") != NULL); - - return 0; -} -int ConDone(void) -{ - SLsmg_reset_smg(); - SLang_reset_tty(); - return 0; -} - -int ConSuspend(void) -{ - SLsmg_suspend_smg(); - SLang_reset_tty(); - return 0; -} -int ConContinue(void) -{ - SLang_init_tty(-1, 0, 1); - SLsmg_resume_smg(); - return 0; -} - -int ConSetTitle(char * /*Title */ , char * /*STitle */ ) -{ - return 0; -} - -int ConGetTitle(char *Title, int /*MaxLen */ - , char * /*STitle */ , int /*SMaxLen */ ) -{ - *Title = '\0'; - return 0; -} - -int ConClear() -{ - SLsmg_cls(); - SLsmg_refresh(); - return 0; -} - -static void fte_write_color_chars(PCell Cell, int W) -{ - int i = 0; - int chset = 0, chsetprev = 0; - unsigned char ch, col = 0x70, colprev = 0x70; - char buf[256]; - - SLsmg_set_color(colprev); - while (W > 0) { - for (i = 0; i < W && i < (int) sizeof(buf); i++) { - ch = Cell[i] & 0xff; - col = (Cell[i] >> 8) & 0x7f; - if (ch <= 127 || ch >= 0xa0) { - if (ch < 32) - buf[i] = '.'; - else - buf[i] = ch; - chset = 0; - } else { - buf[i] = slang_dchs[ch - 128]; - chset = 1; - } - - - - if (col != colprev || chset != chsetprev) - break; - - } - - if (i > 0) { - SLsmg_write_nchars(buf, i); - W -= i; - Cell += i; - } - - if (col != colprev) { - SLsmg_set_color(col); - colprev = col; - } - - if (chset != chsetprev) { - SLsmg_set_char_set(chset); - chsetprev = chset; - } - } - SLsmg_set_char_set(0); -} - -int ConPutBox(int X, int Y, int W, int H, PCell Cell) -{ - int CurX, CurY; - - ConQueryCursorPos(&CurX, &CurY); - while (H > 0) { - SLsmg_gotorc(Y++, X); - fte_write_color_chars(Cell, W); - Cell += W; - H--; - } - ConSetCursorPos(CurX, CurY); - SLsmg_refresh(); - - return 0; -} - -int ConPutBoxRaw(int X, int Y, int W, int H, unsigned short *box) -{ - int CurX, CurY; - - ConQueryCursorPos(&CurX, &CurY); - while (H > 0) { - SLsmg_gotorc(Y++, X); - SLsmg_write_raw(box, W); - box += W; - H--; - } - ConSetCursorPos(CurX, CurY); - - return 0; - -} - -int ConGetBox(int X, int Y, int W, int H, PCell Cell) -{ - int CurX, CurY, i; - char ch; - - ConQueryCursorPos(&CurX, &CurY); - while (H > 0) { - SLsmg_gotorc(Y++, X); - SLsmg_read_raw(Cell, W); - for (i = 0; i < W; i++) - if (Cell[i] & 0x8000) { - ch = Cell[i] & 0xff; - Cell[i] &= 0x7f00; - Cell[i] |= ftesl_get_dch(ch); - } - Cell += W; - H--; - } - ConSetCursorPos(CurX, CurY); - - return 0; - -} - -int ConGetBoxRaw(int X, int Y, int W, int H, unsigned short *box) -{ - int CurX, CurY; - - ConQueryCursorPos(&CurX, &CurY); - while (H > 0) { - SLsmg_gotorc(Y++, X); - SLsmg_read_raw(box, W); - box += W; - H--; - } - ConSetCursorPos(CurX, CurY); - - return 0; - -} - -int ConPutLine(int X, int Y, int W, int H, PCell Cell) -{ - int CurX, CurY; - - ConQueryCursorPos(&CurX, &CurY); - while (H > 0) { - SLsmg_gotorc(Y, X); - fte_write_color_chars(Cell, W); - H--; - } - ConSetCursorPos(CurX, CurY); - SLsmg_refresh(); - - return 0; -} - -int ConSetBox(int X, int Y, int W, int H, TCell Cell) -{ - PCell line = (PCell) malloc(sizeof(TCell) * W); - int i; - - for (i = 0; i < W; i++) - line[i] = Cell; - ConPutLine(X, Y++, W, H, line); - free(line); - return 0; -} - - - -int ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count) -{ - unsigned short *box; - - box = new unsigned short [W * H]; - - TCell fill = (((unsigned) Fill) << 8) | ' '; - - ConGetBoxRaw(X, Y, W, H, box); - - if (Way == csUp) { - ConPutBoxRaw(X, Y, W, H - Count, box + W * Count); - ConSetBox(X, Y + H - Count, W, Count, fill); - } else { - ConPutBoxRaw(X, Y + Count, W, H - Count, box); - ConSetBox(X, Y, W, Count, fill); - } - - delete(box); - - return 0; -} - -int ConSetSize(int /*X */ , int /*Y */ ) -{ - return -1; -} - -int ConQuerySize(int *X, int *Y) -{ - *X = SLtt_Screen_Cols; - *Y = SLtt_Screen_Rows; - return 0; -} - -int ConSetCursorPos(int X, int Y) -{ - SLsmg_gotorc(Y, X); - SLsmg_refresh(); - return 0; -} - -int ConQueryCursorPos(int *X, int *Y) -{ - *X = SLsmg_get_column(); - *Y = SLsmg_get_row(); - return 0; -} - -int CurVis = 1; - -int ConShowCursor() -{ - CurVis = 1; - SLtt_set_cursor_visibility(1); - return 0; -} -int ConHideCursor() -{ - CurVis = 0; - SLtt_set_cursor_visibility(0); - return 0; -} -int ConCursorVisible() -{ - return CurVis; -} - -int ConSetCursorSize(int /*Start */ , int /*End */ ) -{ - return 0; -} - -int ConSetMousePos(int /*X */ , int /*Y */ ) -{ - return -1; -} -int ConQueryMousePos(int *X, int *Y) -{ - *X = 0; - *Y = 0; - return 0; -} - -int ConShowMouse() -{ - return -1; -} - -int ConHideMouse() -{ - return -1; -} - -int ConMouseVisible() -{ - return 0; -} - -int ConQueryMouseButtons(int *ButtonCount) -{ - *ButtonCount = 0; - return 0; -} - -static TEvent Prev = -{evNone}; - -static TKeyCode keys_ctrlhack[] = -{ - kfAlt, - kbHome, - kfCtrl, - kbDown, - kbEnd, - - kbF1, - kfCtrl | 'G', - kbBackSp, - kbTab, - kfCtrl | 'J', - - kfCtrl | 'K', - kbLeft, - kbEnter, - kbPgDn, - kfCtrl | 'O', - - kbPgUp, - kbIns, - kbRight, - kfShift, - kfCtrl | 'T', - - kbUp, - kfCtrl | 'V', - kfCtrl | 'W', - kbCenter, - kfCtrl | 'Y', - - kbDel, -}; - -static TKeyCode ftesl_getftekey(unsigned char key) -{ - if (key < 32) - return speckeys[key]; - else - return (TKeyCode) key; -} - -/* - * Keyboard handling with SLang. - */ -static TKeyCode ftesl_process_key(int key, int ctrlhack = 0) -{ - TKeyCode kcode; - - //fprintf(stderr, "KEY %03d \n", key); - if (key < 256 && key >= 32) { - return (TKeyCode) key; - } else if (key >= 1 && key <= 26 && key != 13 && key != 9 && key != 8) { - if (!ctrlhack) - return ((key + 'A' - 1) & 0xff) | kfCtrl; - else - return keys_ctrlhack[key - 1]; - } else if (key & FTESL_KEY) { - kcode = ftesl_getftekey(key & 0x00ff); - if (key & FTESL_KEY_SHIFT) - kcode |= kfShift; - if (key & FTESL_KEY_CTRL) - kcode |= kfCtrl; - if (key & FTESL_KEY_ALT) - kcode |= kfAlt; - if (key & FTESL_KEY_GRAY) - kcode |= kfGray; - return kcode; - } else - switch (key) { - case SL_KEY_UP: - return kbUp; - case SL_KEY_DOWN: - return kbDown; - case SL_KEY_LEFT: - return kbLeft; - case SL_KEY_RIGHT: - return kbRight; - case SL_KEY_PPAGE: - return kbPgUp; - case SL_KEY_NPAGE: - return kbPgDn; - case SL_KEY_HOME: - return kbHome; - case SL_KEY_END: - return kbEnd; - case SL_KEY_BACKSPACE: - case FTESL_KEY_BACKSP: - return kbBackSp; - case SL_KEY_ENTER: - case FTESL_KEY_ENTER: - return kbEnter; - case SL_KEY_IC: - return kbIns; - case SL_KEY_DELETE: - return kbDel; - case SL_KEY_F(1): - return kbF1; - case SL_KEY_F(2): - return kbF2; - case SL_KEY_F(3): - return kbF3; - case SL_KEY_F(4): - return kbF4; - case SL_KEY_F(5): - return kbF5; - case SL_KEY_F(6): - return kbF6; - case SL_KEY_F(7): - return kbF7; - case SL_KEY_F(8): - return kbF8; - case SL_KEY_F(9): - return kbF9; - case SL_KEY_F(10): - return kbF10; - case SL_KEY_F(11): - return kbF11; - case SL_KEY_F(12): - return kbF12; - case FTESL_KEY_TAB: - return kbTab; - case FTESL_KEY_ESC: - case SL_KEY_ERR: - return kbEsc; - default: - return '?'; - } -} - - -int ConGetEvent(TEventMask /*EventMask */ , - TEvent * Event, int WaitTime, int Delete) -{ - int key; - TKeyEvent *KEvent = &(Event->Key); - fd_set readfds; - struct timeval timeout; - - if (Prev.What != evNone) { - *Event = Prev; - if (Delete) - Prev.What = evNone; - return 1; - } - - Event->What = evNone; - - WaitTime = (WaitTime >= 0) ? WaitTime / 100 : 36000; - - FD_ZERO(&readfds); - - FD_SET(0, &readfds); - for (int p = 0; p < MAX_PIPES; p++) - if (Pipes[p].used && Pipes[p].fd != -1) - FD_SET(Pipes[p].fd, &readfds); - - if (WaitTime == -1) { - if (select(sizeof(fd_set) * 8, &readfds, NULL, NULL, NULL) < 0) - return -1; - } else { - timeout.tv_sec = WaitTime / 1000; - timeout.tv_usec = (WaitTime % 1000) * 1000; - if (select(sizeof(fd_set) * 8, &readfds, NULL, NULL, &timeout) < 0) - return -1; - } - - if (SLang_input_pending(0) > 0) { - TKeyCode kcode = 0, kcode1; - - key = SLang_getkey(); - int escfirst = 1; - - if (key == 27) - while (1) { - if (use_esc_hack) { - if (SLang_input_pending(1) == 0) { - kcode = kbEsc; - break; - } - } - - key = SLang_getkey(); - if (key == 3) { - SLang_ungetkey(key); - SLkp_getkey(); - } - if (key >= 'a' && key <= 'z') - key -= 'a' - 'A'; - if (key == 27) { - kcode = kbEsc; - break; - } else if (key == '[' && escfirst) { - unsigned char kbuf[2]; - - kbuf[0] = 27; - kbuf[1] = (char) key; - SLang_ungetkey_string(kbuf, 2); - key = SLkp_getkey(); - kcode = ftesl_process_key(key, 0); - break; - } else { - kcode1 = ftesl_process_key(key, 1); - if (keyCode(kcode1) == kbF1) { - key = SLang_getkey(); - switch (key) { - case '0': - kcode |= kbF10; - break; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - kcode |= kbF1 + key - '1'; - break; - case 'a': - case 'b': - kcode |= kbF11 + key - 'a'; - break; - } - } else - kcode |= kcode1; - - if (keyCode(kcode) != 0) { - if (escfirst) - kcode |= kfAlt; - break; - } - } - escfirst = 0; - } else { - SLang_ungetkey(key); - key = SLkp_getkey(); - kcode = ftesl_process_key(key, 0); - } - - Event->What = evKeyDown; - KEvent->Code = kcode; - - if (!Delete) - Prev = *Event; - - return 1; - } else { - for (int pp = 0; pp < MAX_PIPES; pp++) { - if (Pipes[pp].used && Pipes[pp].fd != -1 && - FD_ISSET(Pipes[pp].fd, &readfds) && - Pipes[pp].notify) { - Event->What = evNotify; - Event->Msg.View = 0; - Event->Msg.Model = Pipes[pp].notify; - Event->Msg.Command = cmPipeRead; - Event->Msg.Param1 = pp; - Pipes[pp].stopped = 0; - } - //fprintf(stderr, "Pipe %d\n", Pipes[pp].fd); - return 0; - } - } - - return -1; -} - -int ConPutEvent(TEvent Event) -{ - Prev = Event; - return 0; -} - -GUI::GUI(int &argc, char **argv, int XSize, int YSize) -{ - fArgc = argc; - fArgv = argv; - ::ConInit(-1, -1); - ::ConSetSize(XSize, YSize); - gui = this; -} - -GUI::~GUI() -{ - ::ConDone(); - gui = 0; -} - -int GUI::ConSuspend(void) -{ - return::ConSuspend(); -} - -int GUI::ConContinue(void) -{ - return::ConContinue(); -} - -int GUI::ShowEntryScreen() -{ - TEvent E; - - ConHideMouse(); - do { - gui->ConGetEvent(evKeyDown, &E, -1, 1, 0); - } while (E.What != evKeyDown); - ConShowMouse(); - if (frames) - frames->Repaint(); - return 1; -} - -int GUI::OpenPipe(char *Command, EModel * notify) -{ - int i; - - for (i = 0; i < MAX_PIPES; i++) { - if (Pipes[i].used == 0) { - int pfd[2]; - - Pipes[i].id = i; - Pipes[i].notify = notify; - Pipes[i].stopped = 1; - - if (pipe((int *) pfd) == -1) - return -1; - - switch (Pipes[i].pid = fork()) { - case -1: /* fail */ - return -1; - case 0: /* child */ - signal(SIGPIPE, SIG_DFL); - close(pfd[0]); - close(0); - dup2(pfd[1], 1); - dup2(pfd[1], 2); - close(pfd[1]); - exit(system(Command)); - default: - close(pfd[1]); - fcntl(pfd[0], F_SETFL, O_NONBLOCK); - Pipes[i].fd = pfd[0]; - } - Pipes[i].used = 1; - return i; - } - } - return -1; -} - -int GUI::SetPipeView(int id, EModel * notify) -{ - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - - Pipes[id].notify = notify; - return 0; -} - -int GUI::ReadPipe(int id, void *buffer, int len) -{ - int rc; - - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - - rc = read(Pipes[id].fd, buffer, len); - if (rc == 0) { - close(Pipes[id].fd); - Pipes[id].fd = -1; - return -1; - } - if (rc == -1) { - Pipes[id].stopped = 1; - return 0; - } - return rc; -} - -int GUI::ClosePipe(int id) -{ - int status = -1; - - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - if (Pipes[id].fd != -1) - close(Pipes[id].fd); - - kill(Pipes[id].pid, SIGHUP); - alarm(1); - waitpid(Pipes[id].pid, &status, 0); - alarm(0); - Pipes[id].used = 0; - return WEXITSTATUS(status); -} - -int GUI::RunProgram(int /*mode */ , char *Command) -{ - int rc, W, H, W1, H1; - - ConQuerySize(&W, &H); - ConHideMouse(); - ConSuspend(); - - if (*Command == 0) // empty string = shell - Command = getenv("SHELL"); - - rc = system(Command); - - ConContinue(); - ConShowMouse(); - ConQuerySize(&W1, &H1); - - if (W != W1 || H != H1) { - frames->Resize(W1, H1); - } - frames->Repaint(); - return rc; -} - -char ConGetDrawChar(int index) -{ - static const char * use_tab = NULL; - static int use_tab_size = 0; - - static const char tab[] = - { - DCH_SLANG_C1, - DCH_SLANG_C2, - DCH_SLANG_C3, - DCH_SLANG_C4, - DCH_SLANG_H, - DCH_SLANG_V, - DCH_SLANG_M1, - DCH_SLANG_M2, - DCH_SLANG_M3, - DCH_SLANG_M4, - DCH_SLANG_X, - DCH_SLANG_RPTR, - DCH_SLANG_EOL, - DCH_SLANG_EOF, - DCH_SLANG_END, - DCH_SLANG_AUP, - DCH_SLANG_ADOWN, - DCH_SLANG_HFORE, - DCH_SLANG_HBACK, - DCH_SLANG_ALEFT, - DCH_SLANG_ARIGHT - }; - - static const char tab_linux[] = - { - DCH_SLANG_C1, - DCH_SLANG_C2, - DCH_SLANG_C3, - DCH_SLANG_C4, - DCH_SLANG_H, - DCH_SLANG_V, - DCH_SLANG_M1, - DCH_SLANG_M2, - DCH_SLANG_M3, - DCH_SLANG_M4, - DCH_SLANG_X, - ' ', - '.', - DCH_SLANG_EOF, - DCH_SLANG_END, - DCH_SLANG_AUP, - DCH_SLANG_ADOWN, - DCH_SLANG_HFORE, - DCH_SLANG_HBACK, - DCH_SLANG_ALEFT, - DCH_SLANG_ARIGHT - }; - //static const char tab_linux1[] = - //{ - // '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - // 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', - // 'l', 'm', 'n', 'o', 'p', 'q' - //}; - - if (use_tab == NULL) { - char *c = getenv("TERM"); - use_tab = ((c == NULL) || strcmp(c, "linux") != 0) ? tab : tab_linux; - use_tab_size = (use_tab == tab) - ? sizeof(tab) : sizeof(tab_linux); - } - - assert(index >= 0 && index < use_tab_size); - - return use_tab[index]; -} diff --git a/src/con_x11.cpp b/src/con_x11.cpp deleted file mode 100644 index 39e4032..0000000 --- a/src/con_x11.cpp +++ /dev/null @@ -1,1660 +0,0 @@ -/* con_x11.cpp - * - * Copyright (c) 1994-1996, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - * I18N & XMB support added by kabi@fi.muni.cz - */ - -#include -#include -#include -#ifdef WINNT -#include -#define NO_PIPES -#define NO_SIGNALS -#else -#include -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#if defined(AIX) -#include -#include -#endif -#include -#include -#include -#include -#include -#ifdef USE_XTINIT -#include -#endif -#ifdef HPUX -#include -#endif -#include "console.h" -#include "gui.h" - -#include "con_i18n.h" -#include "s_files.h" - -XIC xic = NULL; - -#ifdef WINHCLX -#include /* HCL - HCLXlibInit */ -#endif - -#ifdef CAST_FD_SET_INT -#define FD_SET_CAST() (int *) -#else -#define FD_SET_CAST() -#endif - -#define MIN_SCRWIDTH 20 -#define MIN_SCRHEIGHT 6 - -#define MAX_PIPES 40 -//#define PIPE_BUFLEN 4096 - -typedef struct { - int used; - int id; - int fd; - int pid; - int stopped; - EModel *notify; -} GPipe; - -static GPipe Pipes[MAX_PIPES] = { - { 0 }, -}; - -static long MouseAutoDelay = 40; -static long MouseAutoRepeat = 200; -static long MouseMultiClick = 300; - -static int setUserPosition = 0; -static int initX = 0, initY = 0; -static unsigned int ScreenCols = 80; -static unsigned int ScreenRows = 40; -static unsigned int CursorX = 0; -static unsigned int CursorY = 0; -static int CursorVisible = 1; -static unsigned char *ScreenBuffer = NULL; -static int Refresh = 0; - -static Display *display; -static Colormap colormap; -static Atom wm_protocols; -static Atom wm_delete_window; -static Atom targets; -static Window win; -static Atom selection_buffer; -static XSizeHints sizeHints; -// program now contains both modes if available -// some older Xservers don't like XmbDraw... -static XFontStruct *fontStruct; -#ifdef USE_XMB -static int useXMB = 1; // default is yes -static XFontSet fontSet; -static int FontCYD; -#else -static int useXMB = 0; -#endif -static int FontCX, FontCY; -static XColor Colors[16]; -static GC GCs[256]; -static int rc; -static char winTitle[256] = "FTE"; -static char winSTitle[256] = "FTE"; - -static char *CurSelectionData = 0; -static int CurSelectionLen = 0; -static int CurSelectionOwn = 0; -static Time now; - -static int AllocBuffer() { - unsigned char *p; - unsigned int i; - - ScreenBuffer = (unsigned char *)malloc(2 * ScreenCols * ScreenRows); - if (ScreenBuffer == NULL) return -1; - for (i = 0, p = ScreenBuffer; i < ScreenCols * ScreenRows; i++) { - *p++ = 32; - *p++ = 0x07; - } - return 0; -} - -static struct { - int r, g, b; -} dcolors[] = -{ - { 0, 0, 0 }, // black - { 0, 0, 160 }, // darkBlue - { 0, 160, 0 }, // darkGreen - { 0, 160, 160 }, // darkCyan - { 160, 0, 0 }, // darkRed - { 160, 0, 160 }, // darkMagenta - { 160, 160, 0 }, // darkYellow - { 204, 204, 204 }, // paleGray - { 160, 160, 160 }, // darkGray - { 0, 0, 255 }, // blue - { 0, 255, 0 }, // green - { 0, 255, 255 }, // cyan - { 255, 0, 0 }, // red - { 255, 0, 255 }, // magenta - { 255, 255, 0 }, // yellow - { 255, 255, 255 }, // white -}; - -static void SetColor(int i) { - assert (0 <= i && i <= 15); - Colors[i].blue = (dcolors[i].b << 8) | dcolors[i].b; - Colors[i].green = (dcolors[i].g << 8) | dcolors[i].g; - Colors[i].red = (dcolors[i].r << 8) | dcolors[i].r; - Colors[i].flags = DoRed | DoGreen | DoBlue; -} - -static int InitXColors() { - int i, j; - long d = 0x7FFFFFFF, d1; - XColor clr; - unsigned long pix; - int num; - long d_red, d_green, d_blue; - long u_red, u_green, u_blue; - - for (i = 0; i < 16; i++) { - SetColor(i); - if (XAllocColor(display, colormap, &Colors[i]) == 0) { - SetColor(i); - pix = 0xFFFFFFFF; - num = DisplayCells(display, DefaultScreen(display)); - for (j = 0; j < num; j++) { - clr.pixel = j; - XQueryColor(display, colormap, &clr); - - d_red = (clr.red - Colors[i].red) >> 3; - d_green = (clr.green - Colors[i].green) >> 3; - d_blue = (clr.blue - Colors[i].blue) >> 3; - - //fprintf(stderr, "%d:%d dr:%d, dg:%d, db:%d\n", i, j, d_red, d_green, d_blue); - - u_red = d_red / 100 * d_red * 3; - u_green = d_green / 100 * d_green * 4; - u_blue = d_blue / 100 * d_blue * 2; - - //fprintf(stderr, "%d:%d dr:%u, dg:%u, db:%u\n", i, j, u_red, u_green, u_blue); - - d1 = u_red + u_blue + u_green; - - if (d1 < 0) - d1 = -d1; - if (pix == ~0UL || d1 < d) { - pix = j; - d = d1; - } - } - if (pix == 0xFFFFFFFF) { - fprintf(stderr, "Color search failed for #%04X%04X%04X\n", - Colors[i].red, - Colors[i].green, - Colors[i].blue); - } - clr.pixel = pix; - XQueryColor(display, colormap, &clr); - Colors[i] = clr; - if (XAllocColor(display, colormap, &Colors[i]) == 0) { - fprintf(stderr, "Color alloc failed for #%04X%04X%04X\n", - Colors[i].red, - Colors[i].green, - Colors[i].blue); - } - /*colormap = XCreateColormap(display, win, DefaultVisual(display, screen), AllocNone); - for (i = 0; i < 16; i++) { - SetColor(i); - XAllocColor(display, colormap, &Colors[i]); - } - XSetWindowColormap(display, win, colormap); - return 0;*/ - } - } - return 0; -} - -static int InitXGCs() { - unsigned int i; - unsigned long mask = GCForeground | GCBackground; - XGCValues gcv; - - if (!useXMB) { - gcv.font = fontStruct->fid; - mask |= GCFont; - } - - for (i = 0; i < 256; i++) { - gcv.foreground = Colors[i % 16].pixel; - gcv.background = Colors[(i / 16)].pixel; - GCs[i] = XCreateGC(display, win, mask, &gcv); - } - - return 0; -} - -static int InitXFonts(void) -{ - char *fs; - - fs = getenv("VIOFONT"); - if (fs == NULL && WindowFont[0] != 0) - fs = WindowFont; - - if (!useXMB) { - - fontStruct = NULL; - - if (fs != NULL) { - char *s = 0; - - s = strchr(fs, ','); - if (s != NULL) - *s = 0; - fontStruct = XLoadQueryFont(display, fs); - } - if (fontStruct == NULL) - fontStruct = XLoadQueryFont(display, "8x13"); - if (fontStruct == NULL) - fontStruct = XLoadQueryFont(display, "fixed"); - if (fontStruct == NULL) - return -1; - FontCX = fontStruct->max_bounds.width; - FontCY = fontStruct->max_bounds.ascent + fontStruct->max_bounds.descent; - } -#ifdef USE_XMB - else { - const char *def = " "; - const char *fs1 = "-misc-*-r-normal-*"; - const char *fs2 = "*fixed*"; - char **miss; - int nMiss; - - // test font fixed font: - // fs="*-fixed-bold-*-15-*"; - if (fs != NULL) - fontSet = XCreateFontSet(display, fs, &miss, &nMiss, - (char **) &def); - - // try any fixed localized font */ - if (fontSet == NULL) { - fprintf(stderr, "XFTE Warning: unable to open font: '%s'\n" - " using '%s' instead\n", fs, fs1); - fontSet = XCreateFontSet(display, fs1, &miss, &nMiss, - (char **) &def); - } - - // try plain fixed font - if (fontSet == NULL) { - fprintf(stderr, "XFTE Warning: unable to open font: '%s'\n" - " using '%s' instead\n", fs1, fs2); - fontSet = XCreateFontSet(display, fs2, &miss, &nMiss, - (char **) &def); - } - - if (fontSet == NULL) { - fprintf(stderr, "XFTE Warning: unable to open \"base\" font: " - "'%s'\n Missing count: %d\n", fs2, nMiss); - for(int i = 0; i < nMiss; i++) - fprintf(stderr, " %s\n", miss[i]); - if (def != NULL) - fprintf(stderr, " def_ret: %s\n", def); - } - - if (fontSet == NULL) - return -1; - XFontSetExtents *xE = XExtentsOfFontSet(fontSet); - - FontCX = xE->max_logical_extent.width; - FontCY = xE->max_logical_extent.height; - // handle descending (comes in negative form) - FontCYD = -(xE->max_logical_extent.y); - // printf("Font X:%d\tY:%d\tD:%d\n", FontCX, FontCY, FontCYD); - } -#endif - return 0; -} - -static int SetupXWindow(int argc, char **argv) { - unsigned long mask; - XSetWindowAttributes setWindowAttributes; - -#ifdef WINHCLX - HCLXlibInit(); /* HCL - Initialize the X DLL */ -#endif - -#ifdef USE_XTINIT - XtAppContext app_context; - XtToolkitInitialize(); - app_context = XtCreateApplicationContext(); - if (( display = XtOpenDisplay(app_context, NULL, argv[0], "xfte", - NULL, 0, &argc, argv)) == NULL) - DieError(1, "%s: Can't open display\n", argv[0]); -#else - char *ds; - if ((ds = getenv("DISPLAY")) == NULL) - DieError(1, "$DISPLAY not set?"); - if ((display = XOpenDisplay(ds)) == NULL) - DieError(1, "XFTE Fatal: could not open display: %s!", ds); -#endif - - colormap = DefaultColormap(display, DefaultScreen(display)); - - setWindowAttributes.bit_gravity = - sizeHints.win_gravity = NorthWestGravity; - - // this is correct behavior - if (initX < 0) - initX = DisplayWidth(display, DefaultScreen(display)) + initX; - if (initY < 0) - initY = DisplayHeight(display, DefaultScreen(display)) + initY; - win = XCreateWindow(display, - DefaultRootWindow(display), - initX, initY, - // ScreenCols * FontCX, ScreenRows * FontCY, 0, - // at this moment we don't know the exact size - // but we need to open a window - so pick up 1 x 1 - 1, 1, 0, - CopyFromParent, InputOutput, CopyFromParent, - CWBitGravity, &setWindowAttributes); - - xic = I18NInit(display, win, &mask); - - if (InitXFonts() != 0) - DieError(1, "XFTE Fatal: could not open any font!"); - - /* >KeyReleaseMask shouldn't be set for correct key mapping */ - /* we set it anyway, but not pass to XmbLookupString -- mark */ - mask |= ExposureMask | StructureNotifyMask | VisibilityChangeMask | - FocusChangeMask | KeyPressMask | KeyReleaseMask | - ButtonPressMask | ButtonReleaseMask | ButtonMotionMask; - XSelectInput(display, win, mask); - - wm_protocols = XInternAtom(display, "WM_PROTOCOLS", False); - assert(wm_protocols != None); - wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False); - assert(wm_delete_window != None); - selection_buffer = XInternAtom(display, "fte_clip", False);//??? needed - assert(selection_buffer != None); - targets = XInternAtom(display, "TARGETS", False); - assert(targets != None); - - sizeHints.flags = PResizeInc | PMinSize | PBaseSize | PWinGravity; - sizeHints.width_inc = FontCX; - sizeHints.height_inc = FontCY; - sizeHints.min_width = MIN_SCRWIDTH * FontCX; - sizeHints.min_height = MIN_SCRHEIGHT * FontCY; - sizeHints.base_width = 0; - sizeHints.base_height = 0; - if (setUserPosition) - sizeHints.flags |= USPosition; - - XClassHint classHints; - classHints.res_name = (char *)"fte"; - classHints.res_class = (char *)"Fte"; - XSetClassHint(display, win, &classHints); - - XSetStandardProperties(display, win, winTitle, winTitle, 0, NULL, 0, 0); - XSetWMNormalHints(display, win, &sizeHints); - XSetWMProtocols(display, win, &wm_delete_window, 1); - - if (InitXColors() != 0) return -1; - if (InitXGCs() != 0) return -1; - - XResizeWindow(display, win, ScreenCols * FontCX, ScreenRows * FontCY); - XMapRaised(display, win); - // XClearWindow(display, win); /// !!! why? - return 0; -} - -int ConInit(int XSize, int YSize) { - if (XSize != -1) - ScreenCols = XSize; - if (YSize != -1) - ScreenRows = YSize; - if (AllocBuffer() == -1) return -1; -#ifndef NO_SIGNALS - signal(SIGALRM, SIG_IGN); - signal(SIGPIPE, SIG_IGN); -#endif - return 0; -} - -int ConDone(void) { - XDestroyWindow(display, win); - XCloseDisplay(display); - return 0; -} - -int ConSuspend(void) { - return 0; -} - -int ConContinue(void) { - return 0; -} - -int ConClear(void) { - TDrawBuffer B; - MoveCh(B, ' ', 0x07, ScreenCols); - return ConPutLine(0, 0, ScreenCols, ScreenRows, B); -} - -int ConSetTitle(char *Title, char *STitle) { - char buf[sizeof(winTitle)] = {0}; - JustFileName(Title, buf); - if (buf[0] == '\0') // if there is no filename, try the directory name. - JustLastDirectory(Title, buf); - - strncpy(winTitle, "FTE - ", sizeof(winTitle) - 1); - if (buf[0] != 0) // if there is a file/dir name, stick it in here. - { - strncat(winTitle, buf, sizeof(winTitle) - 1 - strlen(winTitle)); - strncat(winTitle, " - ", sizeof(winTitle) - 1 - strlen(winTitle)); - } - strncat(winTitle, Title, sizeof(winTitle) - 1 - strlen(winTitle)); - winTitle[sizeof(winTitle) - 1] = 0; - strncpy(winSTitle, STitle, sizeof(winSTitle) - 1); - winSTitle[sizeof(winSTitle) - 1] = 0; - XSetStandardProperties(display, win, winTitle, winSTitle, 0, NULL, 0, NULL); - return 0; -} - -int ConGetTitle(char *Title, int MaxLen, char *STitle, int SMaxLen) { - strncpy(Title, winTitle, MaxLen); - Title[MaxLen - 1] = 0; - strncpy(STitle, winSTitle, SMaxLen); - STitle[SMaxLen - 1] = 0; - return 0; -} - -#define InRange(x,a,y) (((x) <= (a)) && ((a) < (y))) -#define CursorXYPos(x,y) (ScreenBuffer + ((x) + ((y) * ScreenCols)) * 2) - -void DrawCursor(int Show) { - if (CursorVisible) { - unsigned char *p = CursorXYPos(CursorX, CursorY), attr; - attr = p[1]; - /*if (Show) attr = ((((attr << 4) & 0xF0)) | (attr >> 4)) ^ 0x77;*/ - if (Show) - attr = (attr ^ 0x77); - - if (!useXMB) - XDrawImageString(display, win, GCs[((unsigned)attr) & 0xFF], - CursorX * FontCX, - fontStruct->max_bounds.ascent + CursorY * FontCY, - (char *)p, 1); -#ifdef USE_XMB - else - XmbDrawImageString(display, win, fontSet, - GCs[((unsigned)attr) & 0xFF], - CursorX * FontCX, FontCYD + CursorY * FontCY, - (char *)p, 1); -#endif - } -} - -int ConPutBox(int X, int Y, int W, int H, PCell Cell) { - unsigned int i; - unsigned char temp[256], attr; - unsigned char *p, *ps, *c, *ops; - unsigned int len, x, l, ox, olen, skip; - - - if (X >= (int) ScreenCols || Y >= (int) ScreenRows || - X + W > (int) ScreenCols || Y + H > (int) ScreenRows) { - //fprintf(stderr, "%d %d %d %d %d %d\n", ScreenCols, ScreenRows, X, Y, W, H); - return -1; - } - //XClearArea(display, win, X, Y, W * FontCX, H * FontCY, False); - - //fprintf(stderr, "%d %d %d %d %d %d\n", ScreenCols, ScreenRows, X, Y, W, H); - for (i = 0; i < (unsigned int)H; i++) { - len = W; - p = CursorXYPos(X, Y + i); - ps = (unsigned char *) Cell; - x = X; - while (len > 0) { - if (!Refresh) { - c = CursorXYPos(x, Y + i); - skip = 0; - ops = ps; - ox = x; - olen = len; - while ((len > 0) && c[0] == ps[0] && c[1] == ps[1] ) - { - ps+=2; - c+=2; - x++; - len--; - skip++; - } - if (len <= 0) break; - if (skip <= 4) { - ps = ops; - x = ox; - len = olen; - } - } - p = ps; - l = 1; - temp[0] = *ps++; attr = *ps++; - while ((l < len) && ((unsigned char) (ps[1]) == attr)) { - temp[l++] = *ps++; - ps++; - } - if (!useXMB) - XDrawImageString(display, win, GCs[((unsigned)attr) & 0xFF], - x * FontCX, fontStruct->max_bounds.ascent + - (Y + i) * FontCY, - (char *)temp, l); -#ifdef USE_XMB - else - XmbDrawImageString(display, win, fontSet, - GCs[((unsigned)attr) & 0xFF], - x * FontCX, FontCYD + (Y + i) * FontCY, - (char *)temp, l); -#endif - //temp[l] = 0; printf("%s\n", temp); - len -= l; - x += l; - } -/* if (x < ScreenCols - 1) { - printf("XX %d %d %d\n", X, x, W); - XFillRectangle(display, win, GCs[15 * 16 + 7], - x * FontCX, (Y + i) * FontCY, - (ScreenCols - x - 1) * FontCX, FontCY); - } -*/ p = CursorXYPos(X, Y + i); - memcpy(p, Cell, W * 2); - if (i + Y == CursorY) - DrawCursor(1); - Cell += W; - } - return 0; -} - -int ConGetBox(int X, int Y, int W, int H, PCell Cell) { - int i; - - for (i = 0; i < H; i++) { - memcpy(Cell, CursorXYPos(X, Y + i), 2 * W); - Cell += W; - } - return 0; -} - -int ConPutLine(int X, int Y, int W, int H, PCell Cell) { - int i; - for (i = 0; i < H; i++) { - if (ConPutBox(X, Y + i, W, 1, Cell) != 0) return -1; - } - return 0; -} - -int ConSetBox(int X, int Y, int W, int H, TCell Cell) { - TDrawBuffer B; - int i; - - for (i = 0; i < W; i++) - B[i] = Cell; - ConPutLine(X, Y, W, H, B); - return 0; -} - -int ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count) { - TCell Cell; - int l; - - MoveCh(&Cell, ' ', Fill, 1); - DrawCursor(0); - if (Way == csUp) { - XCopyArea(display, win, win, GCs[0], - X * FontCX, - (Y + Count) * FontCY, - W * FontCX, - (H - Count) * FontCY, - X * FontCX, - Y * FontCY); - for (l = 0; l < H - Count; l++) - memcpy(CursorXYPos(X, Y + l), CursorXYPos(X, Y + l + Count), 2 * W); - - if (ConSetBox(X, Y + l, W, Count, Cell) == -1) - return -1; - } else if (Way == csDown) { - XCopyArea(display, win, win, GCs[0], - X * FontCX, - Y * FontCY, - W * FontCX, - (H - Count) * FontCY, - X * FontCX, - (Y + Count) * FontCY); - for (l = H - 1; l >= Count; l--) - memcpy(CursorXYPos(X, Y + l), CursorXYPos(X, Y + l - Count), 2 * W); - - if (ConSetBox(X, Y, W, Count, Cell) == -1) - return -1; - } - DrawCursor(1); - return 0; -} - -int ConSetSize(int X, int Y) { - unsigned char *NewBuffer; - unsigned char *p; - int i; - int MX, MY; - - p = NewBuffer = (unsigned char *) malloc(X * Y * 2); - if (NewBuffer == NULL) return -1; - for (i = 0; i < X * Y; i++) { - *p++ = ' '; - *p++ = 0x07; - } - MX = ScreenCols; - if (X < MX) - MX = X; - MY = ScreenRows; - if (Y < MY) - MY = Y; - p = NewBuffer; - for (i = 0; i < MY; i++) { - memcpy(p, CursorXYPos(0, i), MX * 2); - p += X * 2; - } - free(ScreenBuffer); - ScreenBuffer = NewBuffer; - ScreenCols = X; - ScreenRows = Y; - //ConPutBox(0, 0, ScreenCols, ScreenRows, (PCell) ScreenBuffer); - //if (Refresh == 0) - // XResizeWindow(display, win, ScreenCols * FontCX, ScreenRows * FontCY); - return 0; -} - -int ConQuerySize(int *X, int *Y) { - *X = ScreenCols; - *Y = ScreenRows; - return 0; -} - -int ConSetCursorPos(int X, int Y) { - DrawCursor(0); - CursorX = X; - CursorY = Y; - DrawCursor(1); - return 0; -} - -int ConQueryCursorPos(int *X, int *Y) { - *X = CursorX; - *Y = CursorY; - return 0; -} - -int ConShowCursor(void) { - CursorVisible = 1; - DrawCursor(1); - return 0; -} - -int ConHideCursor(void) { - DrawCursor(0); - CursorVisible = 0; - return 0; -} - -int ConCursorVisible(void) { - return 1; -} -int ConSetCursorSize(int Start, int End) { - return 1; -} - -int ConSetMousePos(int X, int Y) { - return 0; -} - -static int LastMouseX = -1, LastMouseY = -1; - -int ConQueryMousePos(int *X, int *Y) { - if (X) *X = LastMouseX; - if (Y) *Y = LastMouseY; - return 0; -} - -int ConShowMouse(void) { - printf("Show\n"); - return 0; -} - -int ConHideMouse(void) { - printf("Hide\n"); - return 0; -} - -int ConMouseVisible(void) { - return 1; -} - -int ConQueryMouseButtons(int *ButtonCount) { - *ButtonCount = 3; - return 0; -} - -void UpdateWindow(int xx, int yy, int ww, int hh) { - PCell p; - int i; - - /* show redrawn area */ - /* - XFillRectangle(display, win, GCs[14], xx, yy, ww, hh); - XFlush(display); - i = XEventsQueued(display, QueuedAfterReading); - while (i-- > 0) { - XEvent e; - XNextEvent(display, &e); - } - // sleep(1);*/ - - ww /= FontCX; ww += 2; - hh /= FontCY; - xx /= FontCX; - yy /= FontCY; - - /* - * OK for this moment I suggest this method - it works somehow - * But I suppose the correct solution would meant general rewrite - * of some basic behavior of FTE editor - * THIS IS TEMPORAL FIX AND SHOULD BE SOLVED IN GENERAL WAY ! - */ - hh *= 3; yy -= hh; hh += hh + 2; - if (yy < 0) - yy = 0; - if (xx + ww > (int)ScreenCols) ww = ScreenCols - xx; - if (yy + hh > (int)ScreenRows) hh = ScreenRows - yy; - Refresh = 1; - //frames->Repaint(); - //frames->Update(); - p = (PCell) CursorXYPos(xx, yy); - for (i = 0; i < hh; i++) { - ConPutBox(xx, yy + i, ww, 1, p); - p += ScreenCols; - } - //fprintf(stderr, "UPDATE\tx:%3d y:%3d w:%3d h:%3d\n", xx, yy, ww, hh); - //XFlush(display); - Refresh = 0; -} - -void ResizeWindow(int ww, int hh) { - int ox = ScreenCols; - int oy = ScreenRows; - ww /= FontCX; if (ww <= 4) ww = 4; - hh /= FontCY; if (hh <= 2) hh = 2; - if ((int)ScreenCols != ww || (int)ScreenRows != hh) { - Refresh = 0; - ConSetSize(ww, hh); - Refresh = 1; - if (ox < (int)ScreenCols) - UpdateWindow(ox * FontCX, 0, - (ScreenCols - ox) * FontCX, ScreenRows * FontCY); - if (oy < (int)ScreenRows) - UpdateWindow(0, oy * FontCY, - ScreenCols * FontCX, (ScreenRows - oy) * FontCY); - Refresh = 0; - } -} - -static struct { - long keysym; - long keycode; -} key_table[] = { - { XK_Escape, kbEsc }, - { XK_Tab, kbTab }, - { XK_Return, kbEnter }, - { XK_Pause, kbPause }, - { XK_BackSpace, kbBackSp }, - { XK_Home, kbHome }, - { XK_Up, kbUp }, - { XK_Prior, kbPgUp }, - { XK_Left, kbLeft }, - { XK_Right, kbRight }, - { XK_End, kbEnd }, - { XK_Down, kbDown }, - { XK_Next, kbPgDn }, - { XK_Select, kbEnd }, - { XK_KP_Enter, kbEnter | kfGray }, - { XK_Insert, kbIns | kfGray }, - { XK_Delete, kbDel | kfGray }, - { XK_KP_Add, '+' | kfGray }, - { XK_KP_Subtract, '-' | kfGray }, - { XK_KP_Multiply, '*' | kfGray }, - { XK_KP_Divide, '/' | kfGray }, - { XK_KP_Begin, kbPgUp | kfGray | kfCtrl }, - { XK_KP_Home, kbHome | kfGray }, - { XK_KP_Up, kbUp | kfGray }, - { XK_KP_Prior, kbPgUp | kfGray }, - { XK_KP_Left, kbLeft | kfGray }, - { XK_KP_Right, kbRight | kfGray }, - { XK_KP_End, kbEnd | kfGray }, - { XK_KP_Down, kbDown | kfGray }, - { XK_KP_Next, kbPgDn| kfGray }, - { XK_Num_Lock, kbNumLock }, - { XK_Caps_Lock, kbCapsLock }, - { XK_Print, kbPrtScr }, - { XK_Shift_L, kbShift }, - { XK_Shift_R, kbShift | kfGray }, - { XK_Control_L, kbCtrl }, - { XK_Control_R, kbCtrl | kfGray }, - { XK_Alt_L, kbAlt }, - { XK_Alt_R, kbAlt | kfGray }, - { XK_Meta_L, kbAlt }, - { XK_Meta_R, kbAlt | kfGray }, - { XK_F1, kbF1 }, - { XK_F2, kbF2 }, - { XK_F3, kbF3 }, - { XK_F4, kbF4 }, - { XK_F5, kbF5 }, - { XK_F6, kbF6 }, - { XK_F7, kbF7 }, - { XK_F8, kbF8 }, - { XK_F9, kbF9 }, - { XK_F10, kbF10 }, - { XK_F11, kbF11 }, - { XK_F12, kbF12 }, - { XK_KP_0, '0' | kfGray }, - { XK_KP_1, '1' | kfGray }, - { XK_KP_2, '2' | kfGray }, - { XK_KP_3, '3' | kfGray }, - { XK_KP_4, '4' | kfGray }, - { XK_KP_5, '5' | kfGray }, - { XK_KP_6, '6' | kfGray }, - { XK_KP_7, '7' | kfGray }, - { XK_KP_8, '8' | kfGray }, - { XK_KP_9, '9' | kfGray }, - { XK_KP_Decimal, '.' | kfGray }, - { 0x1000FF6F, kbDel | kfShift | kfGray }, - { 0x1000FF70, kbIns | kfCtrl | kfGray }, - { 0x1000FF71, kbIns | kfShift | kfGray }, - { 0x1000FF72, kbIns | kfGray }, - { 0x1000FF73, kbDel | kfGray }, - { 0x1000FF74, kbTab | kfShift }, - { 0x1000FF75, kbTab | kfShift }, - { 0, 0 } -}; - -void ConvertKeyToEvent(KeySym key, KeySym key1, char *keyname, char *keyname1, int etype, int state, TEvent *Event) { - unsigned int myState = 0; - - Event->What = evNone; - - switch (etype) { - case KeyPress: Event->What = evKeyDown; break; - case KeyRelease: Event->What = evKeyUp; break; - default: - return ; - } - - if (state & ShiftMask) myState |= kfShift; - if (state & ControlMask) myState |= kfCtrl; - if (state & Mod1Mask) myState |= kfAlt; - - /* modified kabi@fi.muni.cz - * for old method - * if (!KeyAnalyze((etype == KeyPress), state, &key, &key1)) - * return; - */ - - //printf("key: %d ; %d ; %d\n", key, key1, state); - if (key < 256 || (key1 < 256 && (myState == kfAlt || myState == (kfAlt | kfShift)))) { - if (myState & kfAlt) - key = key1; - if (myState == kfShift) - myState = 0; - if (myState & (kfAlt | kfCtrl)) - if ((key >= 'a') && (key < 'z' + 32)) - key &= ~0x20; - if ((myState & kfCtrl) && key < 32) - key += 64; - Event->Key.Code = key | myState; - return; - } else { - for (unsigned i = 0; i < (sizeof(key_table) / sizeof(key_table[0])); i++) { - long k; - - if ((long) key1 == key_table[i].keysym) { - k = key_table[i].keycode; - if (k < 256) - if (myState == kfShift) - myState = 0; - Event->Key.Code = k | myState; - return; - } - } - } - //printf("Unknown key: %ld %s %d %d\n", key, keyname, etype, state); - Event->What = evNone; -} - - -static TEvent LastMouseEvent = { evNone }; - -#define TM_DIFF(x,y) ((long)(((long)(x) < (long)(y)) ? ((long)(y) - (long)(x)) : ((long)(x) - (long)(y)))) - -void ConvertClickToEvent(int type, int xx, int yy, int button, int state, TEvent *Event, Time time) { - unsigned int myState = 0; - static unsigned long LastClickTime = 0; - static short LastClickCount = 0; - static unsigned long LastClick = 0; - unsigned long CurTime = time; - - if (type == MotionNotify) Event->What = evMouseMove; - else if (type == ButtonPress) Event->What = evMouseDown; - else Event->What = evMouseUp; - Event->Mouse.X = xx / FontCX; - Event->Mouse.Y = yy / FontCY; - if (Event->What == evMouseMove) - if (LastMouseX == Event->Mouse.X - && LastMouseY == Event->Mouse.Y) { - Event->What = evNone; - return; - } - LastMouseX = Event->Mouse.X; - LastMouseY = Event->Mouse.Y; - Event->Mouse.Buttons = 0; - if (type == MotionNotify) { - if (state & Button1Mask) Event->Mouse.Buttons |= 1; - if (state & Button2Mask) Event->Mouse.Buttons |= 4; - if (state & Button3Mask) Event->Mouse.Buttons |= 2; - } else { - switch (button) { - case Button1: Event->Mouse.Buttons |= 1; break; - case Button2: Event->Mouse.Buttons |= 4; break; - case Button3: Event->Mouse.Buttons |= 2; break; - case Button4: - case Button5: - if (type == ButtonPress) { - Event->What = evCommand; - if (state & ShiftMask) { - if (button == Button4) - Event->Msg.Command = cmHScrollPgLt; // fix core to use count - else - Event->Msg.Command = cmHScrollPgRt; - } else { - if (button == Button4) - Event->Msg.Command = cmVScrollPgUp; - else - Event->Msg.Command = cmVScrollPgDn; - } - } - return ; - } - } - Event->Mouse.Count = 1; - if (state & ShiftMask) myState |= kfShift; - if (state & ControlMask) myState |= kfCtrl; - if (state & Mod1Mask) myState |= kfAlt; -// if (state & Mod2Mask) myState |= kfAlt; -// if (state & Mod3Mask) myState |= kfAlt; -// if (state & Mod4Mask) myState |= kfAlt; - Event->Mouse.KeyMask = myState; - - if (Event->What == evMouseDown) { - if (LastClickCount) { - if (LastClick == Event->Mouse.Buttons) { - if (TM_DIFF(CurTime, LastClickTime) <= MouseMultiClick) { - Event->Mouse.Count = ++LastClickCount; - } else { - LastClickCount = 0; - } - } else { - LastClick = 0; - LastClickCount = 0; - LastClickTime = 0; - } - } - - LastClick = Event->Mouse.Buttons; - if (LastClickCount == 0) - LastClickCount = 1; - LastClickTime = CurTime; - } - /* if (Event->What == evMouseMove) { - LastClick = 0; - LastClickCount = 0; - LastClickTime = 0; - } - */ - LastMouseEvent = *Event; -} - -void ProcessXEvents(TEvent *Event) { - XEvent event; - XAnyEvent *anyEvent = (XAnyEvent *) &event; - XExposeEvent *exposeEvent = (XExposeEvent *) &event; - XButtonEvent *buttonEvent = (XButtonEvent *) &event; - XKeyEvent *keyEvent = (XKeyEvent *) &event; - XKeyEvent keyEvent1; - XConfigureEvent *configureEvent = (XConfigureEvent *) &event; - XGraphicsExposeEvent *gexposeEvent = (XGraphicsExposeEvent *) &event; - XMotionEvent *motionEvent = (XMotionEvent *) &event; - KeySym key, key1; - int state; - char keyName[32]; - char keyName1[32]; - - memset((void *)&event, 0, sizeof(event)); - Event->What = evNone; -#ifdef WINNT - rc = -1; -#else - rc = -#endif - XNextEvent(display, &event); - - if (XFilterEvent(&event, None)) - return; - - if (event.type == MappingNotify) { - XRefreshKeyboardMapping(&event.xmapping); - return; - } - - if (anyEvent->window != win) - return; - - switch (event.type) { - case Expose: - //fprintf(stderr, "EXPOSE\tx:%3d y:%3d w:%3d h:%3d\n", - // exposeEvent->x, exposeEvent->y, - // exposeEvent->width, exposeEvent->height); - UpdateWindow(exposeEvent->x, - exposeEvent->y, - exposeEvent->width, - exposeEvent->height); - break; - case GraphicsExpose: - /* catch up same events to speed up this a bit */ - state = XEventsQueued(display, QueuedAfterReading); - // printf("Event %d\n", state); - while (state-- > 0) { - XEvent e; - XGraphicsExposeEvent *ge = (XGraphicsExposeEvent *) &e; - - if (XCheckTypedWindowEvent(display, win, GraphicsExpose, &e)) { - if (gexposeEvent->x == ge->x - && gexposeEvent->y == ge->y - && gexposeEvent->width == ge->width - && gexposeEvent->height == ge->height) { - // fprintf(stderr, "found the same gexpose event\n"); - continue; - } else { - // fprintf(stderr, "caught different gexpose event\n"); - XPutBackEvent(display, &e); - } - } - break; - } - //fprintf(stderr, "GEXPOSE\tx:%3d y:%3d w:%3d h:%3d\n", - // gexposeEvent->x, gexposeEvent->y, - // gexposeEvent->width, gexposeEvent->height); - UpdateWindow(gexposeEvent->x, - gexposeEvent->y, - gexposeEvent->width, - gexposeEvent->height); - break; - case ConfigureNotify: - while ((XPending(display) > 0) && - XCheckTypedWindowEvent(display, win, - ConfigureNotify, &event)) - XSync(display, 0); - ResizeWindow(configureEvent->width, configureEvent->height); - Event->What = evCommand; - Event->Msg.Command = cmResize; - break; - case ButtonPress: - case ButtonRelease: - now = event.xbutton.time; - ConvertClickToEvent(event.type, buttonEvent->x, buttonEvent->y, buttonEvent->button, buttonEvent->state, Event, motionEvent->time); - break; - case FocusIn: - I18NFocusIn(xic); - break; - case FocusOut: - I18NFocusOut(xic); - break; - case KeyPress: - // case KeyRelease: - now = event.xkey.time; - state = keyEvent->state; - keyEvent1 = *keyEvent; - keyEvent1.state &= ~(ShiftMask | ControlMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask); - - if (event.type == KeyRelease) - XLookupString(keyEvent, keyName, sizeof(keyName), &key, 0); - else { - I18NLookupString(keyEvent, keyName, sizeof(keyName), &key, xic); - if (!key) - break; - } - XLookupString(&keyEvent1, keyName1, sizeof(keyName1), &key1, 0); - //printf("keyEvent->state = %d %s %08X\n", keyEvent->state, keyName, key); - //printf("keyEvent1.state = %d %s %08X\n", keyEvent1.state, keyName1, key1); - //key1 = XLookupKeysym(keyEvent, 0); - ConvertKeyToEvent(key, key1, keyName, keyName1, event.type, state, Event); - break; - case MotionNotify: - now = event.xmotion.time; - ConvertClickToEvent(event.type, motionEvent->x, motionEvent->y, 0, motionEvent->state, Event, motionEvent->time); - break; - case ClientMessage: - if (event.xclient.message_type == wm_protocols - && event.xclient.format == 32 - && (Atom)event.xclient.data.l[0] == wm_delete_window) - { - Event->What = evCommand; - Event->Msg.Command = cmClose; - } - break; - case SelectionClear: - { - Window owner; - - owner = XGetSelectionOwner(display, XA_PRIMARY); - if (owner != win) { - if (CurSelectionData != 0) - free(CurSelectionData); - CurSelectionData = 0; - CurSelectionLen = 0; - CurSelectionOwn = 0; - } - } - break; - case SelectionRequest: - { - XEvent notify; - - notify.type = SelectionNotify; - notify.xselection.requestor = event.xselectionrequest.requestor; - notify.xselection.selection = event.xselectionrequest.selection; - notify.xselection.target = event.xselectionrequest.target; - notify.xselection.time = event.xselectionrequest.time; - - if (event.xselectionrequest.selection == XA_PRIMARY && - event.xselectionrequest.target == XA_STRING) - { - XChangeProperty(display, - event.xselectionrequest.requestor, - event.xselectionrequest.property, - event.xselectionrequest.target, - 8, PropModeReplace, - (unsigned char *)(CurSelectionData ? CurSelectionData : ""), - CurSelectionLen); - notify.xselection.property = event.xselectionrequest.property; - } else if (event.xselectionrequest.selection == XA_PRIMARY && - event.xselectionrequest.target == targets) - { - Atom type = XA_STRING; - - XChangeProperty(display, - event.xselectionrequest.requestor, - event.xselectionrequest.property, - event.xselectionrequest.target, - 32, PropModeReplace, - (unsigned char *)&type, 1); - notify.xselection.property = event.xselectionrequest.property; - } else { - /*fprintf(stderr, - "selection request %ld prop: %ld target: %ld requestor=%lX\n", - event.xselectionrequest.selection, - event.xselectionrequest.property, - event.xselectionrequest.target, - event.xselectionrequest.requestor);*/ - - notify.xselection.property = None; - } - - XSendEvent(display, notify.xselection.requestor, False, 0L, ¬ify); - } - break; - } -} - -static TEvent Pending = { evNone }; - -int ConGetEvent(TEventMask EventMask, TEvent *Event, int WaitTime, int Delete) { - fd_set read_fds; - struct timeval timeout; - int rc; - static TEvent Queued = { evNone }; - - Event->What = evNone; - if (Queued.What != evNone) { - *Event = Queued; - if (Delete) Queued.What = evNone; - if (Event->What & EventMask) return 0; - else Queued.What = evNone; - } - - Event->What = evNone; - if (Pending.What != evNone) { - *Event = Pending; - if (Delete) Pending.What = evNone; - if (Event->What & EventMask) return 0; - else - Pending.What = evNone; - } - - Event->What = evNone; - while (Event->What == evNone) { - Event->What = evNone; - while (XPending(display) > 0) { - ProcessXEvents(Event); - if (Event->What != evNone) { - while ((Event->What == evMouseMove) && (Queued.What == evNone)) { - while ((rc = XPending(display)) > 0) { - ProcessXEvents(&Queued); - if (Queued.What == evMouseMove) { - *Event = Queued; - Queued.What = evNone; - } else break; - } - if (rc <= 0) break; - } - } - if (Delete == 0) - Pending = *Event; - if (Event->What & EventMask) return 0; - else - Pending.What = evNone; - Event->What = evNone; - } - - Event->What = evNone; - FD_ZERO(&read_fds); - FD_SET(ConnectionNumber(display), &read_fds); - for (int p = 0; p < MAX_PIPES; p++) - if (Pipes[p].used) - if (Pipes[p].fd != -1) - FD_SET(Pipes[p].fd, &read_fds); - - if ((WaitTime == -1 || WaitTime > MouseAutoDelay) && (LastMouseEvent.What == evMouseAuto) && (EventMask & evMouse)) { - timeout.tv_sec = 0; - timeout.tv_usec = MouseAutoDelay * 1000; - rc = select(sizeof(fd_set) * 8, - FD_SET_CAST() &read_fds, NULL, NULL, - &timeout); - if (rc == 0) { - *Event = LastMouseEvent; - return 0; - } - } else if ((WaitTime == -1 || WaitTime > MouseAutoRepeat) && (LastMouseEvent.What == evMouseDown || LastMouseEvent.What == evMouseMove) - && - (LastMouseEvent.Mouse.Buttons) && (EventMask & evMouse)) - { - timeout.tv_sec = 0; - timeout.tv_usec = MouseAutoRepeat * 1000; - rc = select(sizeof(fd_set) * 8, - FD_SET_CAST() &read_fds, NULL, NULL, - &timeout); - if (rc == 0) { - LastMouseEvent.What = evMouseAuto; - *Event = LastMouseEvent; - return 0; - } - } else if (WaitTime == -1) { - rc = select(sizeof(fd_set) * sizeof(char), - FD_SET_CAST() &read_fds, NULL, NULL, - NULL); - } else { - timeout.tv_sec = 0; - timeout.tv_usec = WaitTime * 1000 + 1; - rc = select(sizeof(fd_set) * sizeof(char), - FD_SET_CAST() &read_fds, NULL, NULL, - &timeout); - } - - if (rc == 0 || rc == -1) { - Event->What = evNone; - return -1; - } - if (FD_ISSET(ConnectionNumber(display), &read_fds)) // X has priority - continue; - for (int pp = 0; pp < MAX_PIPES; pp++) { - if (Pipes[pp].used) - if (Pipes[pp].fd != -1) - if (FD_ISSET(Pipes[pp].fd, &read_fds)) { - if (Pipes[pp].notify) { - Event->What = evNotify; - Event->Msg.View = 0; - Event->Msg.Model = Pipes[pp].notify; - Event->Msg.Command = cmPipeRead; - Event->Msg.Param1 = pp; - Pipes[pp].stopped = 0; - } - //fprintf(stderr, "Pipe %d\n", Pipes[pp].fd); - return 0; - } - } - } - return 0; -} - -int ConPutEvent(TEvent Event) { - Pending = Event; - return 0; -} - -int ConFlush(void) { - XFlush(display); - return 0; -} - -int ConGrabEvents(TEventMask EventMask) { - return 0; -} - -int GetXSelection(int *len, char **data) { - if (CurSelectionOwn) { - *data = (char *) malloc(CurSelectionLen); - if (*data == 0) - return -1; - memcpy(*data, CurSelectionData, CurSelectionLen); - *len = CurSelectionLen; - return 0; - } else { - if (XGetSelectionOwner(display, XA_PRIMARY) != None) { - XEvent event; - Atom type; - long extra; - int i; - long l; - time_t time_started; - - assert(selection_buffer != None); - - XConvertSelection(display, - XA_PRIMARY, XA_STRING, - selection_buffer, win, now); - - time_started = time(NULL); - - for (;;) { - if (XCheckTypedWindowEvent(display, - win, - SelectionNotify, - &event)) - break; - - time_t now = time(NULL); - - if (time_started > now) - time_started = now; - - if (now - time_started > 5000) - return -1; - } - - /*do - { - XNextEvent(display, &event); - } while (event.type != SelectionNotify && - event.xselection.property != None && - event.type != ButtonPress);*/ - - if (event.type == SelectionNotify - && event.xselection.property != None) { - XGetWindowProperty(display, - event.xselection.requestor, - event.xselection.property, - 0L, 0x10000, True, - event.xselection.target, &type, &i, - (unsigned long *)&l, - (unsigned long *)&extra, - (unsigned char **)data); - - *len = l; - return 0; - } - return -1; - } - } - *data = XFetchBytes(display, len); - if (*data == 0) - return -1; - else - return 0; -} - -int SetXSelection(int len, char *data) { - if (CurSelectionData != 0) { - free(CurSelectionData); - } - CurSelectionData = (char *)malloc(len); - if (CurSelectionData == 0) { - CurSelectionLen = 0; - return -1; - } - CurSelectionLen = len; - memcpy(CurSelectionData, data, CurSelectionLen); - if (CurSelectionLen < 64 * 1024) { - XStoreBytes(display, data, len); - XSetSelectionOwner(display, XA_PRIMARY, win, CurrentTime); - if (XGetSelectionOwner(display, XA_PRIMARY) == win) - CurSelectionOwn = 1; - } else { - XSetSelectionOwner(display, XA_PRIMARY, None, CurrentTime); - } - return 0; -} - -GUI::GUI(int &argc, char **argv, int XSize, int YSize) { - int o = 1; - - for (int c = 1; c < argc; c++) { - if (strcmp(argv[c], "-font") == 0) { - if (c + 1 < argc) { - strcpy(WindowFont, argv[++c]); - } - } else if (strcmp(argv[c], "-geometry") == 0) { - if (c + 1 < argc) { - - XParseGeometry(argv[++c], &initX, &initY, - &ScreenCols, &ScreenRows); - if (ScreenCols > 255) - ScreenCols = 255; - else if (ScreenCols < MIN_SCRWIDTH) - ScreenCols = MIN_SCRWIDTH; - if (ScreenRows > 255) - ScreenRows = 255; - else if (ScreenRows < MIN_SCRHEIGHT) - ScreenRows = MIN_SCRHEIGHT; - setUserPosition = 1; - } - } else if ((strcmp(argv[c], "-noxmb") == 0) - || (strcmp(argv[c], "--noxmb") == 0)) - useXMB = 0; - else - argv[o++] = argv[c]; - } - argc = o; - argv[argc] = 0; - - if (SetupXWindow(argc, argv) == 0 && - ::ConInit(XSize, YSize) == 0) - gui = this; - else - gui = NULL; - fArgc = argc; - fArgv = argv; -} - -GUI::~GUI() { - ::ConDone(); -} - -int GUI::ConSuspend(void) { - return ::ConSuspend(); -} - -int GUI::ConContinue(void) { - return ::ConContinue(); -} - -int GUI::ShowEntryScreen() { - return 1; -} - -int GUI::OpenPipe(char *Command, EModel *notify) { -#ifndef NO_PIPES - int i; - - for (i = 0; i < MAX_PIPES; i++) { - if (Pipes[i].used == 0) { - int pfd[2]; - - Pipes[i].id = i; - Pipes[i].notify = notify; - Pipes[i].stopped = 1; - - if (pipe((int *)pfd) == -1) - return -1; - - switch (Pipes[i].pid = fork()) { - case -1: /* fail */ - return -1; - case 0: /* child */ - signal(SIGPIPE, SIG_DFL); - close(pfd[0]); - close(0); - assert(open("/dev/null", O_RDONLY) == 0); - dup2(pfd[1], 1); - dup2(pfd[1], 2); - close(pfd[1]); - exit(system(Command)); - default: - close(pfd[1]); - fcntl(pfd[0], F_SETFL, O_NONBLOCK); - Pipes[i].fd = pfd[0]; - } - Pipes[i].used = 1; - //fprintf(stderr, "Pipe Open: %d\n", i); - return i; - } - } - return -1; -#else - return 0; -#endif -} - -int GUI::SetPipeView(int id, EModel *notify) { -#ifndef NO_PIPES - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - //fprintf(stderr, "Pipe View: %d %08X\n", id, notify); - Pipes[id].notify = notify; -#endif - return 0; -} - -int GUI::ReadPipe(int id, void *buffer, int len) { -#ifndef NO_PIPES - int rc; - - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - //fprintf(stderr, "Pipe Read: Get %d %d\n", id, len); - - rc = read(Pipes[id].fd, buffer, len); - //fprintf(stderr, "Pipe Read: Got %d %d\n", id, len); - if (rc == 0) { - close(Pipes[id].fd); - Pipes[id].fd = -1; - return -1; - } - if (rc == -1) { - Pipes[id].stopped = 1; - return 0; - } - return rc; -#else - return 0; -#endif -} - -int GUI::ClosePipe(int id) { -#ifndef NO_PIPES - int status; - - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - if (Pipes[id].fd != -1) - close(Pipes[id].fd); - kill(Pipes[id].pid, SIGHUP); - alarm(2); - waitpid(Pipes[id].pid, &status, 0); - alarm(0); - //fprintf(stderr, "Pipe Close: %d\n", id); - Pipes[id].used = 0; - return WEXITSTATUS(status); -#else - return 0; -#endif -} - -int GUI::RunProgram(int mode, char *Command) { - char Cmd[1024]; - - char const* xterm = getenv("TERM"); - if (NULL == xterm || 0 == *xterm) - xterm = "xterm"; - - strcpy(Cmd, xterm); - - if (*Command == 0) // empty string = shell - strcat(Cmd, " -ls &"); - else { - strcat(Cmd, " -e "); - // buffer overflow problem: -2 for possible async. - strncat(Cmd, Command, sizeof(Cmd) - strlen(Cmd) - 2); - Cmd[sizeof(Cmd) - 3] = 0; - if (mode == RUN_ASYNC) - strcat(Cmd, " &"); - } - rc = system(Cmd); - return rc; -} - -char ConGetDrawChar(int index) { - static char tab[] = "\x0D\x0C\x0E\x0B\x12\x19____+>\x1F\x01\x12 "; - - assert(index >= 0 && index < (int) strlen(tab)); - - return tab[index]; -} diff --git a/src/defcfg2.fte b/src/defcfg2.fte deleted file mode 100644 index 3355be3..0000000 --- a/src/defcfg2.fte +++ /dev/null @@ -1,264 +0,0 @@ -menu File { - item "&Open...\tCtrl+O" { FileOpen } - item "&Reload" { FileReload } - item "&Save\tCtrl+S" { FileSave } - item "Save &As..." { FileSaveAs } - item "Save Al&l" { FileSaveAll } - item "&Close\tCtrl+W" { FileClose } - item; - item "E&xit\tCtrl+Q" { ExitEditor } -} - -menu Edit { - item "&Undo\tCtrl+Z" { Undo } - item "&Redo" { Redo } - item; - item "Cu&t\tCtrl+X" { BlockCut } - item "&Copy\tCtrl+C" { BlockCopy } - item "&Paste\tCtrl+V" { BlockPasteStream } -} - -menu Search { - item "&Find...\tCtrl+F" { Find } - item "Find &Next\tCtrl+G" { FindRepeat } - item; - item "Find and &replace...\tCtrl+R" { FindReplace } - item; - item "&Goto line..." { MoveToLine } -} - -menu Help { - item "&About..." { ShowVersion } -} - -menu Main { - submenu "&File", File; - submenu "&Edit", Edit; - submenu "&Search", Search; - submenu "&Help", Help; -} - -menu Local { - item "&Unmark\tEsc" { BlockUnmark } - item "Cu&t\tCtrl+X" { BlockCut } - item "&Copy\tCtrl+C" { BlockCopy } - item "&Paste\tCtrl+V" { BlockPasteStream } - item "Cl&ose\tAlt+Q" { FileClose } -} - -eventmap MODEL { # basic commands, for files, directories, message view, etc. - key [C+O] { FileOpen } - key [C+W] { FileClose } - - key [F10] { MainMenu } - key [S+F10] { LocalMenu } - - key [C+Q] { ExitEditor } - - key [A+G-Left] { FilePrev } - key [A+G-Right] { FileNext } -} - -eventmap PLAIN: MODEL { -# keymap for plaintext mode - MainMenu = 'Main'; # menu for menubar - LocalMenu = 'Local'; # local menu - - key [Esc] { BlockMarkStream; BlockUnmark } - key [C+S] { FileSave } - - key [C+C] { BlockCopy } - key [C+V] { BlockPasteStream } - key [C+X] { BlockCut } - - key [A+BackSp] { Undo } - key [A+S+BackSp] { Redo } - - key [G-Enter] { LineNew } - key [BackSp] { BackSpace } - key [G-Ins] { ToggleInsert } - key [G-Del] { Delete } - key [Tab] { InsertTab } - key [C+BackSp] { KillWordPrev } - - key [C+F] { Find } - key [C+G] { FindRepeat } - - key [G-Left] { MoveLeft } - key [C+G-Left] { MoveWordPrev } - key [G-Right] { MoveRight } - key [C+G-Right] { MoveWordNext } - key [G-Up] { MoveUp } - key [G-Down] { MoveDown } - key [G-Home] { MoveLineStart } - key [C+G-Home] { MovePageStart } - key [G-End] { MoveLineEnd } - key [C+G-End] { MovePageEnd } - key [G-PgUp] { MovePageUp } - key [C+G-PgUp] { MoveFileStart } - key [G-PgDn] { MovePageDown } - key [C+G-PgDn] { MoveFileEnd } - - key [S+G-Left] { BlockExtendBegin; MoveLeft; BlockExtendEnd } - key [S+G-Right] { BlockExtendBegin; MoveRight; BlockExtendEnd } - key [C+G-S+Left] { BlockExtendBegin; MoveWordPrev; BlockExtendEnd } - key [C+G-S+Right] { BlockExtendBegin; MoveWordNext; BlockExtendEnd } - key [G-S+Up] { BlockExtendBegin; MoveUp; BlockExtendEnd } - key [G-S+Down] { BlockExtendBegin; MoveDown; BlockExtendEnd } - key [G-S+Home] { BlockExtendBegin; MoveLineStart; BlockExtendEnd } - key [G-S+End] { BlockExtendBegin; MoveLineEnd; BlockExtendEnd } - key [C+G-S+Home] { BlockExtendBegin; MovePageStart; BlockExtendEnd } - key [C+G-S+End] { BlockExtendBegin; MovePageEnd; BlockExtendEnd } - key [G-S+PgUp] { BlockExtendBegin; MovePageUp; BlockExtendEnd } - key [G-S+PgDn] { BlockExtendBegin; MovePageDown; BlockExtendEnd } - key [C+G-S+PgUp] { BlockExtendBegin; MoveFileStart; BlockExtendEnd } - key [C+G-S+PgDn] { BlockExtendBegin; MoveFileEnd; BlockExtendEnd } - - key [C+G-Ins] { BlockCopy } - key [S+G-Ins] { BlockPasteStream } - key [S+G-Del] { BlockCut } - - key [F7] { BlockBegin } - key [S+F7] { MoveBlockStart } - key [F8] { BlockEnd } - key [S+F8] { MoveBlockEnd } - - key [A+E] { MainMenu 'E' } - key [A+F] { MainMenu 'F' } - key [A+H] { MainMenu 'H' } - key [A+S] { MainMenu 'S' } -} - -colorize PLAIN { - SyntaxParser = 'PLAIN'; - -# color { -# { 'Normal', '-7' }, -# }; -} - -mode PLAIN { - Colorizer = 'PLAIN'; -} - -eventmap LIST { - key [G-Left] { MoveLeft } - key [G-Right] { MoveRight } - key [G-Up] { MoveUp } - key [G-Down] { MoveDown } - key [G-Home] { MoveLineStart } - key [C+G-Home] { MovePageStart } - key [G-End] { MoveLineEnd } - key [C+G-End] { MovePageEnd } - key [G-PgUp] { MovePageUp } - key [C+G-PgUp] { MoveFileStart } - key [G-PgDn] { MovePageDown } - key [C+G-PgDn] { MoveFileEnd } - key [A+G-Up] { ScrollUp } - key [A+G-Down] { ScrollDown } - key [A+G-Left] { ScrollLeft } - key [A+G-Right] { ScrollRight } - - key [Esc] { Cancel } - key [G-Enter] { Activate } -} - -eventmap BUFFERS: LIST { - key [C+F10] { FileClose } - key [F2] { FileSave } -} - -eventmap ROUTINES: LIST { -} - -eventmap MLIST: MODEL { - key [G-Left] { MoveLeft } - key [G-Right] { MoveRight } - key [G-Up] { MoveUp } - key [G-Down] { MoveDown } - key [G-Home] { MoveLineStart } - key [C+G-Home] { MovePageStart } - key [G-End] { MoveLineEnd } - key [C+G-End] { MovePageEnd } - key [G-PgUp] { MovePageUp } - key [C+G-PgUp] { MoveFileStart } - key [G-PgDn] { MovePageDown } - key [C+G-PgDn] { MoveFileEnd } -# key [A+G-Up] { ScrollUp } -# key [A+G-Down] { ScrollDown } -# key [A+G-Left] { ScrollLeft } -# key [A+G-Right] { ScrollRight } - - key [G-Enter] { Activate } -} - -menu Directory { - item "&Next\tF6" { FileNext } - item "&Previous\tShift+F6" { FilePrev } - item; - item "&Close\tAlt+Q" { FileClose } - item; - item "E&xit\tAlt+X" { ExitEditor } -} - -menu Navigate { - item "Go &< level\tCtrl+PgUp" { DirGoUp } - item "Go &> level\tCtrl+PgDn" { DirGoDown } - item "Go to &\\\tCtrl+\\" { DirGoRoot } -# item "&/ Goto Dir\t/" { DirGoto } - item "&\\ Goto Dir\t\\" { DirGoto } - item; - item '&A:\\' { DirGoto 'A:\\' } - item '&B:\\' { DirGoto 'B:\\' } - item '&C:\\' { DirGoto 'C:\\' } - item '&D:\\' { DirGoto 'D:\\' } - item '&E:\\' { DirGoto 'E:\\' } - item '&F:\\' { DirGoto 'F:\\' } - item '&G:\\' { DirGoto 'G:\\' } - item '&H:\\' { DirGoto 'H:\\' } - item '&I:\\' { DirGoto 'I:\\' } -} - -menu DirMain { - submenu "&Directory", Directory; - submenu "&Navigate", Navigate; - submenu "&Tools", Tools; - submenu "&Window", Window; -} - -eventmap DIRECTORY: MLIST { - MainMenu = 'DirMain'; - - key [C+G-PgUp] { DirGoUp } - key [C+G-PgDn] { DirGoDown } - key [C+\\] { DirGoRoot } - key [/] { DirGoto } - key [\\] { DirGoto } - - key [A+D] { MainMenu 'D' } - key [A+N] { MainMenu 'N' } - key [A+W] { MainMenu 'W' } -} - -menu Messages { - item "&Close\tAlt+Q" { FileClose } - item; - item "&Next\tF6" { FileNext } - item "&Previous\tShift+F6" { FilePrev } - item; - item "E&xit\tAlt+X" { ExitEditor } -} - -menu MsgMain { - submenu "&Messages", Messages; - submenu "&Tools", Tools; - submenu "&Window", Window; -} - -eventmap MESSAGES: MLIST { - MainMenu = "MsgMain"; - - key [A+M] { MainMenu 'M' } - key [A+T] { MainMenu 'T' } - key [A+W] { MainMenu 'W' } -} diff --git a/src/dialog.h b/src/dialog.h deleted file mode 100644 index b66d06f..0000000 --- a/src/dialog.h +++ /dev/null @@ -1,23 +0,0 @@ -/* dialog.h - * - * Copyright (c) 1994-1996, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -#ifndef __DIALOG_H__ -#define __DIALOG_H__ - -#define askYes 0 -#define askNo 1 -#define askCancel 2 -#define askOK 3 - -int AskString(char *Prompt, char *String, int MaxLen); -int AskYesNo(char *Prompt); -int AskYesNoCancel(char *Prompt); -int AskOKCancel(char *Prompt); - -#endif diff --git a/src/e_os2.cpp b/src/e_os2.cpp deleted file mode 100644 index e922f3f..0000000 --- a/src/e_os2.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* e_os2.cpp - * - * Copyright (c) 1997, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -// Win32 (NT) specific routines - -#include "fte.h" - -int EView::SysShowHelp(ExState &State, const char *word) { - char file[MAXPATH] = ""; - char cmd[1024]; - - if (State.GetStrParam(this, file, sizeof(file) - 1) == 0) - if (MView->Win->GetStr("Help file", - sizeof(file) - 1, file, HIST_DEFAULT) == 0) - return 0; - - char wordAsk[64] = ""; - if (word == 0) { - if (State.GetStrParam(this, wordAsk, sizeof(wordAsk) - 1) == 0) - if (MView->Win->GetStr("Keyword", - sizeof(wordAsk) - 1, wordAsk, HIST_DEFAULT) == 0) - return 0; - word = wordAsk; - } - - sprintf(cmd, "%s %s %s", HelpCommand, file, word); - - if (system(cmd) != 0) { - Msg(S_ERROR, "Failed to start view.exe!"); - return 0; - } - return 1; -} diff --git a/src/e_unix.cpp b/src/e_unix.cpp deleted file mode 100644 index 01fc79c..0000000 --- a/src/e_unix.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* e_unix.cpp - * - * Copyright (c) 1997, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -#ifdef WINNT -#include "e_win32.cpp" -#else - -// UNIX specific routines - -#include "fte.h" - -#include -#include - -int EView::SysShowHelp(ExState &State, const char *word) { - char options[128] = ""; - char command[1024]; - char file[MAXPATH]; - - if (State.GetStrParam(this, options, sizeof(options) - 1) == 0) - options[0] = 0; - - char wordAsk[64] = ""; - if (word == 0) { - if (State.GetStrParam(this, wordAsk, sizeof(wordAsk) - 1) == 0) - if (MView->Win->GetStr("Keyword", - sizeof(wordAsk) - 1, wordAsk, HIST_DEFAULT) == 0) - return 0; - word = wordAsk; - } - - sprintf(file, "/tmp/fte%d-man-%s", getpid(), word); - sprintf(command, "%s %s %s >'%s' 2>&1", HelpCommand, options, word, file); - - /// !!! why is this needed ??? -#define SYSCALL(call) while(((call) == -1) && (errno == EINTR)) - pid_t pid; - int err, status; - - Msg(S_INFO, "Retrieving man page for %s, please wait", word); - - if ((pid = fork()) == 0) { - close(1); - SYSCALL(err = open(file, O_CREAT | O_WRONLY | O_APPEND, S_IRWXU)); - if (err != -1) { - close(2); - //dup(1); // ignore error output - close(0); - assert(open("/dev/null", O_RDONLY) == 0); - execlp("man", "man", -#ifndef AIX // current AIX's don't like the -a. - "-a", -#endif - word, NULL); - // execlp("/bin/sh", "sh", "-c", command, NULL); - } - perror("Can't Exec Command\n"); - exit(-1); - } else if (pid < 0) { - perror("Can't fork"); - return 0; - } - SYSCALL(err = waitpid(pid, &status, 0)); - if (err == -1) { - perror("Waitpid failed\n"); - return 0; - } - - // int rc = system(command); - - err = FileLoad(0, file, "CATBS", this); - unlink(file); - - if (err == 0){ - Msg(S_ERROR, "Error code %d retrieving manpage for %s", err, word); - return 0; - } - return 1; -} - -#endif diff --git a/src/e_win32.cpp b/src/e_win32.cpp deleted file mode 100644 index 55b5285..0000000 --- a/src/e_win32.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* e_win32.cpp - * - * Copyright (c) 1997, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -// Win32 (NT) specific routines - -#include "fte.h" - -#include - -int EView::SysShowHelp(ExState &State, const char *word) { - char file[MAXPATH] = ""; - - if (State.GetStrParam(this, file, sizeof(file) - 1) == 0) - if (MView->Win->GetStr("Help file", - sizeof(file) - 1, file, HIST_DEFAULT) == 0) - return 0; - - char wordAsk[64] = ""; - if (word == 0) { - if (State.GetStrParam(this, wordAsk, sizeof(wordAsk) - 1) == 0) - if (MView->Win->GetStr("Keyword", - sizeof(wordAsk) - 1, wordAsk, HIST_DEFAULT) == 0) - return 0; - word = wordAsk; - } - - //** Start WinHelp, - if (!WinHelp(0, file, HELP_KEY, (DWORD)word)) { - Msg(S_ERROR, "Failed to start WinHelp!"); - return 0; - } - return 1; -} diff --git a/src/fnmatch.h b/src/fnmatch.h deleted file mode 100644 index eeaee7f..0000000 --- a/src/fnmatch.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (C) 1991, 92, 93, 96, 97, 98 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _FNMATCH_H -#define _FNMATCH_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32 -# if !defined __GLIBC__ || !defined __P -# undef __P -# define __P(protos) protos -# endif -#else /* Not C++ or ANSI C. */ -# undef __P -# define __P(protos) () -/* We can get away without defining `const' here only because in this file - it is used only inside the prototype for `fnmatch', which is elided in - non-ANSI C where `const' is problematical. */ -#endif /* C++ or ANSI C. */ - -#ifndef const -# if (defined __STDC__ && __STDC__) || defined __cplusplus -# define __const const -# else -# define __const -# endif -#endif - -/* We #undef these before defining them because some losing systems - (HP-UX A.08.07 for example) define these in . */ -#undef FNM_PATHNAME -#undef FNM_NOESCAPE -#undef FNM_PERIOD - -/* Bits set in the FLAGS argument to `fnmatch'. */ -#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ -#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ -#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ - -#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE -# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ -# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ -# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ -#endif - -/* Value returned by `fnmatch' if STRING does not match PATTERN. */ -#define FNM_NOMATCH 1 - -/* This value is returned if the implementation does not support - `fnmatch'. Since this is not the case here it will never be - returned but the conformance test suites still require the symbol - to be defined. */ -#ifdef _XOPEN_SOURCE -# define FNM_NOSYS (-1) -#endif - -/* Match STRING against the filename pattern PATTERN, - returning zero if it matches, FNM_NOMATCH if not. */ -extern int fnmatch __P ((__const char *__pattern, __const char *__string, - int __flags)); - -#ifdef __cplusplus -} -#endif - -#endif /* fnmatch.h */ diff --git a/src/fte-bcc2.mak b/src/fte-bcc2.mak deleted file mode 100644 index 62b8eb1..0000000 --- a/src/fte-bcc2.mak +++ /dev/null @@ -1,72 +0,0 @@ -LIBDIR = \BCOS2\LIB -INCDIR = \BCOS2\INCLUDE - -.AUTODEPEND - -DEFINES=-DOS2 -DBCPP -DHEAPWALK - -DEBUG = -#DEBUG=-v - -INIT = $(LIBDIR)\c02.obj - -CC = bcc -LD = tlink -CCFLAGS = $(DEFINES) -L$(LIBDIR) -I$(INCDIR) -H=fte.CSM \ - -k- -sm -K -w -w-par -Ot -RT- -xd- -x- -vi- -d -a -y $(DEBUG) - -LDFLAGS = -L$(LIBDIR) $(DEBUG) -s -Toe -Oc -B:0x10000 -OEXT=obj - -!include objs.inc - -.cpp.$(OEXT): - $(CC) $(CCFLAGS) -c {$< } - -.c.$(OEXT): - $(CC) $(CCFLAGS) -c {$< } - -all: cfte.exe fte.exe ftepm.exe clipserv.exe cliputil.exe - -defcfg.cnf: defcfg.fte cfte.exe - cfte defcfg.fte defcfg.cnf - -defcfg.h: defcfg.cnf bin2c.exe - bin2c defcfg.cnf >defcfg.h - -c_config.obj: defcfg.h - -bin2c.exe: bin2c.cpp - $(CC) $(CCFLAGS) bin2c.cpp - -cfte.exe: $(CFTE_OBJS) - $(LD) @&&| - $(LDFLAGS) $(INIT) $**,cfte.exe,cfte.map,os2 c2mt,cfte.def -| - -fte.exe: $(OBJS) $(VIOOBJS) - $(LD) @&&| - $(LDFLAGS) $(INIT) $**,fte.exe,fte.map,os2 c2mt,fte.def -| - -ftepm.exe:: $(OBJS) $(PMOBJS) - $(LD) @&&| - $(LDFLAGS) $(INIT) $**,ftepm.exe,ftepm.map,c2mt os2,ftepm.def -| - rc -i $(INCDIR) ftepm.rc ftepm.exe - -clipserv.exe: clipserv.obj - $(LD) @&&| - $(LDFLAGS) $(INIT) $**,clipserv.exe,clipserv.map,c2mt os2,clipserv.def -| - -cliputil.exe: cliputil.obj clip_vio.obj - $(LD) @&&| - $(LDFLAGS) $(INIT) $**,cliputil.exe,cliputil.map,c2mt os2,cliputil.def -| - -ftepm.exe:: ftepm.res - rc ftepm.res ftepm.exe - -ftepm.res: ftepm.rc pmdlg.rc - rc -i $(INCDIR) -r ftepm.rc diff --git a/src/fte-bcc5.mak b/src/fte-bcc5.mak deleted file mode 100644 index 2d729a4..0000000 --- a/src/fte-bcc5.mak +++ /dev/null @@ -1,63 +0,0 @@ -# -# FTE makefile for use with Borland C++ 5.5.x/C++Builder 5 -# -# The author, Jon Svendsen, explicitly places this module -# in the Public Domain -# -# Assumes compiler-native includes to be in $(MAKEDIR)\..\Include -# and libraries in $(MAKEDIR)\..\Libs -# $(MAKEDIR) is set by Borland make and is the location of your make.exe -# - -INCDIR = $(MAKEDIR)\..\Include -LIBDIR = $(MAKEDIR)\..\Lib - -OPTIMIZE = -O2 - -CC = bcc32 -LD = ilink32 - -OEXT = obj - -DEFS = -DNT -DNTCONSOLE -DBCPP - -CCFLAGS = $(OPTIMIZE) -w-aus -w-par -tWC $(DEFS) -I$(INCDIR) -LDFLAGS = -ap -Tpe -c -x -Gn -L$(LIBDIR) -j$(LIBDIR) -LDOBJS = c0x32.obj -LDLIBS = import32.lib cw32.lib - -!include objs.inc - -.cpp.$(OEXT): - $(CC) $(CCFLAGS) -c {$< } - -.c.$(OEXT): - $(CC) $(CCFLAGS) -c {$< } - -all: cfte.exe fte.exe - -defcfg.cnf: defcfg.fte cfte.exe - cfte defcfg.fte defcfg.cnf - -defcfg.h: defcfg.cnf bin2c.exe - bin2c defcfg.cnf >defcfg.h - -c_config.obj: defcfg.h - -bin2c.exe: bin2c.obj - $(LD) $(LDFLAGS) $(LDOBJS) bin2c.obj,$< ,,$(LDLIBS) ,, - -cfte.exe: $(CFTE_OBJS) - $(LD) $(LDFLAGS) $(LDOBJS) $(CFTE_OBJS),$< ,,$(LDLIBS) ,, - -fte.exe: $(OBJS) $(NTOBJS) - $(LD) $(LDFLAGS) $(LDOBJS) $(OBJS) $(NTOBJS),$< ,,$(LDLIBS) ,, - -clean: - del *.$(OEXT) - del *.tds - del fte.exe - del cfte.exe - del bin2c.exe - del defcfg.h - del defcfg.cnf diff --git a/src/fte-cygwin-xf86.mak b/src/fte-cygwin-xf86.mak deleted file mode 100644 index e6fa373..0000000 --- a/src/fte-cygwin-xf86.mak +++ /dev/null @@ -1,103 +0,0 @@ -# versions of FTE to build - -# Versions: -# xfte - using XLib (the most stable) - -TARGETS = xfte - -PRIMARY = xfte - -# Comment or uncoment this two flags below if -# you want to use: - -# Keyboard remaping by XFTE -#REMAPFLAG = -DUSE_HARD_REMAP - -# Drawing fonts with locale support -XMBFLAG = -DUSE_XMB - -# System X11R6 is compiled with X_LOCALE -#SYSTEM_X_LOCALE = -DX_LOCALE - -I18NOPTIONS = $(XMBFLAG) $(REMAPFLAG) $(SYSTEM_X_LOCALE) - -# Optionally, you can define: -# -DDEFAULT_INTERNAL_CONFIG to use internal config by default -# -DUSE_XTINIT to use XtInitialize on init -# -DFTE_NO_LOGGING to completely disable trace logging -APPOPTIONS = -DDEFAULT_INTERNAL_CONFIG - -#gcc/g++ -COPTIONS = -Wall -Wpointer-arith -Wconversion -Wwrite-strings \ - -Wmissing-prototypes -Wmissing-declarations -Winline - -#CC = g++ -#LD = g++ -# try this for smaller/faster code and less dependencies -CC = g++ -fno-rtti -fno-exceptions -LD = g++ -fno-rtti -fno-exceptions - - -####################################################################### -# Linux -UOS = -DLINUX -XINCDIR = -I/usr/X11R6/include -XLIBDIR = -L/usr/X11R6/lib -lstdc++ -SOCKETLIB = -lwsock32 -liberty - -####################################################################### - -LIBDIR = -INCDIR = - -#OPTIMIZE = -g # -O -g -OPTIMIZE = -O2 -#OPTIMIZE = -O2 -s - -CCFLAGS = $(OPTIMIZE) $(I18NOPTIONS) $(APPOPTIONS) $(COPTIONS) -DUNIX $(UOS) \ - $(INCDIR) $(XINCDIR) -LDFLAGS = $(OPTIMIZE) $(LIBDIR) $(XLIBDIR) - -OEXT = o - -.SUFFIXES: .cpp .o - -include objs.inc - -# Need -lXt below if USE_XTINIT is defined -XLIBS = -lX11 $(SOCKETLIB) - -.cpp.o: - $(CC) $(CCFLAGS) -c $< - -.c.o: - $(CC) $(CCFLAGS) -c $< - - -all: cfte $(TARGETS) -#rm -f fte ; ln -s $(PRIMARY) fte - -cfte: cfte.o s_files.o - $(LD) $(LDFLAGS) cfte.o s_files.o -o cfte - -c_config.o: defcfg.h - -defcfg.h: defcfg.cnf - perl mkdefcfg.pl defcfg.h - -#DEFAULT_FTE_CONFIG = simple.fte -DEFAULT_FTE_CONFIG = defcfg.fte -#DEFAULT_FTE_CONFIG = defcfg2.fte -#DEFAULT_FTE_CONFIG = ../config/main.fte - -defcfg.cnf: $(DEFAULT_FTE_CONFIG) cfte - ./cfte $(DEFAULT_FTE_CONFIG) defcfg.cnf - -xfte: $(OBJS) $(XOBJS) - $(LD) $(LDFLAGS) $(OBJS) $(XOBJS) $(XLIBS) -o xfte - -compkeys: compkeys.o - $(LD) $(LDFLAGS) compkeys.o -o compkeys - -clean: - rm -f core *.o $(TARGETS) defcfg.h defcfg.cnf cfte fte vfte compkeys diff --git a/src/fte-emx.mak b/src/fte-emx.mak deleted file mode 100644 index cbd39b6..0000000 --- a/src/fte-emx.mak +++ /dev/null @@ -1,80 +0,0 @@ -INCDIR = -LIBDIR = - -#OPTIMIZE = -g -OPTIMIZE = -O -s -#OPTIMIZE = -O2 -s - -MT = -Zmt - -CC = gcc -LD = gcc - -#XTYPE = -Zomf -#XLTYPE = -Zsys -Zlinker /map -Zlinker /runfromvdm # -Zomf -#OEXT=obj -OEXT=o - -#DEFS = -DDEBUG_EDITOR -DCHECKHEAP -#LIBS = -lmalloc1 -#DEFS = -DDEBUG_EDITOR -DDBMALLOC -I/src/dbmalloc -#LIBS = -L/src/dbmalloc -ldbmalloc -LIBS = -lstdcpp - -DEFS=-DINCL_32 #-DUSE_OS2_TOOLKIT_HEADERS - -CCFLAGS = $(OPTIMIZE) $(MT) $(XTYPE) -x c++ -Wall -DOS2 $(DEFS) $(INCDIR) -pipe -LDFLAGS = $(OPTIMIZE) $(MT) -Zmap $(XLTYPE) $(LIBDIR) - -.SUFFIXES: .cpp .$(OEXT) - -include objs.inc - -.cpp.$(OEXT): - $(CC) $(CCFLAGS) -c $< - -.c.$(OEXT): - $(CC) $(CCFLAGS) -c $< - -all: cfte.exe fte.exe ftepm.exe clipserv.exe cliputil.exe - -clipserv.exe: clipserv.$(OEXT) clipserv.def - $(LD) $(LDFLAGS) clipserv.$(OEXT) clipserv.def -o clipserv.exe $(LIBS) - -cliputil.exe: cliputil.$(OEXT) clip_vio.$(OEXT) cliputil.def - $(LD) $(LDFLAGS) cliputil.$(OEXT) clip_vio.$(OEXT) cliputil.def -o cliputil.exe $(LIBS) - -cfte.exe: $(CFTE_OBJS) cfte.def - $(LD) $(LDFLAGS) $(CFTE_OBJS) cfte.def -o cfte.exe $(LIBS) - -defcfg.cnf: defcfg.fte cfte.exe - cfte defcfg.fte defcfg.cnf - -defcfg.h: defcfg.cnf bin2c.exe - bin2c defcfg.cnf >defcfg.h - -bin2c.exe: bin2c.cpp - $(CC) $(CCFLAGS) bin2c.cpp -o bin2c.exe - -c_config.$(OEXT): defcfg.h - -fte.exe: $(OBJS) $(VIOOBJS) fte.def - $(LD) $(LDFLAGS) $(OBJS) $(VIOOBJS) fte.def -o fte.exe $(LIBS) - -ftepm.res: ftepm.rc pmdlg.rc bmps/*.bmp - rc -r -i \emx\include ftepm.rc ftepm.res - -ftepm.exe: $(OBJS) $(PMOBJS) ftepm.def ftepm.res - $(LD) $(LDFLAGS) $(OBJS) $(PMOBJS) ftepm.def ftepm.res -o ftepm.exe $(LIBS) - -fte.cnf: cfte.exe - cfte ..\config\main.fte fte.cnf - -#rc -i \emx\include ftepm.rc ftepm.exe - -#ftepm.exe:: ftepm.res -# rc ftepm.res ftepm.exe - -distro: ftepm.exe fte.exe fte.cnf cfte.exe clipserv.exe cliputil.exe - zip ../fte-os2.zip ftepm.exe fte.exe fte.cnf cfte.exe clipserv.exe cliputil.exe - (cd .. && zip -r fte-config.zip Artistic doc config) diff --git a/src/fte-mngw.mak b/src/fte-mngw.mak deleted file mode 100644 index 926d7d8..0000000 --- a/src/fte-mngw.mak +++ /dev/null @@ -1,62 +0,0 @@ -# -# FTE makefile for use with the MinGW toolchain -# -# Please note that the common GNU Make 3.77 port for MinGW is broken -# and does not process this makefile correctly . Get a working Make 3.79.1 -# from http://www.nextgeneration.dk/gnu/ -# -# The author, Jon Svendsen, explicitly places this module -# in the Public Domain -# - -INCDIR = -LIBDIR = - -OPTIMIZE = -O -s - -MT = -Zmt - -CC = g++ -LD = g++ - -# uncomment this if you don't have fileutils installed -# RM = del - -OEXT=o - -DEFS=-DNT -DNTCONSOLE -DMINGW - -CCFLAGS = $(OPTIMIZE) -x c++ -Wall $(DEFS) $(INCDIR) -pipe -LDFLAGS = $(OPTIMIZE) $(LIBDIR) -Wl,-static - -.SUFFIXES: .cpp .$(OEXT) - -include objs.inc - -.cpp.$(OEXT): - $(CC) $(CCFLAGS) -c $< - -.c.$(OEXT): - $(CC) $(CCFLAGS) -c $< - -all: cfte.exe fte.exe - -cfte.exe: $(CFTE_OBJS) - $(LD) $(LDFLAGS) $(CFTE_OBJS) -o cfte.exe $(LIBS) - -defcfg.cnf: defcfg.fte cfte.exe - -"./cfte.exe" defcfg.fte defcfg.cnf - -defcfg.h: defcfg.cnf bin2c.exe - -"./bin2c.exe" defcfg.cnf >defcfg.h - -bin2c.exe: bin2c.cpp - $(CC) $(CCFLAGS) bin2c.cpp -o bin2c.exe - -c_config.$(OEXT): defcfg.h - -fte.exe: $(OBJS) $(NTOBJS) - -$(LD) $(LDFLAGS) $(OBJS) $(NTOBJS) -o fte.exe $(LIBS) - -clean: - -$(RM) fte.exe cfte.exe bin2c.exe defcfg.cnf defcfg.h $(OBJS) $(NTOBJS) $(CFTE_OBJS) \ No newline at end of file diff --git a/src/fte-msvc.mak b/src/fte-msvc.mak deleted file mode 100644 index a720427..0000000 --- a/src/fte-msvc.mak +++ /dev/null @@ -1,71 +0,0 @@ -INCDIR = -LIBDIR = - -OPTIMIZE = /O2 /MT -#OPTIMIZE = /Zi /Od /MTd - -#DEBUG = -DMSVCDEBUG - -CC = cl -LD = cl - -OEXT=obj - -#APPOPTIONS = -DDEFAULT_INTERNAL_CONFIG -#/Fm /GF /J -CCFLAGS = $(OPTIMIZE) -DNT -DNTCONSOLE -DMSVC $(INCDIR) /DWIN32 /D_CONSOLE /GX \ - $(APPOPTIONS) $(DEBUG)\ - /nologo /W3 /J # /YX -LDFLAGS = $(OPTIMIZE) $(LIBDIR) /nologo - -.SUFFIXES: .cpp .$(OEXT) - -!include objs.inc - -.cpp.$(OEXT): - $(CC) $(CCFLAGS) -c $< - -.c.$(OEXT): - $(CC) $(CCFLAGS) -c $< - -all: cfte.exe fte.cnf fte.exe - -clean: - -del bin2c.exe - -del bin2c.pdb - -del cfte.exe - -del cfte.pdb - -del cfte.exp - -del cfte.lib - -del defcfg.cnf - -del defcfg.h - -del fte.cnf - -del fte.exe - -del fte.his - -del fte.pdb - -del vc60.pdb - -del *.obj - -cfte.exe: $(CFTE_OBJS) cfte.def - $(LD) $(LDFLAGS) /Fecfte.exe $(CFTE_OBJS) cfte.def - -defcfg.cnf: defcfg.fte cfte.exe - cfte defcfg.fte defcfg.cnf - -defcfg.h: defcfg.cnf bin2c.exe - bin2c defcfg.cnf >defcfg.h - -fte.cnf: ..\config\* cfte.exe - cfte ..\config\main.fte fte.cnf - -bin2c.exe: bin2c.cpp - $(CC) $(CCFLAGS) $(LDFLAGS) /Febin2c.exe bin2c.cpp - -c_config.$(OEXT): defcfg.h - -fte.exe: $(OBJS) $(NTOBJS) - $(LD) $(LDFLAGS) /Fefte.exe $(OBJS) $(NTOBJS) user32.lib - -distro: fte.exe fte.cnf cfte.exe - zip ../fte-nt.zip fte.exe fte.cnf cfte.exe - diff --git a/src/fte-unix.mak b/src/fte-unix.mak deleted file mode 100644 index 4535c5f..0000000 --- a/src/fte-unix.mak +++ /dev/null @@ -1,207 +0,0 @@ -# versions of FTE to build - -# Versions: -# xfte - using XLib (the most stable) - -# vfte - for Linux console directly (with limitations, see con_linux.cpp) - -TARGETS = xfte vfte sfte -#TARGETS = xfte - -PRIMARY = xfte - -# Comment or uncoment this two flags below if -# you want to use: - -# Keyboard remaping by XFTE -#REMAPFLAG = -DUSE_HARD_REMAP - -# Drawing fonts with locale support -XMBFLAG = -DUSE_XMB - -# System X11R6 is compiled with X_LOCALE -#SYSTEM_X_LOCALE = -DX_LOCALE - -I18NOPTIONS = $(XMBFLAG) $(REMAPFLAG) $(SYSTEM_X_LOCALE) - -# Optionally, you can define: -# -DDEFAULT_INTERNAL_CONFIG to use internal config by default -# -DUSE_XTINIT to use XtInitialize on init -# -DFTE_NO_LOGGING to completely disable trace logging -APPOPTIONS = -DDEFAULT_INTERNAL_CONFIG - -#gcc/g++ -COPTIONS = -Wall -Wpointer-arith -Wconversion -Wwrite-strings \ - -Wmissing-prototypes -Wmissing-declarations -Winline - -#CC = g++ -#LD = g++ -# try this for smaller/faster code and less dependencies -CC = g++ -fno-rtti -fno-exceptions -LD = gcc -fno-rtti -fno-exceptions - - -# choose your os here - -####################################################################### -# Linux -UOS = -DLINUX -XLIBDIR = -L/usr/X11R6/lib -lstdc++ - -####################################################################### -# HP/UX -#UOS = -DHPUX -D_HPUX_SOURCE -DCAST_FD_SET_INT -#UOS = -DHPUX -D_HPUX_SOURCE - -#CC = CC +a1 -#LD = CC -#CC = aCC -#LD = aCC - -#XLIBDIR = -L/usr/lib/X11R6 - -#XINCDIR = -I/usr/include/X11R5 -#XLIBDIR = -L/usr/lib/X11R5 - -#MINCDIR = -I/usr/include/Motif1.2 -#MLIBDIR = -L/usr/lib/Motif1.2 - -SINCDIR = -I/usr/include/slang - -####################################################################### -# AIX -#UOS = -DAIX -D_BSD_INCLUDES - -#CC = xlC -#LD = xlC -#COPTIONS = -#TARGETS = xfte - -####################################################################### -# Irix -# missing fnmatch, but otherwise ok (tested only on 64bit) -# 6.x has fnmatch now ;-) -# uncomment below to use SGI CC compiler -#UOS = -DIRIX -#CC = CC -#LD = CC -#COPTIONS = -xc++ - -####################################################################### -# SunOS (Solaris) -#UOS = -DSUNOS -#CC = CC -noex -#LD = CC -noex -#COPTIONS = -#XINCDIR = -I/usr/openwin/include -#XLIBDIR = -L/usr/openwin/lib - -####################################################################### -# for SCO CC -# -# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -# If you have problems with the program "cfte" -# try to compile this program without optimalization -O2 -# use just -O -# -#UOS = -DSCO -#CC = CC -b elf -#LD = $(CC) -#XLIBDIR = -L/usr/X11R6/lib -#SOCKETLIB = -lsocket -#COPTIONS = +.cpp - -####################################################################### -# NCR -#CC = cc -Hnocopyr -#LD = cc -Hnocopyr -#COPTIONS = -w3 -#UOS = -DNCR -#XINCDIR = -I../../include -#SOCKETLIB = -lsocket -lnsl -lc -lucb - -####################################################################### - -#QTDIR = /users/markom/qt -#QLIBDIR = -L$(QTDIR)/lib -#QINCDIR = -I$(QTDIR)/include -#QINCDIR = -I/usr/include/qt - -MOC = moc - -LIBDIR = -INCDIR = - -#OPTIMIZE = -g # -O -g -OPTIMIZE = -O2 -#OPTIMIZE = -O2 -s - -CCFLAGS = $(OPTIMIZE) $(I18NOPTIONS) $(APPOPTIONS) $(COPTIONS) -DUNIX $(UOS) $(INCDIR) $(XINCDIR) $(QINCDIR) $(MINCDIR) $(SINCDIR) -LDFLAGS = $(OPTIMIZE) $(LIBDIR) $(XLIBDIR) $(QLIBDIR) $(MLIBDIR) - -OEXT = o - -.SUFFIXES: .cpp .o .moc - -include objs.inc - -# Need -lXt below if USE_XTINIT is defined -XLIBS = -lX11 $(SOCKETLIB) -VLIBS = -lgpm -lncurses -# -ltermcap outdated by ncurses -SLIBS = -lslang -QLIBS = -lqt -#MLIBS = -lXm -lXp -lXt -lXpm -lXext - -.cpp.o: - $(CC) $(CCFLAGS) -c $< - -.c.o: - $(CC) $(CCFLAGS) -c $< - -.cpp.moc: - $(MOC) $< -o $@ - -all: cfte $(TARGETS) -#rm -f fte ; ln -s $(PRIMARY) fte - -cfte: cfte.o s_files.o - $(LD) $(LDFLAGS) cfte.o s_files.o -o cfte - -c_config.o: defcfg.h - -defcfg.h: defcfg.cnf - perl mkdefcfg.pl defcfg.h - -#DEFAULT_FTE_CONFIG = simple.fte -DEFAULT_FTE_CONFIG = defcfg.fte -#DEFAULT_FTE_CONFIG = defcfg2.fte -#DEFAULT_FTE_CONFIG = ../config/main.fte - -defcfg.cnf: $(DEFAULT_FTE_CONFIG) cfte - ./cfte $(DEFAULT_FTE_CONFIG) defcfg.cnf - -xfte: $(OBJS) $(XOBJS) - $(LD) $(LDFLAGS) $(OBJS) $(XOBJS) $(XLIBS) -o xfte - -#qfte: g_qt.moc g_qt_dlg.moc $(OBJS) $(QOBJS) -# $(LD) $(LDFLAGS) $(OBJS) $(QOBJS) $(QLIBS) $(XLIBS) -o qfte - -vfte: $(OBJS) $(VOBJS) - $(LD) $(LDFLAGS) $(OBJS) $(VOBJS) $(VLIBS) -o vfte - -sfte: $(OBJS) $(SOBJS) compkeys - $(LD) $(LDFLAGS) $(OBJS) $(SOBJS) $(SLIBS) -o sfte - -compkeys: compkeys.o - $(LD) $(LDFLAGS) compkeys.o -o compkeys - -#mfte: $(OBJS) $(MOBJS) -# $(LD) $(LDFLAGS) $(OBJS) $(MOBJS) $(MLIBS) $(XLIBS) -o mfte - -g_qt.obj: g_qt.moc - -g_qt_dlg.obj: g_qt_dlg.moc - -clean: - rm -f core *.o $(TARGETS) defcfg.h defcfg.cnf cfte fte vfte compkeys diff --git a/src/fte-vag.mak b/src/fte-vag.mak deleted file mode 100644 index c0d45af..0000000 --- a/src/fte-vag.mak +++ /dev/null @@ -1,176 +0,0 @@ -# -# -# Makefile for VisualAge C++ version 3.00 -# -# - -EXE = - -OEXT = obj - -DEBUG = 0 -#DEBUG = 1 - -CC = icc -LINK = ilink -RC = rc -VOID = echo > NUL - -!if $(DEBUG) -C_FLAGS = /Ti /Tx -!else -C_FLAGS = /O /Gs- -!endif -C_OPTIONS = /Q /Tl /G4 /Gm+ /DOS2 /DINCL_32 $(C_FLAGS) - -!if $(DEBUG) -CPP_FLAGS = /Ti /Tm /Tx -!else -CPP_FLAGS = /O /Gs- -!endif -CPP_OPTIONS = /Q /G4 /Gm+ /DOS2 /DINCL_32 $(CPP_FLAGS) - -!if $(DEBUG) -L_FLAGS = /DEBUG /DBGPACK -!else -L_FLAGS = /EXEPACK:2 /PACKC /PACKD /OPTF -!endif -L_OPTIONS = /BASE:0x010000 /EXEC /NOE /NOLOGO $(L_FLAGS) - -RC_OPT = -n - -C_SRC = -C_H = -CPP_SRC = -CPP_HPP = - -!include objs.inc - -RES = - -LIBS = -HLIB = - -DEF = - - -.SUFFIXES: -.SUFFIXES: .cpp .rc - -all: cfte.exe fte.exe ftepm.exe clipserv.exe cliputil.exe fte.cnf - -clean: - -del bin2c.exe - -del bin2c.map - -del cfte.exe - -del cfte.map - -del clipserv.exe - -del clipserv.map - -del cliputil.exe - -del cliputil.map - -del defcfg.cnf - -del defcfg.h - -del fte.cnf - -del fte.exe - -del fte.his - -del fte.map - -del ftepm.exe - -del ftepm.map - -del ftepm.res - -del *.obj - -clipserv.exe: clipserv.$(OEXT) clipserv.def - $(VOID) <defcfg.h - -fte.cnf: ..\config\* cfte.exe - cfte ..\config\main.fte fte.cnf - -bin2c.obj: bin2c.cpp - -bin2c.exe: bin2c.obj - $(VOID) <defcfg.h - -defcfg.cnf: defcfg.fte cfte - cfte defcfg.fte defcfg.cnf - -xfte: $(OBJS) $(XOBJS) - $(LD) $(LDFLAGS) $(OBJS) $(XOBJS) $(XLIBS) -o xfte - -qfte: g_qt.moc g_qt_dlg.moc $(OBJS) $(QOBJS) - $(LD) $(LDFLAGS) $(OBJS) $(QOBJS) $(QLIBS) $(XLIBS) -o qfte - -vfte: $(OBJS) $(VOBJS) - $(LD) $(LDFLAGS) $(OBJS) $(VOBJS) $(VLIBS) -o vfte - -mfte: $(OBJS) $(MOBJS) - $(LD) $(LDFLAGS) $(OBJS) $(MOBJS) $(MLIBS) $(XLIBS) -o mfte - -g_qt.obj: g_qt.moc - -g_qt_dlg.obj: g_qt_dlg.moc - -clean: - rm -f *.o $(TARGETS) defcfg.h defcfg.cnf cfte fte diff --git a/src/fte-xwin.mak b/src/fte-xwin.mak deleted file mode 100644 index a6ff9b1..0000000 --- a/src/fte-xwin.mak +++ /dev/null @@ -1,246 +0,0 @@ -# fte-unix.make modified to be generic enough to work with WINNT or UNIX - -# versions of FTE to build - -# Versions: -# xfte - using XLib (the most stable) - -# vfte - for Linux console directly (with limitations, see con_linux.cpp) - -#WINNT -ESUF=.exe -OEXT=obj -OUTFLAG = -out: -OUTEXEFLAG = /Fe - -#UNIX -#ESUF= -#OEXT=o -#OUTFLAG = -o -#OUTEXEFLAG = -o -# -o must have a space after it above - -.SUFFIXES: .cpp .$(OEXT) - -TARGETS = xfte$(ESUF) -#TARGETS = vfte$(ESUF) xfte$(ESUF) - -PRIMARY = xfte$(ESUF) - -# Comment or uncoment this two flags below if -# you want to use: - -# Keyboard remaping by XFTE -#REMAPFLAG = -DUSE_HARD_REMAP - -# Drawing fonts with locale support -#XMBFLAG = -DUSE_XMB - -# System X11R6 is compiled with X_LOCALE -#SYSTEM_X_LOCALE = -DX_LOCALE - -I18NOPTIONS = $(XMBFLAG) $(REMAPFLAG) $(SYSTEM_X_LOCALE) - -# Optionally, you can define: -# -DDEFAULT_INTERNAL_CONFIG to use internal config by default -# -DUSE_XTINIT to use XtInitialize on init -APPOPTIONS = -DDEFAULT_INTERNAL_CONFIG -DUSE_XTINIT - -#gcc/g++ -#COPTIONS = -Wall -Wpointer-arith -Wconversion -Wwrite-strings \ -# -Wmissing-prototypes -Wmissing-declarations -Winline - -#CC = g++ -#LD = g++ -# try this for smaller/faster code and less dependencies -#CC = g++ -fno-rtti -fno-exceptions -#LD = gcc -fno-rtti -fno-exceptions - -# choose your os here - -####################################################################### -#MSVC/EXCEED XDK -X_BASE = C:\win32app\Exceed\xdk - -X_LIBS = -LIBPATH:$(X_BASE)\lib \ - HCLXm.lib HCLMrm.lib HCLXmu.lib HCLXt.lib Xlib.lib hclshm.lib xlibcon.lib \ - -# Xm.lib Mrm.lib Xmu.lib Xt.lib Xlib.lib hclshm.lib xlibcon.lib - -XINCDIR = -I:$(X_BASE)\include - -#optimize -#OPTIMIZE = /Ox -DNDEBUG - -#debug -#OPTIMIZE = /Od /Zi -D_DEBUG -#LDOPTIMIZE = /DEBUG - -CC = cl -LD = link - -CCFLAGS = $(OPTIMIZE) -DNT -DMSVC $(INCDIR) -DWIN32 -D_CONSOLE -DWINHCLX \ - -nologo -W3 -J -DNONXP -DWINNT -D_X86_ -MD -Op -W3 -QIfdiv -GX \ - $(XINCDIR) -LDFLAGS = $(LDOPTIMIZE) $(LIBDIR) -nologo Advapi32.lib User32.lib Wsock32.lib \ - -map /NODEFAULTLIB:libc.lib $(X_LIBS) - - -####################################################################### -# Linux -#UOS = -DLINUX -#XLIBDIR = -L/usr/X11/lib - -####################################################################### -# HP/UX -#UOS = -DHPUX -D_HPUX_SOURCE -DCAST_FD_SET_INT -#UOS = -DHPUX -D_HPUX_SOURCE - -#CC = CC +a1 -#LD = CC -#CC = aCC -#LD = aCC - -#XLIBDIR = -L/usr/lib/X11R6 - -#XINCDIR = -I/usr/include/X11R5 -#XLIBDIR = -L/usr/lib/X11R5 - -#MINCDIR = -I/usr/include/Motif1.2 -#MLIBDIR = -L/usr/lib/Motif1.2 - -SINCDIR = -I/usr/include/slang - -####################################################################### -# AIX -#UOS = -DAIX -D_BSD_INCLUDES # not recently tested (it did work) - -#CC = xlC -#LD = xlC - -####################################################################### -# Irix -# missing fnmatch, but otherwise ok (tested only on 64bit) -# 6.x has fnmatch now ;-) -# uncomment below to use SGI CC compiler -#UOS = -DIRIX -#CC = CC -#LD = CC -#COPTIONS = -xc++ - -####################################################################### -# SunOS (Solaris) -#UOS = -DSUNOS -#CC = CC -#LD = CC -#XINCDIR = -I/usr/openwin/include -#XLIBDIR = -L/usr/openwin/lib - -####################################################################### -# for SCO CC -# -# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -# If you have problems with the program "cfte" -# try to compile this program without optimalization -O2 -# use just -O -# -#UOS = -DSCO -#CC = CC -b elf -#LD = $(CC) -#XLIBDIR = -L/usr/X11R6/lib -#SOCKETLIB = -lsocket -#COPTIONS = +.cpp - -####################################################################### -# NCR -#CC = cc -Hnocopyr -#LD = cc -Hnocopyr -#COPTIONS = -w3 -#UOS = -DNCR -#XINCDIR = -I../../include -#SOCKETLIB = -lsocket -lnsl -lc -lucb - -####################################################################### - -#QTDIR = /users/markom/qt -#QLIBDIR = -L$(QTDIR)/lib -#QINCDIR = -I$(QTDIR)/include -#QINCDIR = -I/usr/include/qt - -MOC = moc - -#LIBDIR = -#INCDIR = - -#OPTIMIZE = -O -g -#OPTIMIZE = -O2 -#OPTIMIZE = -O2 -s - -#UNIX -#CCFLAGS = $(OPTIMIZE) $(I18NOPTIONS) $(COPTIONS) -DUNIX $(UOS) $(INCDIR) $(XINCDIR) $(QINCDIR) $(MINCDIR) $(SINCDIR) -#LDFLAGS = $(OPTIMIZE) $(LIBDIR) $(XLIBDIR) $(QLIBDIR) $(MLIBDIR) - -include objs.inc - -#UNIX -# need -lXt below if USE_XTINIT -#XLIBS = -lX11 -Xt $(SOCKETLIB) -#VLIBS = -lgpm -lncurses -# -ltermcap outdated by ncurses -#SLIBS = -lslang -#QLIBS = -lqt -#MLIBS = -lXm -lXp -lXt -lXpm -lXext - -.cpp.$(OEXT): - $(CC) $(CCFLAGS) $(APPOPTIONS) -c $< - -.c.$(OEXT): - $(CC) $(CCFLAGS) $(APPOPTIONS) -c $< - -.cpp.moc: - $(MOC) $< -o $@ - -all: cfte$(ESUF) $(TARGETS) -# rm -f fteln -s $(PRIMARY) fte - -cfte$(ESUF): cfte.$(OEXT) s_files.$(OEXT) - $(LD) $(LDFLAGS) cfte.$(OEXT) s_files.$(OEXT) $(OUTFLAG)cfte$(ESUF) - -c_config.$(OEXT): defcfg.h - - -#defcfg.h: defcfg.cnf -# perl mkdefcfg.pl defcfg.h - -defcfg.h: defcfg.cnf bin2c$(ESUF) - bin2c$(ESUF) defcfg.cnf >defcfg.h - -bin2c$(ESUF): bin2c.cpp - $(CC) $(CCFLAGS) $(OUTEXEFLAG)bin2c$(ESUF) bin2c.cpp - -DEFAULT_FTE_CONFIG = simple.fte -#DEFAULT_FTE_CONFIG = defcfg.fte -#DEFAULT_FTE_CONFIG = defcfg2.fte -#DEFAULT_FTE_CONFIG = ../config/main.fte - -defcfg.cnf: $(DEFAULT_FTE_CONFIG) cfte$(ESUF) - cfte$(ESUF) $(DEFAULT_FTE_CONFIG) defcfg.cnf - -xfte$(ESUF): $(OBJS) $(XOBJS) - $(LD) $(LDFLAGS) $(OBJS) $(XOBJS) $(XLIBS) $(OUTFLAG)xfte$(ESUF) - -qfte$(ESUF): g_qt.moc g_qt_dlg.moc $(OBJS) $(QOBJS) - $(LD) $(LDFLAGS) $(OBJS) $(QOBJS) $(QLIBS) $(XLIBS) $(OUTFLAG)qfte$(ESUF) - -vfte$(ESUF): $(OBJS) $(VOBJS) - $(LD) $(LDFLAGS) $(OBJS) $(VOBJS) $(VLIBS) $(OUTFLAG)vfte$(ESUF) - -mfte$(ESUF): $(OBJS) $(MOBJS) - $(LD) $(LDFLAGS) $(OBJS) $(MOBJS) $(MLIBS) $(XLIBS) $(OUTFLAG)mfte$(ESUF) - -g_qt.$(OEXT): g_qt.moc - -g_qt_dlg.$(OEXT): g_qt_dlg.moc - -clean: - rm -f *.$(OEXT) $(TARGETS) defcfg.h defcfg.cnf cfte$(ESUF) fte$(ESUF) diff --git a/src/fte.def b/src/fte.def deleted file mode 100644 index 834220e..0000000 --- a/src/fte.def +++ /dev/null @@ -1,3 +0,0 @@ -NAME fte WINDOWCOMPAT -DESCRIPTION 'FTE Text Editor' -STACKSIZE 49152 diff --git a/src/fte2.cpp b/src/fte2.cpp deleted file mode 100644 index ad113ba..0000000 --- a/src/fte2.cpp +++ /dev/null @@ -1,525 +0,0 @@ -/* fte.cpp - * - * Copyright (c) 1994-1996, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -#include "fte.h" - -#if defined(UNIX) -/* Some paths where to also look for the rc-file */ -/* How many */ -#define UNIX_RCPATHS 3 - -/* Actual locations */ -char *Unix_RCPaths[UNIX_RCPATHS]={ - "/usr/local/etc/fte/system.fterc", - "/etc/fte/system.fterc", - "/usr/X11R6/lib/X11/xfte/system.fterc", -}; - -#endif /* UNIX */ - -static void Usage() { - printf("Usage: " PROGRAM " [-!] [-?] [--help] [-h] [-crdnm] files...\n" - "Version: " VERSION " " COPYRIGHT "\n" - " You may distribute under the terms of either the GNU General Public\n" - " License or the Artistic License, as specified in the README file.\n" - "\n" - "Options:\n" - " -- End of options, only files remain.\n" - " -+ Next option is file.\n" - " -? Display usage.\n" - " -h Display usage.\n" - " --help Display usage.\n" - " -! Ignore config file, use builtin defaults (also -c).\n" - " -c[<.cnf>] Use specified configuration file (no arg=builtin).\n" -#ifdef CONFIG_DESKTOP - " -d[<.dsk>] Load/Save desktop from <.dsk> (no arg=disable desktop).\n" -#endif -/* -#ifdef CONFIG_HISTORY - " -h[<.his>] Load/Save history from <.his> (no arg=disable history).\n" -#endif -*/ - " -m[] Override mode for remaining files (no arg=no override).\n" - " -l[,] Go to line (and column) in next file.\n" - " -r Open next file as read-only.\n" -#ifdef CONFIG_TAGS - " -T[] Load tags file at startup.\n" - " -t Locate specified tag.\n" -#endif -// " -p Load files into already running FTE.\n" - ); -} - -/* - * findPathExt() returns a ^ to the suffix in a file name string. If the - * name contains a suffix, the pointer ^ts to the suffix' dot character, - * if the name has no suffix the pointer points to the NUL terminator of - * the file name string. - * .lib: CBASE.LIB - */ -static char *findPathExt(char *filename) { - char *p, *sps; - - for (p = filename, sps = NULL; *p; p++) { - if (ISSLASH(*p)) - sps = NULL; - if (*p == '.') - sps = p; - } - if (sps == NULL) - sps = p; - return sps; -} - -#if defined(OS2) && defined(__EMX__) - -// argv[0] on emx does not contain full path - -#define INCL_DOS -#include - -char *getProgramName(char *name) { - char ProgramName[MAXPATH]; - PTIB tib; - PPIB pib; - - DosGetInfoBlocks(&tib, &pib); - if (DosQueryModuleName(pib->pib_hmte, sizeof(ProgramName), ProgramName) != 0) - return name; - return strdup(ProgramName); -} - -#endif - -static int GetConfigFileName(int argc, char **argv, char *ConfigFileName) { - int i; - char CfgName[MAXPATH] = ""; - - if (ConfigFileName[0] == 0) { -#if defined(UNIX) - // ? use ./.fterc if by current user ? - ExpandPath("~/.fterc", CfgName); -#elif defined(DOS) || defined(DOSP32) - strcpy(CfgName, argv[0]); - strcpy(findPathExt(CfgName), ".cnf"); -#elif defined(OS2) || defined(NT) - char home[MAXPATH] = ""; - char *ph; -#if defined(OS2) - ph = getenv("HOME"); - if (ph) strcpy(home, ph); -#endif -#if defined(NT) - ph = getenv("HOMEDRIVE"); - if (ph) strcpy(home, ph); - ph = getenv("HOMEPATH"); - if (ph) strcat(home, ph); -#endif - if (home[0]) { - strcpy(CfgName, home); - Slash(CfgName, 1); - strcat(CfgName, "fte.cnf"); - } - - if (!home[0] || access(CfgName, 0) != 0) { - strcpy(CfgName, argv[0]); - strcpy(findPathExt(CfgName), ".cnf"); - } -#endif - - strcpy(ConfigFileName, CfgName); - } -// printf("Trying '%s'...",ConfigFileName); - if (access(ConfigFileName, 0) == 0) - { -// printf("success, loading!\n"); - return 1; - } -// printf("failed!\n"); - -#if defined(UNIX_RCPATHS) - for (i=0;iSwitchToModel(MM); - } else { - if (ModeOverride) { - if (MultiFileLoad(argv[Arg], Mode, 0) == 0) return 0; - } else { - if (MultiFileLoad(argv[Arg], 0, 0) == 0) return 0; - } - if (((EBuffer *)MM)->Loaded == 0) - ((EBuffer *)MM)->Load(); - if (GotoLine) { - GotoLine = 0; - ((EBuffer *)MM)->SetNearPosR(ColNum - 1, LineNum - 1); - } else { - int r, c; - - if (RetrieveFPos(((EBuffer *)MM)->FileName, r, c) == 1) - ((EBuffer *)MM)->SetNearPosR(c, r); - } - - if (ReadOnly) { - ReadOnly = 0; - BFI(((EBuffer *)MM), BFI_ReadOnly) = 1; - } - } - QuoteNext = 0; - MM = MM->Next; - LCount++; - } - } - while (LCount-- > 0) - MM = MM->Prev; - return 1; -} - -#ifdef CONFIG_HISTORY -static void DoLoadHistoryOnEntry(int &argc, char **argv) { - if (HistoryFileName[0] == 0) { -#ifdef UNIX - ExpandPath("~/.fte-history", HistoryFileName); -#else - JustDirectory(argv[0], HistoryFileName); - strcat(HistoryFileName, "fte.his"); -#endif - } else { - char p[256]; - - ExpandPath(HistoryFileName, p); - if (IsDirectory(p)) { - Slash(p, 1); -#ifdef UNIX - strcat(p, ".fte-history"); -#else - strcat(p, "fte.his"); -#endif - } - strcpy(HistoryFileName, p); - } - - if (KeepHistory && FileExists(HistoryFileName)) - LoadHistory(HistoryFileName); -} - -static void DoSaveHistoryOnExit() { - if (KeepHistory && HistoryFileName[0] != 0) - SaveHistory(HistoryFileName); -} -#endif - -#ifdef CONFIG_DESKTOP -void DoLoadDesktopOnEntry(int &argc, char **argv) { - if (DesktopFileName[0] == 0) { -#ifdef UNIX - if (FileExists(".fte-desktop")) { - ExpandPath(".fte-desktop", DesktopFileName); - } else { - ExpandPath("~/.fte-desktop", DesktopFileName); - } -#else - if (FileExists("fte.dsk")) { - ExpandPath("fte.dsk", DesktopFileName); - } else { - JustDirectory(argv[0], DesktopFileName); - strcat(DesktopFileName, "fte.dsk"); - } -#endif - } else { - char p[MAXPATH]; - - ExpandPath(DesktopFileName, p); - if (IsDirectory(p)) { - Slash(p, 1); -#ifdef UNIX - strcat(p, ".fte-desktop"); -#else - strcat(p, "fte.dsk"); -#endif - } - strcpy(DesktopFileName, p); - } - - if (LoadDesktopOnEntry && FileExists(DesktopFileName)) - LoadDesktop(DesktopFileName); -} -#endif - -static void EditorInit() { - SS = new EBuffer((EModel **)&SS, "Scrap"); - BFI(SS, BFI_Undo) = 0; // disable undo for clipboard - MM = 0; -} - -static void EditorCleanup() { - EModel *B, *N, *A; - EView *BW, *NW, *AW; - - if (MM) { - B = A = MM; - while (B != A) { - N = B->Next; - delete B; - B = N; - } - } - MM = 0; - - delete SS; - SS = 0; - - if (VV) { - BW = AW = VV; - while (BW != AW) { - NW = BW->Next; - delete BW; - BW = NW; - } - } - VV = 0; -} - -static int InterfaceInit(int &argc, char **argv) { - GxView *view; - ExModelView *edit; - - new EGUI(argc, argv, ScreenSizeX, ScreenSizeY); - if (gui == 0) - DieError(1, "Failed to initialize display\n"); - - new EFrame(ScreenSizeX, ScreenSizeY); - if (frames == 0) - DieError(1, "Failed to create window\n"); - - //frames->SetMenu("Main"); //?? - - view = new GxView(frames); - if (view == 0) - DieError(1, "Failed to create view\n"); - - VV = new EView(MM); - assert(VV != 0); - - edit = new ExModelView(VV); - if (edit == 0) return 1; - view->PushView(edit); - return 0; -} - -static void InterfaceCleanup() { - while (frames) - delete frames; - - delete gui; -} - -int main(int argc, char **argv) { -#if defined(__EMX__) - argv[0] = getProgramName(argv[0]); -#endif - - if (CmdLoadConfiguration(argc, argv) == 0) - return 1; - -#ifdef CONFIG_HISTORY - DoLoadHistoryOnEntry(argc, argv); -#endif - - EditorInit(); - -#ifdef CONFIG_DESKTOP - DoLoadDesktopOnEntry(argc, argv); -#endif - - if (CmdLoadFiles(argc, argv) == 0) - return 3; - - if (MM == 0) { -#ifdef CONFIG_OBJ_DIRECTORY - char Path[MAXPATH]; - - GetDefaultDirectory(0, Path, sizeof(Path)); - MM = new EDirectory(&MM, Path); - assert(MM != 0); - //VV->SwitchToModel(MM); -#else - Usage(); - return 1; -#endif - } - if (InterfaceInit(argc, argv) != 0) - return 2; - - gui->Run(); // here starts the PM second thread, so the above blocks the SIQ ;-( - -#ifdef CONFIG_HISTORY - DoSaveHistoryOnExit(); -#endif - - EditorCleanup(); - - InterfaceCleanup(); - -#if defined(OS2) - if (_heapchk() != _HEAPOK) - DieError(0, "Heap memory is corrupt."); -#endif - return 0; -} diff --git a/src/ftepm.def b/src/ftepm.def deleted file mode 100644 index 37c88c1..0000000 --- a/src/ftepm.def +++ /dev/null @@ -1,3 +0,0 @@ -NAME ftepm WINDOWAPI -DESCRIPTION 'FTE Text Editor - Presentation Manager GUI' -STACKSIZE 49152 diff --git a/src/ftepm.rc b/src/ftepm.rc deleted file mode 100644 index 3d537aa..0000000 --- a/src/ftepm.rc +++ /dev/null @@ -1,30 +0,0 @@ -#include - -ICON 1 icons\ftepm.ico - -BITMAP 101 bmps\exit.bmp -BITMAP 102 bmps\open.bmp -BITMAP 103 bmps\save.bmp -BITMAP 104 bmps\close.bmp -BITMAP 105 bmps\prev.bmp -BITMAP 106 bmps\last.bmp -BITMAP 107 bmps\next.bmp -BITMAP 108 bmps\undo.bmp -BITMAP 109 bmps\redo.bmp -BITMAP 110 bmps\cut.bmp -BITMAP 111 bmps\copy.bmp -BITMAP 112 bmps\paste.bmp -BITMAP 113 bmps\pastecol.bmp -BITMAP 114 bmps\errprev.bmp -BITMAP 115 bmps\errnext.bmp -BITMAP 116 bmps\tagfind.bmp -BITMAP 117 bmps\tagnext.bmp -BITMAP 118 bmps\tagprev.bmp -BITMAP 119 bmps\tagpop.bmp - -MENU 1 -BEGIN - MENUITEM "Quit", 100 -END - -rcinclude pmdlg.rc diff --git a/src/g_motif.cpp b/src/g_motif.cpp deleted file mode 100644 index 0b1a9ab..0000000 --- a/src/g_motif.cpp +++ /dev/null @@ -1,2003 +0,0 @@ -/* g_motif.cpp - * - * Copyright (c) 1994-1996, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HPUX -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "console.h" -#include "gui.h" - -#define DEBUG(x) -//printf x - -#define MAX_PIPES 4 -//#define PIPE_BUFLEN 4096 - -typedef struct { - int used; - int id; - int fd; - int pid; - int stopped; - EModel *notify; - XtInputId input; -} GPipe; - -static GPipe Pipes[MAX_PIPES] = { - { 0 }, { 0 }, { 0 }, { 0 } -}; - -#define sfFocus 1 - -static long MouseAutoDelay = 40; -static long MouseAutoRepeat = 200; -static long MouseMultiClick = 300; - -static Atom WM_DELETE_WINDOW; - -class GViewPeer { -public: - Widget ScrollWin; - Widget TextWin; - Widget SbHorz, SbVert; - GC gc[256]; - XGCValues gcv; - // TAttr GCattr; - int Visibility; - - GView *View; -// int wX, wY; - int wW, wH, wState, wRefresh; - int cX, cY, cVisible, cStart, cEnd; - int sbVstart, sbVamount, sbVtotal; - int sbHstart, sbHamount, sbHtotal; - int VertPos, HorzPos; - unsigned char *ScreenBuffer; - - GViewPeer(GView *view, int XSize, int YSize); - ~GViewPeer(); - - int AllocBuffer(); - void DrawCursor(int Show); - void UpdateWindow(int xx, int yy, int ww, int hh); - - int ConPutBox(int X, int Y, int W, int H, PCell Cell); - int ConGetBox(int X, int Y, int W, int H, PCell Cell); - int ConPutLine(int X, int Y, int W, int H, PCell Cell); - int ConSetBox(int X, int Y, int W, int H, TCell Cell); - int ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count); - - int ConSetSize(int X, int Y); - int ConQuerySize(int *X, int *Y); - - int ConSetCursorPos(int X, int Y); - int ConQueryCursorPos(int *X, int *Y); - int ConShowCursor(); - int ConHideCursor(); - int ConCursorVisible(); - int ConSetCursorSize(int Start, int End); - - int QuerySbVPos(); - int SetSbVPos(int Start, int Amount, int Total); - int SetSbHPos(int Start, int Amount, int Total); - int ExpandHeight(int DeltaY); - - int UpdateCursor(); - int PMShowCursor(); - int PMHideCursor(); - int PMSetCursorPos(); -}; - -class GFramePeer { -public: - GFrame *Frame; - Widget ShellWin, MainWin, PanedWin, MenuBar; - - GFramePeer(GFrame *frame, int Width, int Height); - ~GFramePeer(); - - int ConSetTitle(char *Title, char *STitle); - int ConGetTitle(char *Title, int MaxLen, char *STitle, int SMaxLen); - - int ConSetSize(int X, int Y); - int ConQuerySize(int *X, int *Y); - void MapFrame(); -}; - -int ShowVScroll = 1; -int ShowHScroll = 0; -int ShowMenuBar = 1; -int ShowToolBar = 0; - -GFrame *frames = 0; -GUI *gui = 0; - -unsigned long HaveGUIDialogs = 0; - -static GView *MouseCapture = 0; -static GView *FocusCapture = 0; - -static int cxChar = 8; -static int cyChar = 13; - -static XtAppContext AppContext; -static Widget TopLevel; -static Display *display; -static Window root; -static int screen; -static Colormap colormap; -static XColor Colors[16]; -static XFontStruct *fontStruct; - -TEvent EventBuf = { evNone }; - -TEvent NextEvent = { evNone }; - -XButtonEvent LastRelease; -Widget LPopupMenu = 0; - -static int LastMouseX = -1, LastMouseY = -1; - -static void SetColor(int i) { - int j, k, z; - j = i & 7; - k = 65535 - 20480; - z = (i > 7) ? (20480) : 0; - Colors[i].blue = k * (j & 1) + z; - Colors[i].green = k * ((j & 2)?1:0) + z; - Colors[i].red = k * ((j & 4)?1:0) + z; - Colors[i].flags = DoRed | DoGreen | DoBlue; -} - -static int InitXColors() { - int i, j; - long d = 0, d1; - XColor clr; - long pix; - int num; - long d_red, d_green, d_blue; - unsigned long u_red, u_green, u_blue; - - for (i = 0; i < 16; i++) { - SetColor(i); - if (XAllocColor(display, colormap, &Colors[i]) == 0) { - SetColor(i); - pix = -1; - num = DisplayCells(display, DefaultScreen(display)); - for (j = 0; j < num; j++) { - clr.pixel = j; - XQueryColor(display, colormap, &clr); - - d_red = clr.red - Colors[i].red; - d_green = clr.green - Colors[i].green; - d_blue = clr.blue - Colors[i].blue; - - //fprintf(stderr, "%d:%d dr:%d, dg:%d, db:%d\n", i, j, d_red, d_green, d_blue); - - u_red = d_red / 10 * d_red; - u_green = d_green / 10 * d_green; - u_blue = d_blue / 10 * d_blue; - - //fprintf(stderr, "%d:%d dr:%u, dg:%u, db:%u\n", i, j, u_red, u_green, u_blue); - - d1 = u_red + u_blue + u_green; - - if (d1 < 0) - d1 = -d1; - if (pix == -1 || d1 < d) { - pix = j; - d = d1; - } - } - if (pix == -1) { - fprintf(stderr, "Color search failed for #%04X%04X%04X\n", - Colors[i].red, - Colors[i].green, - Colors[i].blue); - } - clr.pixel = pix; - XQueryColor(display, colormap, &clr); - Colors[i] = clr; - if (XAllocColor(display, colormap, &Colors[i]) == 0) { - fprintf(stderr, "Color alloc failed for #%04X%04X%04X\n", - Colors[i].red, - Colors[i].green, - Colors[i].blue); - } - } - } - return 0; -} - - -static struct { - long keysym; - long keycode; -} key_table[] = { - { XK_Escape, kbEsc }, - { XK_Tab, kbTab }, - { XK_Return, kbEnter }, - { XK_Pause, kbPause }, - { XK_BackSpace, kbBackSp }, - { XK_Home, kbHome }, - { XK_Up, kbUp }, - { XK_Prior, kbPgUp }, - { XK_Left, kbLeft }, - { XK_Right, kbRight }, - { XK_End, kbEnd }, - { XK_Down, kbDown }, - { XK_Next, kbPgDn }, - { XK_Select, kbEnd }, - { XK_KP_Enter, kbEnter | kfGray }, - { XK_Insert, kbIns | kfGray }, - { XK_Delete, kbDel | kfGray }, - { XK_KP_Add, '+' | kfGray }, - { XK_KP_Subtract, '-' | kfGray }, - { XK_KP_Multiply, '*' | kfGray }, - { XK_KP_Divide, '/' | kfGray }, - { XK_Num_Lock, kbNumLock }, - { XK_Caps_Lock, kbCapsLock }, - { XK_Print, kbPrtScr }, - { XK_Shift_L, kbShift }, - { XK_Shift_R, kbShift | kfGray }, - { XK_Control_L, kbCtrl }, - { XK_Control_R, kbCtrl | kfGray }, - { XK_Alt_L, kbAlt }, - { XK_Alt_R, kbAlt | kfGray }, - { XK_Meta_L, kbAlt }, - { XK_Meta_R, kbAlt | kfGray }, - { XK_F1, kbF1 }, - { XK_F2, kbF2 }, - { XK_F3, kbF3 }, - { XK_F4, kbF4 }, - { XK_F5, kbF5 }, - { XK_F6, kbF6 }, - { XK_F7, kbF7 }, - { XK_F8, kbF8 }, - { XK_F9, kbF9 }, - { XK_F10, kbF10 }, - { XK_F11, kbF11 }, - { XK_F12, kbF12 }, - { XK_KP_0, '0' | kfGray }, - { XK_KP_1, '1' | kfGray }, - { XK_KP_2, '2' | kfGray }, - { XK_KP_3, '3' | kfGray }, - { XK_KP_4, '4' | kfGray }, - { XK_KP_5, '5' | kfGray }, - { XK_KP_6, '6' | kfGray }, - { XK_KP_7, '7' | kfGray }, - { XK_KP_8, '8' | kfGray }, - { XK_KP_9, '9' | kfGray }, - { XK_KP_Decimal, '.' | kfGray }, - { 0x1000FF6F, kbDel | kfShift | kfGray }, - { 0x1000FF70, kbIns | kfCtrl | kfGray }, - { 0x1000FF71, kbIns | kfShift | kfGray }, - { 0x1000FF72, kbIns | kfGray }, - { 0x1000FF73, kbDel | kfGray }, - { 0x1000FF74, kbTab | kfShift }, - { 0x1000FF75, kbTab | kfShift }, - { 0, 0 } -}; - -void ConvertKeyToEvent(KeySym key, KeySym key1, char *keyname, int etype, int state, TEvent *Event) { - unsigned int myState = 0; - int i,k; - - - DEBUG(("key: \n")); - Event->What = evNone; - - switch (etype) { - case KeyPress: Event->What = evKeyDown; break; - case KeyRelease: Event->What = evKeyUp; break; - } - - if (state & ShiftMask) myState |= kfShift; - if (state & ControlMask) myState |= kfCtrl; - if (state & Mod1Mask) myState |= kfAlt; - if (state & Mod2Mask) myState |= kfAlt; - if (state & Mod3Mask) myState |= kfAlt; - if (state & Mod4Mask) myState |= kfAlt; - - DEBUG(("key: %d ; %d ; %d\n", key, key1, state)); - if (key < 256) { - if (myState == kfShift) myState = 0; - if (myState & kfCtrl) { - if (((key >= 'A') && (key < 'A' + 32)) || - ((key >= 'a') && (key < 'a' + 32))) - key &= 0x1F; - } - if (myState & kfAlt) { - if (((key >= 'A') && (key <= 'Z')) || - ((key >= 'a') && (key <= 'z'))) - key &= ~0x20; - } - Event->Key.Code = key | myState; - return; - } else { - for (i = 0; i < (sizeof(key_table) / sizeof(key_table[0])); i++) { - if (key1 == key_table[i].keysym) { - k = key_table[i].keycode; - if (k < 256) - if (myState == kfShift) myState = 0; - Event->Key.Code = k | myState; - return; - } - } - } - DEBUG(("Unknown key: %ld %s %d %d\n", key, keyname, etype, state)); - Event->What = evNone; -} - - -static TEvent LastMouseEvent = { evNone }; - -#define TM_DIFF(x,y) ((long)(((long)(x) < (long)(y)) ? ((long)(y) - (long)(x)) : ((long)(x) - (long)(y)))) - -void ConvertClickToEvent(int type, int xx, int yy, int button, int state, TEvent *Event, Time time) { - unsigned int myState = 0; - static unsigned long LastClickTime = 0; - static unsigned long LastClickCount = 0; - static unsigned long LastClick = 0; - unsigned long CurTime = time; - - if (type == MotionNotify) Event->What = evMouseMove; - else if (type == ButtonPress) Event->What = evMouseDown; - else Event->What = evMouseUp; - Event->Mouse.X = xx / cxChar; - Event->Mouse.Y = yy / cyChar; - if (Event->What == evMouseMove) - if (LastMouseX == Event->Mouse.X && - LastMouseY == Event->Mouse.Y) - { - Event->What = evNone; - return; - } - LastMouseX = Event->Mouse.X; - LastMouseY = Event->Mouse.Y; - Event->Mouse.Buttons = 0; - if (type == MotionNotify) { - if (state & Button1Mask) Event->Mouse.Buttons |= 1; - if (state & Button2Mask) Event->Mouse.Buttons |= 4; - if (state & Button3Mask) Event->Mouse.Buttons |= 2; - } else { - switch (button) { - case Button1: Event->Mouse.Buttons |= 1; break; - case Button2: Event->Mouse.Buttons |= 4; break; - case Button3: Event->Mouse.Buttons |= 2; break; - } - } - Event->Mouse.Count = 1; - if (state & ShiftMask) myState |= kfShift; - if (state & ControlMask) myState |= kfCtrl; - if (state & Mod1Mask) myState |= kfAlt; - if (state & Mod2Mask) myState |= kfAlt; - if (state & Mod3Mask) myState |= kfAlt; - if (state & Mod4Mask) myState |= kfAlt; - Event->Mouse.KeyMask = myState; - - if (Event->What == evMouseDown) { - if (LastClickCount) { - if (LastClick == Event->Mouse.Buttons) { - if (TM_DIFF(CurTime, LastClickTime) <= MouseMultiClick) { - Event->Mouse.Count = ++LastClickCount; - } else { - LastClickCount = 0; - } - } else { - LastClick = 0; - LastClickCount = 0; - LastClickTime = 0; - } - } - - LastClick = Event->Mouse.Buttons; - if (LastClickCount == 0) - LastClickCount = 1; - LastClickTime = CurTime; - } - /* if (Event->What == evMouseMove) { - LastClick = 0; - LastClickCount = 0; - LastClickTime = 0; - } - */ - DEBUG(("Mouse: %d %d %d\n", Event->What, Event->Mouse.X, Event->Mouse.Y)); - LastMouseEvent = *Event; -} - -void ProcessXEvents(XEvent *event, TEvent *Event, GViewPeer *Peer) { - XAnyEvent *anyEvent = (XAnyEvent *) event; - XExposeEvent *exposeEvent = (XExposeEvent *) event; - XButtonEvent *buttonEvent = (XButtonEvent *) event; - XKeyEvent *keyEvent = (XKeyEvent *) event; - XKeyEvent keyEvent1; - XConfigureEvent *configureEvent = (XConfigureEvent *) event; - XGraphicsExposeEvent *gexposeEvent = (XGraphicsExposeEvent *) event; - XMotionEvent *motionEvent = (XMotionEvent *) event; - KeySym key, key1; - int state; - char keyName[32]; - char keyName1[32]; - static int hasConfig = 0; - - Event->What = evNone; - Event->Msg.View = Peer->View; - - switch (event->type) { - case ButtonRelease: - case ButtonPress: - LastRelease = *buttonEvent; - ConvertClickToEvent(event->type, buttonEvent->x, buttonEvent->y, buttonEvent->button, buttonEvent->state, Event, motionEvent->time); - break; - case KeyPress: - case KeyRelease: - state = keyEvent->state; - - keyEvent1 = *keyEvent; - keyEvent1.state &= ~(ShiftMask | ControlMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask); - - XLookupString(keyEvent, keyName, sizeof(keyName), &key, 0); - XLookupString(&keyEvent1, keyName1, sizeof(keyName1), &key1, 0); - //key1 = XLookupKeysym(keyEvent, 0); - ConvertKeyToEvent(key, key1, keyName, event->type, state, Event); - break; - case MotionNotify: - ConvertClickToEvent(event->type, motionEvent->x, motionEvent->y, 0, motionEvent->state, Event, motionEvent->time); - break; - } -} - -static void CloseWindow(Widget w, GFramePeer *frame, XEvent *event, Boolean *cont) { - if (event->type != ClientMessage || - ((XClientMessageEvent *)event)->data.l[0] != WM_DELETE_WINDOW) - { - return ; - } - NextEvent.What = evCommand; - NextEvent.Msg.Command = cmClose; - *cont = False; -} - -void MainCallback (Widget w, mItem *item, XtPointer callData) { - DEBUG(("Main: %d\n", item->Cmd)); - NextEvent.What = evCommand; - NextEvent.Msg.Command = item->Cmd; -} - -void PopupCallback (Widget w, mItem *item, XtPointer callData) { - DEBUG(("Popup: %d\n", item->Cmd)); - NextEvent.What = evCommand; - NextEvent.Msg.Command = item->Cmd; -} - -void MenuPopdownCb (Widget w, mItem *item, XtPointer callData) { - DEBUG(("Popdown: %d\n", item->Cmd)); - if (LPopupMenu != 0) { - XtDestroyWidget(XtParent(LPopupMenu)); - LPopupMenu = 0; - } -} - -void InputWindow(Widget w, GViewPeer *Peer, XEvent *event, Boolean *cont) { - DEBUG(("Input\n")); - if (!Peer->View->IsActive()) - Peer->View->Parent->SelectView(Peer->View); - NextEvent.Msg.View = Peer->View; - ProcessXEvents(event, &NextEvent, Peer); - *cont = False; -} - -static void VisibilityCb(Widget w, GViewPeer *peer, XEvent *event, Boolean *cont) { - if (event->type != VisibilityNotify) - return; - - peer->Visibility = event->xvisibility.state; - DEBUG(("Visibility %d\n", peer->Visibility)); - - /* - * When we do an XCopyArea(), and the window is partially obscured, we want - * to receive an event to tell us whether it worked or not. - */ - /*XSetGraphicsExposures(display, gui.text_gc, - gui.visibility != VisibilityUnobscured);*/ - *cont = True; -} - -void ConfigureWindow(Widget w, GViewPeer *Peer, XEvent *event, Boolean *cont) { - Dimension Xd, Yd; - int X, Y; - XConfigureEvent *confEvent = (XConfigureEvent *) event; - - DEBUG(("Configure\n")); - Xd = confEvent->width; - Yd = confEvent->height; - X = Xd; - Y = Yd; - DEBUG(("Resize %d, %d\n", X, Y)); - X /= cxChar; - Y /= cyChar; - DEBUG(("!! Resize %d, %d\n", X, Y)); - if (X > 0 && Y > 0) { - Peer->ConSetSize(X, Y); - NextEvent.What = evCommand; - NextEvent.Msg.Command = cmResize; - } - DEBUG(("!! resize done\n")); - *cont = True; -} - -void ExposeWindow(Widget w, GViewPeer *Peer, XmDrawingAreaCallbackStruct *Call) { - XExposeEvent *exposeEvent = (XExposeEvent *) Call->event; - - DEBUG(("Expose\n")); - // if (!XtIsManaged(w)) return - Peer->UpdateWindow(exposeEvent->x, - exposeEvent->y, - exposeEvent->width, - exposeEvent->height); - DEBUG(("! Expose done\n")); -} - - -void VertValueChanged(Widget w, GViewPeer *Peer, XmScrollBarCallbackStruct *Call) { - if (!Peer->View->IsActive()) - Peer->View->Parent->SelectView(Peer->View); - if (Peer->VertPos != Call->value) { - NextEvent.What = evCommand; - NextEvent.Msg.View = Peer->View; - NextEvent.Msg.Command = cmVScrollMove; - NextEvent.Msg.Param1 = Call->value; - DEBUG(("Vert: %d\n", Call->value)); - Peer->VertPos = Call->value; - } -} - -void HorzValueChanged(Widget w, GViewPeer *Peer, XmScrollBarCallbackStruct *Call) { - if (!Peer->View->IsActive()) - Peer->View->Parent->SelectView(Peer->View); - if (Call->value != Peer->HorzPos) { - NextEvent.What = evCommand; - NextEvent.Msg.View = Peer->View; - NextEvent.Msg.Command = cmHScrollMove; - NextEvent.Msg.Param1 = Call->value; - DEBUG(("Horz: %d\n", Call->value)); - Peer->HorzPos = Call->value; - } -} - -/////////////////////////////////////////////////////////////////////////// - -GViewPeer::GViewPeer(GView *view, int XSize, int YSize) { - - View = view; - Visibility = VisibilityFullyObscured; - - // wX = 0; - // wY = 0; - wW = XSize; - wH = YSize; - sbVtotal = 0; - sbVstart = 0; - sbVamount = 0; - sbHtotal = 0; - sbHstart = 0; - sbHamount = 0; - wState = 0; - cVisible = 1; - cStart = 0; // % - cEnd = 100; - wRefresh = 0; - ScreenBuffer = 0; - cX = -1; - cY = -1; - VertPos = HorzPos = -1; - - for (int jj = 0; jj < 256; jj++) - gc[jj] = 0; - - ScrollWin = XtVaCreateWidget("ScrollWin", - xmScrolledWindowWidgetClass, frames->Peer->PanedWin, - XmNmarginHeight, 0, - XmNmarginWidth, 0, - XmNspacing, 0, - 0); - - TextWin = XtVaCreateManagedWidget ("TextWin", - xmDrawingAreaWidgetClass, ScrollWin, - XmNmarginHeight, 0, - XmNmarginWidth, 0, - XmNhighlightThickness, 0, - XmNshadowThickness, 0, - XmNwidthInc, cxChar, - XmNheightInc, cyChar, - XmNwidth, cxChar * 80, - XmNheight, cyChar * 30, - 0); - - /* XSetWindowColormap(display, XtWindow(TextWin), colormap);*/ - - XtVaSetValues (ScrollWin, - XmNworkWindow, TextWin, - 0); - - SbVert = XtVaCreateManagedWidget("VScrollBar", - xmScrollBarWidgetClass, ScrollWin, - XmNmarginHeight, 0, - XmNmarginWidth, 0, - XmNwidth, 20, - 0); - - SbHorz = XtVaCreateManagedWidget("HScrollBar", - xmScrollBarWidgetClass, ScrollWin, - XmNmarginHeight, 0, - XmNmarginWidth, 0, - XmNorientation, XmHORIZONTAL, - NULL); - - XtVaSetValues(ScrollWin, - XmNhorizontalScrollBar, SbHorz, - XmNverticalScrollBar, SbVert, - 0); - - XtManageChild(ScrollWin); - - gcv.foreground = Colors[0].pixel; - gcv.background = Colors[0].pixel; - gcv.font = fontStruct->fid; - gc[0] = XtGetGC(TextWin, - GCForeground | GCBackground | GCFont, &gcv); - // GCattr = 0x07; - - - /* XtAddCallback(TextWin, XmNinputCallback, InputWindow, this);*/ - - XtAddEventHandler(TextWin, - KeyPressMask | KeyReleaseMask | - ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, - False, InputWindow, this); - XtAddEventHandler(TextWin, - VisibilityChangeMask, - False, VisibilityCb, - this); - XtAddEventHandler(TextWin, - StructureNotifyMask, - False, ConfigureWindow, this); - //XtAddCallback(TextWin, XmNresizeCallback, ResizeWindow, this); - XtAddCallback(TextWin, XmNexposeCallback, ExposeWindow, this); - - XtAddCallback(SbHorz, XmNvalueChangedCallback, HorzValueChanged, this); - XtAddCallback(SbHorz, XmNdragCallback, HorzValueChanged, this); - XtAddCallback(SbHorz, XmNincrementCallback, HorzValueChanged, this); - XtAddCallback(SbHorz, XmNdecrementCallback, HorzValueChanged, this); - XtAddCallback(SbHorz, XmNpageIncrementCallback, HorzValueChanged, this); - XtAddCallback(SbHorz, XmNpageDecrementCallback, HorzValueChanged, this); - XtAddCallback(SbHorz, XmNtoTopCallback, HorzValueChanged, this); - XtAddCallback(SbHorz, XmNtoBottomCallback, HorzValueChanged, this); - - XtAddCallback(SbVert, XmNvalueChangedCallback, VertValueChanged, this); - XtAddCallback(SbVert, XmNdragCallback, VertValueChanged, this); - XtAddCallback(SbVert, XmNincrementCallback, VertValueChanged, this); - XtAddCallback(SbVert, XmNdecrementCallback, VertValueChanged, this); - XtAddCallback(SbVert, XmNpageIncrementCallback, VertValueChanged, this); - XtAddCallback(SbVert, XmNpageDecrementCallback, VertValueChanged, this); - XtAddCallback(SbVert, XmNtoTopCallback, VertValueChanged, this); - XtAddCallback(SbVert, XmNtoBottomCallback, VertValueChanged, this); - -} - -GViewPeer::~GViewPeer() { - XtDestroyWidget(ScrollWin); -} - -int GViewPeer::AllocBuffer() { - int i; - unsigned char *p; - - ScreenBuffer = (unsigned char *)malloc(2 * wW * wH); - if (ScreenBuffer == NULL) return -1; - for (i = 0, p = ScreenBuffer; i < wW * wH; i++) { - *p++ = 32; - *p++ = 0x07; - } - return 0; -} - -#define InRange(x,a,y) (((x) <= (a)) && ((a) < (y))) -#define CursorXYPos(x,y) (ScreenBuffer + ((x) + ((y) * wW)) * 2) - -void GViewPeer::DrawCursor(int Show) { - if (!(View && View->Parent)) - return ; - if (!(wState & sfFocus)) - Show = 0; - - if (Visibility == VisibilityFullyObscured) - return; - - if (cX >= wW || cY >= wW || - cX + 1 > wW || cY + 1 > wH) - { - //fprintf(stderr, "%d %d %d %d %d %d\n", ScreenCols, ScreenRows, X, Y, W, H); - return; - } - - DEBUG(("DrawCursor %d %d\n", cX, cY)); - // if (!XtIsManaged(TextWin)) return ; - - if (cVisible && cX >= 0 && cY >= 0) { - unsigned char *p = CursorXYPos(cX, cY), attr; - attr = p[1]; - /*if (Show) attr = ((((attr << 4) & 0xF0)) | (attr >> 4)) ^ 0x77;*/ - if (Show) attr = (attr ^ 0x77); - - if (gc[attr] == 0) { - gcv.foreground = Colors[attr & 0xF].pixel; - gcv.background = Colors[(attr >> 4) & 0xF].pixel; - gcv.font = fontStruct->fid; - gc[attr] = XtGetGC(TextWin, - GCForeground | GCBackground | GCFont, &gcv); - } - XDrawImageString(display, XtWindow(TextWin), gc[attr], - cX * cxChar, - fontStruct->max_bounds.ascent + cY * cyChar, - p, 1); - } -} - -int GViewPeer::ConPutBox(int X, int Y, int W, int H, PCell Cell) { - int i; - unsigned char temp[256], attr; - unsigned char *p, *ps, *c, *ops; - int len, x, l, ox, olen, skip; - - if (!(View && View->Parent && gc)) - return 1; - - if (Visibility == VisibilityFullyObscured) - return - 1; - - if (X >= wW || Y >= wH || - X + W > wW || Y + H > wH) - { - //fprintf(stderr, "%d %d %d %d %d %d\n", ScreenCols, ScreenRows, X, Y, W, H); - return -1; - } - - - DEBUG(("PutBox %d | %d %d %d %d | %d %d\n", wRefresh, X, Y, W, H, wW, wH)); - for (i = 0; i < H; i++) { - len = W; - p = CursorXYPos(X, Y + i); - ps = (unsigned char *) Cell; - x = X; - while (len > 0) { - if (!wRefresh) { - c = CursorXYPos(x, Y + i); - skip = 0; - ops = ps; - ox = x; - olen = len; - while ((len > 0) && (*(unsigned short *) c == *(unsigned short *)ps)) x++, len--, ps+=2, c+=2, skip++; - if (len <= 0) break; - if (skip <= 4) { - ps = ops; - x = ox; - len = olen; - } - } - p = ps; - l = 1; - temp[0] = *ps++; attr = *ps++; - while ((l < len) && ((unsigned char) (ps[1]) == attr)) { - temp[l++] = *ps++; - ps++; - } - - if (gc[attr] == 0) { - gcv.foreground = Colors[attr & 0xF].pixel; - gcv.background = Colors[(attr >> 4) & 0xF].pixel; - gcv.font = fontStruct->fid; - gc[attr] = XtGetGC(TextWin, - GCForeground | GCBackground | GCFont, &gcv); - } - - XDrawImageString(display, - XtWindow(TextWin), gc[attr], - x * cxChar, - fontStruct->max_bounds.ascent + (Y + i) * cyChar, - temp, l); - x += l; - len -= l; - } - p = CursorXYPos(X, Y + i); - memcpy(p, Cell, W * 2); - if (i + Y == cY) - DrawCursor(1); - Cell += W; - } - DEBUG(("done putbox\n")); - return 0; -} - -void GViewPeer::UpdateWindow(int xx, int yy, int ww, int hh) { - PCell p; - int i; - ww /= cxChar; ww += 2; - hh /= cyChar; hh += 2; - xx /= cxChar; - yy /= cyChar; - if (xx + ww > wW) ww = wW - xx; - if (yy + hh > wH) hh = wH - yy; - wRefresh = 1; - p = (PCell) CursorXYPos(xx, yy); - for (i = 0; i < hh; i++) { - ConPutBox(xx, yy + i, ww, 1, p); - p += wW; - } - XFlush(display); - wRefresh = 0; -} - -int GViewPeer::ConGetBox(int X, int Y, int W, int H, PCell Cell) { - int i; - - for (i = 0; i < H; i++) { - memcpy(Cell, CursorXYPos(X, Y + i), 2 * W); - Cell += W; - } - return 0; -} - -int GViewPeer::ConPutLine(int X, int Y, int W, int H, PCell Cell) { - int i; - - for (i = 0; i < H; i++) { - if (ConPutBox(X, Y + i, W, 1, Cell) != 0) return -1; - } - return 0; -} - -int GViewPeer::ConSetBox(int X, int Y, int W, int H, TCell Cell) { - TDrawBuffer B; - int i; - - for (i = 0; i < W; i++) B[i] = Cell; - ConPutLine(X, Y, W, H, B); - return 0; -} - -int GViewPeer::ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count) { - TCell Cell; - int l; - - MoveCh(&Cell, ' ', Fill, 1); - DrawCursor(0); - if (Way == csUp) { - XCopyArea(display, XtWindow(TextWin), XtWindow(TextWin), gc[0], - X * cxChar, - (Y + Count) * cyChar, - W * cxChar, - (H - Count) * cyChar, - X * cxChar, - Y * cyChar - ); - for (l = 0; l < H - Count; l++) { - memcpy(CursorXYPos(X, Y + l), CursorXYPos(X, Y + l + Count), 2 * W); - } - if (ConSetBox(X, Y + H - Count, W, Count, Cell) == -1) return -1; - } else if (Way == csDown) { - XCopyArea(display, XtWindow(TextWin), XtWindow(TextWin), gc[0], - X * cxChar, - Y * cyChar, - W * cxChar, - (H - Count) * cyChar, - X * cxChar, - (Y + Count)* cyChar - ); - for (l = H - 1; l >= Count; l--) { - memcpy(CursorXYPos(X, Y + l), CursorXYPos(X, Y + l - Count), 2 * W); - } - if (ConSetBox(X, Y, W, Count, Cell) == -1) return -1; - } - DrawCursor(1); - return 0; -} - -int GViewPeer::ConSetSize(int X, int Y) { - unsigned char *NewBuffer; - unsigned char *p; - int i; - unsigned int MX, MY; - - p = NewBuffer = (unsigned char *) malloc(X * Y * 2); - if (NewBuffer == NULL) return -1; - for (i = 0; i < X * Y; i++) { - *p++ = ' '; - *p++ = 0x07; - } - if (ScreenBuffer) { - MX = wW; if (X < MX) MX = X; - MY = wH; if (Y < MY) MY = Y; - if (X < MX) MX = X; - p = NewBuffer; - for (i = 0; i < MY; i++) { - memcpy(p, CursorXYPos(0, i), MX * 2); - p += X * 2; - } - free(ScreenBuffer); - } - ScreenBuffer = NewBuffer; - wW = X; - wH = Y; - wRefresh = 1; - View->Resize(wW, wH); - ConPutBox(0, 0, wW, wH, (PCell) ScreenBuffer); - wRefresh = 0; - // if (Refresh == 0) - // XResizeWindow(display, win, ScreenCols * cxChar, ScreenRows * cyChar); - return 1; -} - -int GViewPeer::ConQuerySize(int *X, int *Y) { - if (X) *X = wW; - if (Y) *Y = wH; - return 1; -} - -int GViewPeer::ConSetCursorPos(int X, int Y) { - if (X < 0) X = 0; - if (X >= wW) X = wW - 1; - if (Y < 0) Y = 0; - if (Y >= wH) Y = wH - 1; - DrawCursor(0); - cX = X; - cY = Y; - DrawCursor(1); - return 1; -} - -int GViewPeer::ConQueryCursorPos(int *X, int *Y) { - if (X) *X = cX; - if (Y) *Y = cY; - return 1; -} - -int GViewPeer::ConShowCursor() { - cVisible = 1; - // DrawCursor(1); - return 1; -} - -int GViewPeer::ConHideCursor() { - cVisible = 0; - // DrawCursor(0); - return 1; -} - -int GViewPeer::ConCursorVisible() { - return cVisible; -} - -int GViewPeer::ConSetCursorSize(int Start, int End) { - cStart = Start; - cEnd = End; - if (wState & sfFocus) - return 1; //PMSetCursorSize(Start, End); - else - return 1; -} - -int GViewPeer::ExpandHeight(int DeltaY) { - return 0; -} - -int GViewPeer::QuerySbVPos() { - return sbVstart; -} - -int GViewPeer::SetSbVPos(int Start, int Amount, int Total) { - if (sbVstart != Start || - sbVamount != Amount || - sbVtotal != Total) - { - sbVstart = Start; - sbVamount = Amount; - sbVtotal = Total; - - if (View->Parent == 0) - return 0; - if (Amount < 1 || Start + Amount > Total) { - XtVaSetValues(SbVert, - XmNmaximum, 1, - XmNminimum, 0, - XmNpageIncrement, 1, - XmNsliderSize, 1, - XmNvalue, 0, - 0); - } else { - XtVaSetValues(SbVert, - XmNmaximum, Total, - XmNminimum, 0, - XmNpageIncrement, ((Amount > 1) ? Amount : 1), - XmNsliderSize, Amount, - XmNvalue, Start, - 0); - } - } - return 1; -} - -int GViewPeer::SetSbHPos(int Start, int Amount, int Total) { - if (sbHstart != Start || - sbHamount != Amount || - sbHtotal != Total) - { - sbHstart = Start; - sbHamount = Amount; - sbHtotal = Total; - - if (View->Parent == 0) - return 0; - - if (Amount < 1 || Start + Amount > Total) { - XtVaSetValues(SbHorz, - XmNmaximum, 1, - XmNminimum, 0, - XmNpageIncrement, 1, - XmNsliderSize, 1, - XmNvalue, 0, - 0); - } else { - XtVaSetValues(SbHorz, - XmNmaximum, Total, - XmNminimum, 0, - XmNpageIncrement, ((Amount > 1) ? Amount : 1), - XmNsliderSize, Amount, - XmNvalue, Start, - 0); - } - } - return 1; -} - -int GViewPeer::UpdateCursor() { - ConSetCursorPos(cX, cY); - ConSetCursorSize(cStart, cEnd); - if (cVisible) - ConShowCursor(); - else - ConHideCursor(); - return 1; -} - -int GViewPeer::PMShowCursor() { - // if (wState & sfFocus) - // WinShowCursor(hwndView, TRUE); - return 1; -} - -int GViewPeer::PMHideCursor() { - // if (wState & sfFocus) - // WinShowCursor(hwndView, FALSE); - return 1; -} - -int GViewPeer::PMSetCursorPos() { - // if (wState & sfFocus) { - // WinDestroyCursor(hwndView); - // WinCreateCursor(hwndView, - // cxChar * cX, cyChar * (wH - cY - 1), cxChar, 2, - // CURSOR_TYPE, - // NULL); - // WinShowCursor(hwndView, TRUE); - // } - return 1; -} - -/////////////////////////////////////////////////////////////////////////// - -GView::GView(GFrame *parent, int XSize, int YSize) { - Parent = parent; - Prev = Next = 0; - Peer = new GViewPeer(this, XSize, YSize); - if (Parent) - Parent->AddView(this); -} - -GView::~GView() { - if (Parent) - Parent->RemoveView(this); - if (Peer) - delete Peer; -} - -int GView::ConClear() { - int W, H; - TDrawBuffer B; - - ConQuerySize(&W, &H); - MoveChar(B, 0, W, ' ', 0x07, 1); - ConSetBox(0, 0, W, H, B[0]); - return 1; -} - -int GView::ConPutBox(int X, int Y, int W, int H, PCell Cell) { - return Peer->ConPutBox(X, Y, W, H, Cell); -} - -int GView::ConGetBox(int X, int Y, int W, int H, PCell Cell) { - return Peer->ConGetBox(X, Y, W, H, Cell); -} - -int GView::ConPutLine(int X, int Y, int W, int H, PCell Cell) { - return Peer->ConPutLine(X, Y, W, H, Cell); -} - -int GView::ConSetBox(int X, int Y, int W, int H, TCell Cell) { - return Peer->ConSetBox(X, Y, W, H, Cell); -} - -int GView::ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count) { - return Peer->ConScroll(Way, X, Y, W, H, Fill, Count); -} - -int GView::ConSetSize(int X, int Y) { - if (Peer->ConSetSize(X, Y)) ; - // Resize(X, Y); - else - return 0; - return 1; -} - -int GView::ConQuerySize(int *X, int *Y) { - return Peer->ConQuerySize(X, Y); -} - -int GView::ConSetCursorPos(int X, int Y) { - return Peer->ConSetCursorPos(X, Y); -} - -int GView::ConQueryCursorPos(int *X, int *Y) { - return Peer->ConQueryCursorPos(X, Y); -} - -int GView::ConShowCursor() { - return Peer->ConShowCursor(); -} - -int GView::ConHideCursor() { - return Peer->ConHideCursor(); -} - -int GView::ConCursorVisible() { - return Peer->ConCursorVisible(); -} - -int GView::ConSetCursorSize(int Start, int End) { - return Peer->ConSetCursorSize(Start, End); -} - -int GView::QuerySbVPos() { - return Peer->QuerySbVPos(); -} - -int GView::SetSbVPos(int Start, int Amount, int Total) { - return Peer->SetSbVPos(Start, Amount, Total); -} - -int GView::SetSbHPos(int Start, int Amount, int Total) { - return Peer->SetSbHPos(Start, Amount, Total); -} - -int GView::ExpandHeight(int DeltaY) { - return Peer->ExpandHeight(DeltaY); -} - -void GView::Update() { -} - -void GView::Repaint() { -} - -void GView::HandleEvent(TEvent &Event) { -} - -void GView::Resize(int width, int height) { - Repaint(); -} - -void GView::EndExec(int NewResult) { - Result = NewResult; -} - -int GView::Execute() { - int SaveRc = Result; - int NewResult; - - Result = -2; - while (Result == -2 && frames != 0) - gui->ProcessEvent(); - NewResult = Result; - Result = SaveRc; - return NewResult; -} - -int GView::IsActive() { - return (Parent->Active == this); -} - -void GView::Activate(int gotfocus) { - if (gotfocus) { - Peer->wState |= sfFocus; - Peer->UpdateCursor(); - } else { - Peer->wState &= ~sfFocus; - } - Repaint(); -} - -int GView::CaptureMouse(int grab) { - if (MouseCapture == 0) { - if (grab) - MouseCapture = this; - else - return 0; - } else { - if (grab || MouseCapture != this) - return 0; - else - MouseCapture = 0; - } - return 1; -} - -/////////////////////////////////////////////////////////////////////////// - -GFramePeer::GFramePeer(GFrame *frame, int Width, int Height) { - ShellWin = XtCreatePopupShell("fte", topLevelShellWidgetClass, - TopLevel, NULL, 0); - - XtVaSetValues(ShellWin, - XmNwidthInc, cxChar, - XmNheightInc, cyChar, - NULL); - - MainWin = XtCreateManagedWidget("Widget", xmMainWindowWidgetClass, - ShellWin, NULL, 0); - - PanedWin = XtVaCreateManagedWidget("pane", - xmPanedWindowWidgetClass, MainWin, - XmNmarginHeight, 0, - XmNmarginWidth, 0, - 0 ); - - XtVaSetValues (MainWin, - XmNworkWindow, PanedWin, - 0); - - if (Width != -1 && Height != -1) - ConSetSize(Width, Height); -} - -GFramePeer::~GFramePeer() { -} - -int GFramePeer::ConSetSize(int X, int Y) { - //return ::ConSetSize(X, Y); - return 0; -} - -int GFramePeer::ConQuerySize(int *X, int *Y) { - // ::ConQuerySize(&fW, &fH); - // if (X) *X = fW; - // if (Y) *Y = fH; - return 1; -} - -//int GFrame::ConQuerySize(int *X, int *Y) { -// ::ConQuerySize(X, Y); -// if (ShowVScroll) -// --*X; -//} - -int GFramePeer::ConSetTitle(char *Title, char *STitle) { - XSetStandardProperties(display, XtWindow(ShellWin), Title, STitle, 0, NULL, 0, NULL); - return 1; -} - -int GFramePeer::ConGetTitle(char *Title, int MaxLen, char *STitle, int SMaxLen) { - *Title = 0; - *STitle = 0; - return 1; -} - -void GFramePeer::MapFrame() { - //Parent->UpdateMenu(); - XtPopup(ShellWin, XtGrabNone); - XSetWMProtocols(display, XtWindow(ShellWin), &WM_DELETE_WINDOW, 1); - XtInsertEventHandler(ShellWin, NoEventMask, True, CloseWindow, NULL, XtListHead); -} - -/////////////////////////////////////////////////////////////////////////// - -GFrame::GFrame(int XSize, int YSize) { - Menu = 0; - if (frames == 0) { - frames = Prev = Next = this; - } else { - Next = frames->Next; - Prev = frames; - frames->Next->Prev = this; - frames->Next = this; - frames = this; - } - Top = Active = 0; - Peer = new GFramePeer(this, XSize, YSize); -} - -GFrame::~GFrame() { - if (Peer) { - delete Peer; - Peer = 0; - } - if (Next == this) { - frames = 0; - // DEBUG(("No more frames\x7\x7\n")); - } else { - Next->Prev = Prev; - Prev->Next = Next; - frames = Next; - } - Next = Prev = 0; -} - -int GFrame::ConSetTitle(char *Title, char *STitle) { - return Peer->ConSetTitle(Title, STitle); -} - -int GFrame::ConGetTitle(char *Title, int MaxLen, char *STitle, int SMaxLen) { - return Peer->ConGetTitle(Title, MaxLen, STitle, SMaxLen); -} - -int GFrame::ConSetSize(int X, int Y) { - return Peer->ConSetSize(X, Y); -} - -int GFrame::ConQuerySize(int *X, int *Y) { - return Peer->ConQuerySize(X, Y); -} - -int GFrame::ConSplitView(GView *view, GView *newview) { - int dmy; - - newview->Parent = this; - // newview->Peer->wX = 0; - ConQuerySize(&newview->Peer->wW, &dmy); - // newview->Peer->wY = view->Peer->wY + view->Peer->wH / 2; - // newview->Peer->wH = view->Peer->wH - view->Peer->wH / 2; - // view->Peer->wH /= 2; - InsertView(view, newview); - view->ConSetSize(view->Peer->wW, view->Peer->wH); - newview->ConSetSize(newview->Peer->wW, newview->Peer->wH); - return 0; -} - -int GFrame::ConCloseView(GView *view) { - return 0; -} - -int GFrame::ConResizeView(GView *view, int DeltaY) { - return 0; -} - -int GFrame::AddView(GView *view) { - if (Top != 0) { - return ConSplitView(Top, view); - } else { - // int W, H; - - view->Parent = this; - view->Prev = view->Next = 0; - - // view->Peer->wX = 0; - // view->Peer->wY = 0; - // ConQuerySize(&W, &H); - // view->ConSetSize(W, H); - InsertView(Top, view); - return 0; - } -} - -void GFrame::Update() { - GView *v = Active; - - UpdateMenu(); - while (v) { - v->Update(); - v = v->Next; - if (v == Active) - break; - } -} - -void GFrame::UpdateMenu() { -} - -void GFrame::Repaint() { - GView *v = Active; - - while (v) { - v->Repaint(); - v = v->Next; - if (v == Active) - break; - } -} - -void GFrame::InsertView(GView *Prev, GView *view) { - if (!view) return ; - if (Prev) { - view->Prev = Prev; - view->Next = Prev->Next; - Prev->Next = view; - view->Next->Prev = view; - } else { - view->Prev = view->Next = view; - Top = view; - } - if (Active == 0) { - Active = view; - Active->Activate(1); - } -} - -void GFrame::RemoveView(GView *view) { - if (!view) return ; - - if (Active == view) - Active->Activate(0); - if (view->Next == view) { - Top = Active = 0; - delete this; - } else { - view->Next->Prev = view->Prev; - view->Prev->Next = view->Next; - - // if (Top == view) { - // Top = view->Next; - // Top->Peer->wY -= view->Peer->wH; - // Top->ConSetSize(Top->Peer->wW, Top->Peer->wH + view->Peer->wH); - // } else { - // view->Prev->ConSetSize(view->Prev->Peer->wW, - // view->Prev->Peer->wH + view->Peer->wH); - // } - - if (Active == view) { - Active = view->Prev; - Active->Activate(1); - } - } -} - -void GFrame::SelectNext(int back) { - GView *c = Active; - - if (c == 0 && Top == 0) - return; - else if (c == 0) - c = Active = Top; - else - if (back) { - Active = Active->Prev; - } else { - Active = Active->Next; - } - if (c != Active) { - c->Activate(0); - Active->Activate(1); - } - if (Active) - XtSetKeyboardFocus(Peer->PanedWin, Active->Peer->TextWin); -} - -int GFrame::SelectView(GView *view) { - if (Top == 0) - return 0; - - if (FocusCapture != 0 || MouseCapture != 0) - return 0; - - if (Active) - Active->Activate(0); - Active = view; - if (Active) - Active->Activate(1); - if (Active) - XtSetKeyboardFocus(Peer->PanedWin, Active->Peer->TextWin); - return 1; -} - -void GFrame::Resize(int width, int height) { - if (!Top) - return; - - if (width < 8 || height < 2) - return; - - if (Top == Top->Next) { - Top->ConSetSize(width, height); - } else { - } -} - -Widget CreateMotifMenu(Widget parent, int menu, int main, XtCallbackProc MenuProc) { - Widget hmenu; - int i; - char s[256]; - char *p; - Widget item; - - if (main == 1) { - hmenu = XmCreateMenuBar(parent, "menu", NULL, 0); - } else if (main == 2) { - hmenu = XmCreatePopupMenu(parent, "submenu", - NULL, 0); - // XtCreateManagedWidget ( "Title", xmLabelWidgetClass, hmenu, - // NULL, 0 ); - - // XtCreateManagedWidget ( "separator", xmSeparatorWidgetClass, - // hmenu, NULL, 0 ); - } else { - hmenu = XmCreatePulldownMenu(parent, "submenu", - NULL, 0); - } - - for (i = 0; i < Menus[menu].Count; i++) { - if (Menus[menu].Items[i].Name) { - char *mn = 0; - - strcpy(s, Menus[menu].Items[i].Name); - p = strchr(s, '&'); - if (p) { - strcpy(p, p + 1); - mn = p; - } - p = strchr(s, '\t'); - if (p) { - *p = 0; - p++; - } - - if (Menus[menu].Items[i].SubMenu != -1) { - item = XtVaCreateManagedWidget(s, - xmCascadeButtonWidgetClass, - hmenu, - XmNsubMenuId, - CreateMotifMenu(hmenu, - Menus[menu].Items[i].SubMenu, - 0, MenuProc), - NULL ); - } else { - item = XtVaCreateManagedWidget(s, - xmPushButtonWidgetClass, hmenu, - 0); - XtAddCallback(item, XmNactivateCallback, - MenuProc, &(Menus[menu].Items[i])); - } - - if (p) - XtVaSetValues(item, - XmNacceleratorText, - XmStringCreate(p, XmSTRING_DEFAULT_CHARSET), - 0); - if (mn) - XtVaSetValues(item, - XmNmnemonic, - KeySym(*mn), - 0); - } else { - item = XtVaCreateManagedWidget("separator", - xmSeparatorWidgetClass, - hmenu, - 0); - //XmCreateSeparator(parent, "xx", 0, 0); - } - // item.id = Menus[menu].Items[i].Cmd & 0xFFFF; // ? - } - return hmenu; -} - -Widget CreateMotifMainMenu(Widget parent, char *Name) { - int id = GetMenuId(Name); - - return CreateMotifMenu(parent, id, 1, MainCallback); -} - -int GFrame::SetMenu(const char *Name) { - if (Menu) free(Menu); - Menu = strdup(Name); - - Peer->MenuBar = CreateMotifMainMenu(Peer->MainWin, Name); - XtManageChild (Peer->MenuBar); - XtVaSetValues (Peer->MainWin, - XmNmenuBar, Peer->MenuBar, - 0); - - return 1; -} - -int GFrame::ExecMainMenu(char Sub) { - return 0; -} - -int GFrame::PopupMenu(const char *Name) { - int id = GetMenuId(Name); - - LPopupMenu = CreateMotifMenu(Peer->MainWin, id, 2, (XtCallbackProc)PopupCallback); - XtAddCallback(XtParent(LPopupMenu), XmNpopdownCallback, MenuPopdownCb, 0); - XmMenuPosition (LPopupMenu, (XButtonEvent *)&LastRelease); - XtManageChild (LPopupMenu); - return 1; -} - -// GUI - - -GUI::GUI(int &argc, char **argv, int XSize, int YSize) { - - char *fs = getenv("VIOFONT"); - if (fs == 0 && WindowFont[0] != 0) - fs = WindowFont; - - TopLevel = XtVaAppInitialize(&AppContext, "TopLevel", NULL, 0, - &argc, argv, NULL, - XmNmappedWhenManaged, FALSE, - NULL); - - if (TopLevel == 0) - return ; - - display = XtDisplay(TopLevel); - //XSynchronize(display, True); - if (display == NULL) - return; - - root = DefaultRootWindow(display); - screen = DefaultScreen(display); - colormap = DefaultColormap(display, screen); - - InitXColors(); - - fontStruct = NULL; - if (fs) - fontStruct = XLoadQueryFont(display, fs); - else { -#ifdef HPUX - fontStruct = XLoadQueryFont(display, "8x13"); -#endif -#ifdef AIX - fontStruct = XLoadQueryFont(display, "8x13"); -#endif -#ifdef LINUX - fontStruct = XLoadQueryFont(display, "8x13"); -#endif -#ifdef IRIX - fontStruct = XLoadQueryFont(display, "8x13"); -#endif - } - if (fontStruct == NULL) - fontStruct = XLoadQueryFont(display, "fixed"); - if (fontStruct == NULL) - return; - cxChar = fontStruct->max_bounds.width; - cyChar = fontStruct->max_bounds.ascent + fontStruct->max_bounds.descent; - XtRealizeWidget(TopLevel); - - WM_DELETE_WINDOW = XInternAtom(display, "WM_DELETE_WINDOW", False); - - gui = this; -} - -GUI::~GUI() { - gui = 0; -} - -int GUI::ConGrabEvents(TEventMask EventMask) { - return 0; -} - -void GUI::DispatchEvent(GFrame *frame, GView *view, TEvent &Event) { - if (Event.What != evNone) { - if (view) - view->HandleEvent(Event); - } -} - -int GUI::ConSuspend(void) { return 0; } - -int GUI::ConContinue(void) { return 0; } - -int GUI::ConGetEvent(TEventMask EventMask, TEvent *Event, int WaitTime, int Delete, GView **view) { - //return ::ConGetEvent(EventMask, Event, WaitTime, Delete, view); - assert(1 == 0); - return 0; -} - -int GUI::ConPutEvent(TEvent Event) { - EventBuf = Event; - return 0; -} - -int GUI::ConFlush(void) { - return 0; -} - -void GUI::ProcessEvent() { - static int need_update = 1; - - if (need_update && XtAppPending(AppContext) == 0 ) { - frames->Update(); - need_update = 0; - } - XtAppProcessEvent(AppContext, XtIMAll); - if (NextEvent.What != evNone) { - DispatchEvent(frames, NextEvent.Msg.View, NextEvent); - NextEvent.What = evNone; - need_update = 1; - } -} - -int GUI::Run() { - frames->Peer->MapFrame(); - - //XtAppMainLoop(AppContext); - while (frames != 0) - ProcessEvent(); - - return 0; -} - -int GUI::ShowEntryScreen() { - return 1; -} - -int GUI::RunProgram(int mode, char *Command) { - char Cmd[1024]; - - char* xterm = getenv("TERM"); - if (NULL == xterm || 0 == *xterm) - xterm = "xterm"; - - strcpy(Cmd, xterm); - - if (*Command == 0) // empty string = shell - strcat(Cmd, " -ls &"); - else { - strcat(Cmd, " -e "); - // buffer overflow problem: -2 for possible async. - strncat(Cmd, Command, sizeof(Cmd) - strlen(Cmd) - 2); - Cmd[sizeof(Cmd) - 3] = 0; - if (mode == RUN_ASYNC) - strcat(Cmd, " &"); - } - rc = system(Cmd); - return rc; -} - -void PipeCallback(GPipe *pipe, int *source, XtInputId *input) { - if (pipe && pipe->notify && *source == pipe->fd) { - NextEvent.What = evNotify; - NextEvent.Msg.View = frames->Active; - NextEvent.Msg.Model = pipe->notify; - NextEvent.Msg.Command = cmPipeRead; - NextEvent.Msg.Param1 = pipe->id; - pipe->stopped = 0; - } - //fprintf(stderr, "Pipe %d\n", *source); -} - -int GUI::OpenPipe(char *Command, EModel *notify) { - int i; - - for (i = 0; i < MAX_PIPES; i++) { - if (Pipes[i].used == 0) { - int pfd[2]; - - Pipes[i].id = i; - Pipes[i].notify = notify; - Pipes[i].stopped = 1; - - if (pipe((int *)pfd) == -1) - return -1; - - switch (Pipes[i].pid = fork()) { - case -1: /* fail */ - return -1; - case 0: /* child */ - close(pfd[0]); - close(0); - dup2(pfd[1], 1); - dup2(pfd[1], 2); - exit(system(Command)); - default: - close(pfd[1]); - fcntl(pfd[0], F_SETFL, O_NONBLOCK); - Pipes[i].fd = pfd[0]; - } - Pipes[i].input = - XtAppAddInput(AppContext, Pipes[i].fd, XtInputReadMask, PipeCallback, &Pipes[i]); - Pipes[i].used = 1; - //fprintf(stderr, "Pipe Open: %d\n", i); - return i; - } - } - return -1; -} - -int GUI::SetPipeView(int id, EModel *notify) { - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - //fprintf(stderr, "Pipe View: %d %08X\n", id, notify); - Pipes[id].notify = notify; - if (notify != Pipes[id].notify) - if (notify) { - Pipes[id].input = - XtAppAddInput(AppContext, Pipes[id].fd, XtInputReadMask, PipeCallback, &Pipes[id]); - } else { - if (Pipes[id].input != 0) { - XtRemoveInput(Pipes[id].input); - Pipes[id].input = 0; - } - } - return 0; -} - -int GUI::ReadPipe(int id, void *buffer, int len) { - int rc; - - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - //fprintf(stderr, "Pipe Read: Get %d %d\n", id, len); - - rc = read(Pipes[id].fd, buffer, len); - //fprintf(stderr, "Pipe Read: Got %d %d\n", id, len); - if (rc == 0) { - if (Pipes[id].input != 0) { - XtRemoveInput(Pipes[id].input); - Pipes[id].input = 0; - } - close(Pipes[id].fd); - return -1; - } - if (rc == -1) { - Pipes[id].stopped = 1; - return 0; - } - return rc; -} - -int GUI::ClosePipe(int id) { - int status; - - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - waitpid(Pipes[id].pid, &status, 0); - //fprintf(stderr, "Pipe Close: %d\n", id); - Pipes[id].used = 0; - return WEXITSTATUS(status); -} - -int GetXSelection(int *len, char **data) { - *data = XFetchBytes(display, len); - if (*data == 0) - return -1; - else - return 0; -} - -int SetXSelection(int len, char *data) { - XStoreBytes(display, data, len); - XSetSelectionOwner (display, XA_PRIMARY, None, CurrentTime); - return 1; -} - -/* - static void SetColor(int i) { - int j, k, z; - j = i & 7; - k = 65535 - 20480; - z = (i > 7) ? (20480) : 0; - Colors[i].blue = k * (j & 1) + z; - Colors[i].green = k * ((j & 2)?1:0) + z; - Colors[i].red = k * ((j & 4)?1:0) + z; - Colors[i].flags = DoRed | DoGreen | DoBlue; - } - - static int InitXColors() { - int i; - - for (i = 0; i < 16; i++) { - SetColor(i); - if (XAllocColor(display, colormap, &Colors[i]) == 0) { - colormap = XCreateColormap(display, win, DefaultVisual(display, screen), AllocNone); - for (i = 0; i < 16; i++) { - SetColor(i); - XAllocColor(display, colormap, &Colors[i]); - } - XSetWindowColormap(display, win, colormap); - return 0; - } - } - return 0; - } - static int InitXGCs() { - int i; - XGCValues gcv; - - for (i = 0; i < 256; i++) { - gcv.foreground = Colors[i % 16].pixel; - gcv.background = Colors[(i / 16)].pixel; - gcv.font = fontStruct->fid; - GCs[i] = XCreateGC(display, win, GCForeground | GCBackground | GCFont, &gcv); - } - return 0; - } - */ - -void DieError(int rc, const char *msg, ...) { - va_list ap; - - va_start(ap, msg); - vfprintf(stderr, msg, ap); - va_end(ap); - exit(rc); -} - -char ConGetDrawChar(int index) { - static char tab[] = "\x0D\x0C\x0E\x0B\x12\x19____+>\x1F\x01\x12 "; - - assert(index >= 0 && index < strlen(tab)); - - return tab[index]; -} diff --git a/src/g_pm.cpp b/src/g_pm.cpp deleted file mode 100644 index 6668ff1..0000000 --- a/src/g_pm.cpp +++ /dev/null @@ -1,3891 +0,0 @@ -/* g_pm.cpp - * - * Copyright (c) 1994-1996, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -/* - * here's how it works: - * there's one visible and one object window per view - * events are forwarded from the visible on to object window and pulled - * into the editor from the worker thread (there's only one, FTE - * editor core is single-threaded). - * SIQ is never blocked. - * the only problem is that window doesn't repaint correctly after resize, - * until the worker thread finishes processing, but we can't really - * do anything with this as the editor core is not thread-safe. - */ - -#define INCL_WIN -#define INCL_GPI -#define INCL_VIO -#define INCL_AVIO -#define INCL_DOS -#define INCL_DOSERRORS - -#include -#include -#include -#include -#include -#include -#include -#include -#include "ftever.h" -#include "sysdep.h" -#include "feature.h" -#include "console.h" -#include "gui.h" -#include "c_history.h" -#include "c_commands.h" -#include "c_config.h" -#include "c_mode.h" -#include "c_color.h" -#include "s_files.h" -#include "log.h" - -#define PM_STACK_SIZE (96 * 1024) - -#define UWM_NOTIFY (WM_USER + 1) -#define UWM_DESTROY (WM_USER + 2) -#define UWM_DESTROYHWND (WM_USER + 3) -#define UWM_DROPPEDFILE (WM_USER + 4) -#define UWM_FILEDIALOG (WM_USER + 5) -#define UWM_DLGBOX (WM_USER + 6) -#define UWM_PROCESSDLG (WM_USER + 7) -#define UWM_CHOICE (WM_USER + 8) -#define UWM_CREATECHILD (WM_USER + 9) -#define UWM_CREATEWORKER (WM_USER + 10) -#define UWM_CREATEFRAME (WM_USER + 11) -#define UWM_CREATEMAINMENU (WM_USER + 12) -#define UWM_CREATEPOPUPMENU (WM_USER + 13) - -#define CURSOR_TYPE (CURSOR_FLASH | CURSOR_SOLID) - -//#define SIZER_HEIGHT 4 - -#define FID_MTOOLBAR 10001 - -#define MAXXSIZE 160 -#define MAXYSIZE 96 - -#define MAX_PIPES 4 -#define PIPE_BUFLEN 4096 - -typedef struct { - int used; - int id; - int reading, stopped; - TID tid; - HMTX Access; - HEV ResumeRead; - char *buffer; - int buflen; - int bufused; - int bufpos; - EModel *notify; - char *Command; - int RetCode; - int DoTerm; -} GPipe; - -static GPipe Pipes[MAX_PIPES] = { - { 0 }, { 0 }, { 0 }, { 0 } -}; - -#define sfFocus 1 - -typedef struct _PMPTR { // for passing pointers to winprocs - USHORT len; - void *p; -} PMPTR; - -class GViewPeer; - -struct PMData { - GViewPeer *Peer; - HVPS hvps; - HPS hps; - SHORT cxChar; - SHORT cyChar; - HWND hwndWorker; -}; - -class GViewPeer { -public: - GView *View; -// int wX, wY; - int wW, wH, wState; - int cX, cY, cVisible, cStart, cEnd; - int sbVstart, sbVamount, sbVtotal; - int sbHstart, sbHamount, sbHtotal; - - HWND hwndView; - HWND hwndVscroll, hwndHscroll; - HWND hwndWorker; - PMData *pmData; - int OldMouseX, OldMouseY; - - GViewPeer(GView *view, int XSize, int YSize); - ~GViewPeer(); - - int ConPutBox(int X, int Y, int W, int H, PCell Cell); - int ConGetBox(int X, int Y, int W, int H, PCell Cell); - int ConPutLine(int X, int Y, int W, int H, PCell Cell); - int ConSetBox(int X, int Y, int W, int H, TCell Cell); - int ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count); - - int ConSetSize(int X, int Y); - int ConQuerySize(int *X, int *Y); - - int ConSetCursorPos(int X, int Y); - int ConQueryCursorPos(int *X, int *Y); - int ConShowCursor(); - int ConHideCursor(); - int ConCursorVisible(); - int ConSetCursorSize(int Start, int End); - - int QuerySbVPos(); - int SetSbVPos(int Start, int Amount, int Total); - int SetSbHPos(int Start, int Amount, int Total); - int ExpandHeight(int DeltaY); - - int UpdateCursor(); - int PMShowCursor(); - int PMHideCursor(); - int PMSetCursorPos(); -}; - -class GFramePeer { -public: - GFrame *Frame; - HWND hwndFrame; - HWND menuBar; - HWND hwndToolBar; - PFNWP oldFrameProc; - - GFramePeer(GFrame *aFrame, int Width, int Height); - ~GFramePeer(); - - int ConSetTitle(char *Title, char *STitle); - int ConGetTitle(char *Title, int MaxLen, char *STitle, int SMaxLen); - - int ConSetSize(int X, int Y); - int ConQuerySize(int *X, int *Y); - void MapFrame(); - void ShowFrame(); - void SizeFrame(); -}; - -int ShowVScroll = 1; -int ShowHScroll = 0; -int ShowMenuBar = 1; -int ShowToolBar = 1; -unsigned long HaveGUIDialogs = - GUIDLG_FILE | - GUIDLG_CHOICE | - GUIDLG_FIND | - GUIDLG_FINDREPLACE | - GUIDLG_PROMPT; -extern int PMDisableAccel; - -GFrame *frames = 0; -GUI *gui = 0; - -GView *MouseCapture = 0; -GView *FocusCapture = 0; - -static HEV WorkerStarted, StartInterface; - -HWND CreatePMMainMenu(HWND parent, HWND owner, char *Name); -HWND CreatePMMenu(HWND parent, HWND owner, int menu, int id, int style); -HWND CreateToolBar(HWND parent, HWND owner, int id); - -MRESULT EXPENTRY FrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2); -//MRESULT EXPENTRY SizerWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2); -MRESULT EXPENTRY AVIOWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2); -MRESULT EXPENTRY ObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2); -MRESULT EXPENTRY CreatorWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2); - -HAB hab = 0; -HAB habW = 0; -static char szClient[] = "EViewer"; -static char szObject[] = "EWorker"; -static char szCreator[] = "ECreator"; -//static char szSizeBar[] = "ESizeBar" // TODO -static ULONG flFrame = - FCF_TITLEBAR | FCF_SYSMENU | - FCF_SIZEBORDER | FCF_MAXBUTTON | FCF_HIDEBUTTON | - FCF_SHELLPOSITION | FCF_TASKLIST | -// FCF_VERTSCROLL | FCF_HORZSCROLL | - FCF_MENU | FCF_ICON; - -SWP swp; -HMQ hmq = 0; -HMQ hmqW = 0; -HMTX hmtxPMData = 0; -ULONG cxScreen, cyScreen, - cyTitleBar, //cyMenuBar, - cxBorder, cyBorder, - cxScrollBar, cyScrollBar; -SHORT reportSize = 1; -TEvent EventBuf = { evNone }; -HWND hwndCreatorUser, hwndCreatorWorker; -char dragname[CCHMAXPATH]; - -#ifdef OLD_PMMENUTOOLBAR /* implemented using menus */ - -struct { - int id; - HBITMAP handle; - int cmd; - int flags; -} tools[] = -{ -// { 101, 0, ExExitEditor, MIS_BITMAP }, -// { 0, 0, 0, MIS_SEPARATOR }, - { 102, 0, ExFileOpen, MIS_BITMAP }, - { 103, 0, ExFileSave, MIS_BITMAP }, - { 104, 0, ExFileClose, MIS_BITMAP }, - { 0, 0, 0, MIS_SEPARATOR }, - { 105, 0, ExFilePrev, MIS_BITMAP }, - { 106, 0, ExFileLast, MIS_BITMAP }, - { 107, 0, ExFileNext, MIS_BITMAP }, - { 0, 0, 0, MIS_SEPARATOR }, - { 108, 0, ExUndo, MIS_BITMAP }, - { 109, 0, ExRedo, MIS_BITMAP }, - { 0, 0, 0, MIS_SEPARATOR }, - { 110, 0, ExBlockCut, MIS_BITMAP }, - { 111, 0, ExBlockCopy, MIS_BITMAP }, - { 112, 0, ExBlockPasteStream, MIS_BITMAP }, - { 113, 0, ExBlockPasteColumn, MIS_BITMAP }, - { 0, 0, 0, MIS_SEPARATOR }, - { 114, 0, ExCompilePrevError, MIS_BITMAP }, - { 115, 0, ExCompileNextError, MIS_BITMAP }, - { 0, 0, 0, MIS_SEPARATOR }, - { 116, 0, ExTagFindWord, MIS_BITMAP }, - { 119, 0, ExTagPop, MIS_BITMAP }, - { 117, 0, ExTagNext, MIS_BITMAP }, - { 118, 0, ExTagPrev, MIS_BITMAP }, -}; - -HWND CreateToolBar(HWND parent, HWND owner, int id) { - HWND menu; - int i; - MENUITEM item; - HPS ps; - - menu = WinCreateWindow(parent, - WC_MENU, "menu", WS_VISIBLE | MS_ACTIONBAR, - 0, 0, 0, 0, - owner, HWND_TOP, id, 0, 0); - - //WinEnableWindowUpdate(hmenu, FALSE); - - ps = WinGetPS(menu); - for (i = 0; i < sizeof(tools)/sizeof(tools[0]); i++) { - if (tools[i].handle == 0 && (tools[i].flags & MIS_BITMAP)) { - tools[i].handle = GpiLoadBitmap(ps, NULLHANDLE, tools[i].id, 0, 0); - } - memset((void *)&item, 0, sizeof(item)); - item.iPosition = i; - item.hwndSubMenu = 0; - item.afStyle = tools[i].flags; - item.id = tools[i].cmd + 16384 + 8192; - item.afAttribute = 0; - item.hItem = tools[i].handle; - WinSendMsg(menu, MM_INSERTITEM, MPFROMP(&item), MPFROMP(0)); - } - WinReleasePS(ps); - - return menu; -} -#else -#include "pm_tool.h" -#include "pm_tool.cpp" - -#define CMD(x) ((x) + 16384 + 8192) - -ToolBarItem tools[] = -{ - // { tiBITMAP, 101, CMD(ExExitEditor), 0, 0 }, - { tiBITMAP, 102, CMD(ExFileOpen), 0, 0 }, - { tiBITMAP, 103, CMD(ExFileSave), 0, 0 }, - { tiBITMAP, 104, CMD(ExFileClose), 0, 0 }, - { tiSEPARATOR, 0, 0, 0, 0}, - { tiBITMAP, 105, CMD(ExFilePrev), 0, 0 }, - { tiBITMAP, 106, CMD(ExFileLast), 0, 0 }, - { tiBITMAP, 107, CMD(ExFileNext), 0, 0 }, - { tiSEPARATOR, 0, 0, 0, 0}, - { tiBITMAP, 108, CMD(ExUndo), 0, 0 }, - { tiBITMAP, 109, CMD(ExRedo), 0, 0 }, - { tiSEPARATOR, 0, 0, 0, 0}, - { tiBITMAP, 110, CMD(ExBlockCut), 0, 0 }, - { tiBITMAP, 111, CMD(ExBlockCopy), 0, 0 }, - { tiBITMAP, 112, CMD(ExBlockPasteStream), 0, 0 }, - { tiBITMAP, 113, CMD(ExBlockPasteColumn), 0, 0 }, - { tiSEPARATOR, 0, 0, 0, 0}, - { tiBITMAP, 114, CMD(ExCompilePrevError), 0, 0 }, - { tiBITMAP, 115, CMD(ExCompileNextError), 0, 0 }, - { tiSEPARATOR, 0, 0, 0, 0}, - { tiBITMAP, 116, CMD(ExTagFindWord), 0, 0 }, - { tiBITMAP, 119, CMD(ExTagPop), 0, 0 }, - { tiBITMAP, 117, CMD(ExTagNext), 0, 0 }, - { tiBITMAP, 118, CMD(ExTagPrev), 0, 0 }, -}; - -HWND CreateToolBar(HWND parent, HWND owner, int id) { - STARTFUNC("CreateToolBar{g_pm.cpp}"); - static int reged = 0; - HPS hps; - unsigned int i; - - if (!reged) { - RegisterToolBarClass(hab); - reged = 1; - } - - hps = WinGetPS(parent); - - for (i = 0; i < sizeof(tools)/sizeof(tools[0]); i++) - { - if (tools[i].hBitmap == 0 && (tools[i].ulType == tiBITMAP)) - tools[i].hBitmap = GpiLoadBitmap(hps, NULLHANDLE, tools[i].ulId, 0, 0); - } - - WinReleasePS(hps); - - return CreateToolBar(parent, owner, id, - sizeof(tools)/sizeof(tools[0]), - tools); -} - -#endif - -HWND CreatePMMenu(HWND parent, HWND owner, int menu, int id, int style) { - HWND hmenu; - int i; - MENUITEM item; - char s[256]; - char *p; - - hmenu = WinCreateWindow(parent, - WC_MENU, "menu", style & ~MS_CONDITIONALCASCADE, - 0, 0, 0, 0, - owner, HWND_TOP, id, 0, 0); - - //WinEnableWindowUpdate(hmenu, FALSE); - - for (i = 0; i < Menus[menu].Count; i++) { - memset((void *)&item, 0, sizeof(item)); - item.iPosition = i; - item.hwndSubMenu = 0; - if (Menus[menu].Items[i].Name) { - if (Menus[menu].Items[i].SubMenu != -1) { - item.afStyle = MIS_SUBMENU | MIS_TEXT; - item.hwndSubMenu = CreatePMMenu(HWND_DESKTOP, owner, - Menus[menu].Items[i].SubMenu, 0, - (Menus[menu].Items[i].Cmd == SUBMENU_CONDITIONAL) ? MS_CONDITIONALCASCADE : 0); - { - static ids = 1000; - item.id = ids++; - if (ids == 7000) { - ids = 1000; - } - } - } else { - item.afStyle = MIS_TEXT; - item.id = (Menus[menu].Items[i].Cmd & 0xFFFF) + 8192; // ? - } - } else { - item.afStyle = MIS_SEPARATOR; - item.id = 0; - } - item.afAttribute = 0; - item.hItem = 0; - if (Menus[menu].Items[i].Name) { - strcpy(s, Menus[menu].Items[i].Name); - p = strchr(s, '&'); - if (p) - (*p) = '~'; - p = (char *)&s; - } else { - p = 0; - } - WinSendMsg(hmenu, MM_INSERTITEM, MPFROMP(&item), MPFROMP(p)); - if (i == 0 && style == MS_CONDITIONALCASCADE) { - WinSetWindowBits(hmenu, QWL_STYLE, - MS_CONDITIONALCASCADE, MS_CONDITIONALCASCADE); - WinSendMsg(hmenu, MM_SETDEFAULTITEMID, MPFROMSHORT(item.id), 0); - } - } - //WinEnableWindowUpdate(hmenu, TRUE); - return hmenu; -} - -HWND CreatePMMainMenu(HWND parent, HWND owner, char *Name) { - int id = GetMenuId(Name); - HWND main; - - assert (id != -1); - - main = CreatePMMenu(parent, owner, id, FID_MENU, MS_ACTIONBAR); - return main; -} - -#include "pmdlg.h" - -void InsertHistory(HWND hwnd, int id, int maxlen) { - int i, count; - char *str; - count = CountInputHistory(id); - - str = (char *)malloc(maxlen + 1); - if (str == 0) - return; - - for (i = 0; i < count; i++) { - if (GetInputHistory(id, str, maxlen, i + 1) == 1) - WinInsertLboxItem(hwnd, LIT_END, str); - } - free(str); -} - -MRESULT EXPENTRY FileDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { - FILEDLG *dlg; - - dlg = (FILEDLG *)WinQueryWindowULong(hwnd, QWL_USER); - - switch (msg) { - case WM_INITDLG: - WinSendMsg(hwnd, WM_SETICON, - MPFROMLONG(WinLoadPointer(HWND_DESKTOP, 0, 1)), 0); - - InsertHistory(WinWindowFromID(hwnd, DID_FILENAME_ED), HIST_PATH, MAXPATH); - WinInvalidateRect(hwnd, 0, TRUE); - WinRestoreWindowPos("FTEPM", - ((dlg->fl & FDS_SAVEAS_DIALOG) ? "FileSaveDlg" : "FileOpenDlg"), - hwnd); - break; - case WM_COMMAND: - switch (SHORT1FROMMP(mp1)) { - case DID_OK: - WinShowWindow(hwnd, FALSE); - WinStoreWindowPos("FTEPM", - ((dlg->fl & FDS_SAVEAS_DIALOG) ? "FileSaveDlg" : "FileOpenDlg"), - hwnd); - break; - - case DID_CANCEL: - WinShowWindow(hwnd, FALSE); - WinStoreWindowPos("FTEPM", - ((dlg->fl & FDS_SAVEAS_DIALOG) ? "FileSaveDlg" : "FileOpenDlg"), - hwnd); - break; - } - break; - case WM_CLOSE: - WinShowWindow(hwnd, FALSE); - WinStoreWindowPos("FTEPM", - ((dlg->fl & FDS_SAVEAS_DIALOG) ? "FileSaveDlg" : "FileOpenDlg"), - hwnd); - break; - } - return WinDefFileDlgProc(hwnd, msg, mp1, mp2); -} - -int DLGGetFile(GView *View, const char *Prompt, unsigned int BufLen, char *FileName, int Flags) { - FILEDLG dlg; - - memset((void *)&dlg, 0, sizeof(dlg)); - - dlg.cbSize = sizeof(dlg); - dlg.fl = - /*FDS_CENTER |*/ FDS_CUSTOM | - ((Flags & GF_SAVEAS) ? FDS_SAVEAS_DIALOG : FDS_OPEN_DIALOG); - dlg.pszTitle = (char*)Prompt; - strcpy(dlg.szFullFile, FileName); - dlg.hMod = NULLHANDLE; - dlg.usDlgId = IDD_FILEDLG; - dlg.pfnDlgProc = FileDlgProc; - - if (!LONGFROMMR(WinSendMsg(View->Parent->Peer->hwndFrame, - UWM_FILEDIALOG, MPFROMP(&dlg), 0))) - return 0; - - if (dlg.lReturn == DID_OK) { - strncpy(FileName, dlg.szFullFile, BufLen); - FileName[BufLen - 1] = 0; - AddInputHistory(HIST_PATH, FileName); - return 1; - } - return 0; -} - -typedef struct { - char *Title; - int NSel; - va_list ap; - int Flags; -} ChoiceInfo; - -static int DoChoice(HWND hwndFrame, ChoiceInfo *choice) { - char msg[1024]; - char Prompt[1024]; - char *fmt; - char *p; - int rc; - HWND hwndDlg; - HWND hwndStatic; - HWND hwndButton[40]; - int cyBorder, cxBorder; - SWP swp, swp1; - int i, x, y; - ULONG flFrame = FCF_TITLEBAR | FCF_SYSMENU | FCF_DLGBORDER; - HPS ps; - int xw, yw, nx, ny; - RECTL tr; - int cp, cd; - char msgbox[100]; - int SPC = 4; - - sprintf(msgbox, "MsgBox: %s", choice->Title); - - cxBorder = WinQuerySysValue(HWND_DESKTOP, SV_CXDLGFRAME); - cyBorder = WinQuerySysValue(HWND_DESKTOP, SV_CYDLGFRAME); - - hwndDlg = WinCreateStdWindow(HWND_DESKTOP, - WS_VISIBLE, - &flFrame, - 0, - choice->Title, - 0, - 0, - 0, 0); - - WinSendMsg(hwndDlg, WM_SETICON, - MPFROMLONG(WinLoadPointer(HWND_DESKTOP, 0, 1)), 0); - - WinSetOwner(hwndDlg, hwndFrame); - - x = SPC; - for (i = 0; i < choice->NSel; i++) { - char button[60]; - strcpy(button, va_arg(choice->ap, char *)); - p = strchr(button, '&'); - if (p) - *p = '~'; - - hwndButton[i] = - WinCreateWindow(hwndDlg, - WC_BUTTON, - button, - WS_VISIBLE | BS_PUSHBUTTON | BS_AUTOSIZE | ((i == 0) ? BS_DEFAULT | WS_TABSTOP | WS_GROUP: 0), - cxBorder + x, SPC + cyBorder, 0, 0, - hwndDlg, ((i == 0) ? HWND_TOP: hwndButton[i - 1]), - 200 + i, - NULL, NULL); - - WinQueryWindowPos(hwndButton[i], &swp); - x += SPC + swp.cx; - } - - fmt = va_arg(choice->ap, char *); - vsprintf(msg, fmt, choice->ap); - strncpy((PCHAR)Prompt, msg, sizeof(Prompt)); - Prompt[sizeof(Prompt) - 1] = 0; - - hwndStatic = WinCreateWindow(hwndDlg, - WC_STATIC, - Prompt, - WS_VISIBLE | SS_TEXT | DT_TOP | DT_LEFT | DT_WORDBREAK, - 0, 0, 0, 0, - hwndDlg, HWND_TOP, - 100, - NULL, NULL); - - WinRestoreWindowPos("FTEPM", msgbox, hwndDlg); - - xw = cxScreen / 2; - if (x - SPC > xw) - xw = x - SPC; - - yw = 0; - ps = WinGetPS(hwndStatic); - - cp = 0; - for (;;) { - tr.xLeft = 0; - tr.xRight = xw; - tr.yTop = cyScreen / 2; - tr.yBottom = 0; - - cd = WinDrawText(ps, -1, (Prompt + cp), - &tr, - 0, 0, - DT_LEFT | DT_TOP | DT_WORDBREAK | DT_TEXTATTRS | - DT_QUERYEXTENT | DT_EXTERNALLEADING); - if (!cd) - break; - cp += cd; - yw += tr.yTop - tr.yBottom; - } - - WinReleasePS(ps); - - WinSetWindowPos(hwndStatic, 0, - cxBorder + SPC, - cyBorder + SPC + swp.cy + SPC, - xw, yw, SWP_MOVE | SWP_SIZE); - - WinQueryWindowPos(hwndStatic, &swp1); - WinQueryWindowPos(hwndButton[0], &swp); - - nx = cxBorder + SPC + xw + SPC + cxBorder; - ny = cyBorder + SPC + swp.cy + SPC + swp1.cy + SPC + cyTitleBar + cyBorder; - - WinQueryWindowPos(hwndDlg, &swp); - - x = swp.x; - y = swp.y + swp.cy - ny; - - if (y < cyBorder) y = - cyBorder; - if (y + ny >= cyScreen + cyBorder) y = cyScreen - ny + cyBorder; - if (x + nx >= cxScreen + cxBorder) x = cxScreen - nx + cxBorder; - if (x < -cxBorder) x = -cxBorder; - - WinSetWindowPos(hwndDlg, 0, - x, y, - nx, ny, - SWP_SIZE | SWP_SHOW | SWP_MOVE | SWP_ACTIVATE); - - WinSubclassWindow(hwndDlg, (PFNWP) WinDefDlgProc); - - if (choice->Flags & (GPC_ERROR | GPC_FATAL)) - WinAlarm(HWND_DESKTOP, WA_ERROR); - else if (choice->Flags & (GPC_CONFIRM)) - WinAlarm(HWND_DESKTOP, WA_NOTE); - else if (choice->Flags & (GPC_WARNING)) - WinAlarm(HWND_DESKTOP, WA_WARNING); - - rc = LONGFROMMR(WinSendMsg(hwndFrame, UWM_PROCESSDLG, - MPFROMLONG(hwndDlg), 0)); - - WinStoreWindowPos("FTEPM", msgbox, hwndDlg); - - WinSendMsg(hwndFrame, UWM_DESTROYHWND, MPFROMLONG(hwndDlg), 0); - if (rc == DID_CANCEL || rc == DID_ERROR) - return choice->NSel - 1; - - if (rc >= 200 && rc < choice->NSel + 200) - return rc - 200; - - return 0; -} - -/* reimplemented most of the WinMessageBox code to get store/restore position to work */ -int DLGPickChoice(GView *View, const char *ATitle, int NSel, va_list ap, int Flags) { - ChoiceInfo choice; - - choice.Title = (char *)ATitle; - choice.NSel = NSel; - choice.ap = ap; - choice.Flags = Flags; - return LONGFROMMR(WinSendMsg(View->Parent->Peer->hwndFrame, UWM_CHOICE, MPFROMP(&choice), 0)); -} - -static struct { - char *Title; - char *Entry; - int MaxLen; - int HistId; -} PromptInfo; - -MRESULT EXPENTRY PromptDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { - switch (msg) { - case WM_INITDLG: - WinSendMsg(hwnd, WM_SETICON, - MPFROMLONG(WinLoadPointer(HWND_DESKTOP, 0, 1)), 0); - - WinSendDlgItemMsg(hwnd, IDE_FIELD, EM_SETTEXTLIMIT, MPFROMLONG(PromptInfo.MaxLen), 0); - WinSetDlgItemText(hwnd, IDE_FIELD, PromptInfo.Entry); - InsertHistory(WinWindowFromID(hwnd, IDE_FIELD), PromptInfo.HistId, PromptInfo.MaxLen); - WinSetDlgItemText(hwnd, IDS_PROMPT, PromptInfo.Title); - WinSetWindowText(hwnd, PromptInfo.Title); - WinInvalidateRect(hwnd, 0, TRUE); - WinRestoreWindowPos("FTEPM", "PromptDlg", hwnd); - return WinDefDlgProc(hwnd, msg, mp1, mp2); - - case WM_COMMAND: - switch (SHORT1FROMMP(mp1)) { - case DID_OK: - WinQueryDlgItemText(hwnd, IDE_FIELD, PromptInfo.MaxLen, PromptInfo.Entry); - PromptInfo.Entry[PromptInfo.MaxLen - 1] = 0; - AddInputHistory(PromptInfo.HistId, PromptInfo.Entry); - - WinShowWindow(hwnd, FALSE); - WinStoreWindowPos("FTEPM", "PromptDlg", hwnd); - WinDismissDlg(hwnd, TRUE); - return (MRESULT)FALSE; - - case DID_CANCEL: - WinShowWindow(hwnd, FALSE); - WinStoreWindowPos("FTEPM", "PromptDlg", hwnd); - WinDismissDlg(hwnd, FALSE); - return (MRESULT)FALSE; - } - break; - case WM_CLOSE: - WinShowWindow(hwnd, FALSE); - WinStoreWindowPos("FTEPM", "PromptDlg", hwnd); - /* passthru */ - default: - return WinDefDlgProc(hwnd, msg, mp1, mp2); - } - return (MRESULT)FALSE; -} - -int DLGGetStr(GView *View, const char *Prompt, unsigned int BufLen, char *Str, int HistId, int Flags) { - assert(BufLen > 0); - PromptInfo.MaxLen = BufLen - 1; - PromptInfo.Title = (char *)Prompt; - PromptInfo.Entry = Str; - PromptInfo.HistId = HistId; - - if (LONGFROMMR(WinSendMsg(View->Parent->Peer->hwndFrame, - UWM_DLGBOX, MPFROMP(PFNWP(PromptDlgProc)), MPFROMLONG(IDD_PROMPT))) != DID_OK) - return 0; - - return 1; -} - -static SearchReplaceOptions SearchOpt; -static int ReplaceDlg = 0; - -MRESULT EXPENTRY FindDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { - switch (msg) { - case WM_INITDLG: - WinSendMsg(hwnd, WM_SETICON, - MPFROMLONG(WinLoadPointer(HWND_DESKTOP, 0, 1)), 0); - - WinSendDlgItemMsg(hwnd, IDE_FIND, EM_SETTEXTLIMIT, MPFROMLONG(MAXSEARCH), 0); - WinSetDlgItemText(hwnd, IDE_FIND, SearchOpt.strSearch); - InsertHistory(WinWindowFromID(hwnd, IDE_FIND), HIST_SEARCH, MAXSEARCH); - WinCheckButton(hwnd, IDC_IGNORECASE, (SearchOpt.Options & SEARCH_NCASE) ? 1 : 0); - WinCheckButton(hwnd, IDC_REGEXPS, (SearchOpt.Options & SEARCH_RE) ? 1 : 0); - WinCheckButton(hwnd, IDC_WORDS, (SearchOpt.Options & SEARCH_WORD) ? 1 : 0); - WinCheckButton(hwnd, IDC_BLOCK, (SearchOpt.Options & SEARCH_BLOCK) ? 1 : 0); - WinCheckButton(hwnd, IDC_GLOBAL, (SearchOpt.Options & SEARCH_GLOBAL) ? 1 : 0); - WinCheckButton(hwnd, IDC_REVERSE, (SearchOpt.Options & SEARCH_BACK) ? 1 : 0); - WinCheckButton(hwnd, IDC_ALLOCCURENCES, (SearchOpt.Options & SEARCH_ALL) ? 1 : 0); - WinCheckButton(hwnd, IDC_JOINLINE, (SearchOpt.Options & SEARCH_JOIN) ? 1: 0); - if (ReplaceDlg) { - WinSendDlgItemMsg(hwnd, IDE_REPLACE, EM_SETTEXTLIMIT, MPFROMLONG(MAXSEARCH), 0); - WinSetDlgItemText(hwnd, IDE_REPLACE, SearchOpt.strReplace); - InsertHistory(WinWindowFromID(hwnd, IDE_REPLACE), HIST_SEARCH, MAXSEARCH); - WinCheckButton(hwnd, IDC_NOPROMPTING, (SearchOpt.Options & SEARCH_NASK) ? 1 : 0); - } else { - WinCheckButton(hwnd, IDC_DELETELINE, (SearchOpt.Options & SEARCH_DELETE) ? 1 : 0); - } - WinInvalidateRect(hwnd, 0, TRUE); - WinRestoreWindowPos("FTEPM", ReplaceDlg ? "ReplaceDlg" : "FindDlg", hwnd); - return WinDefDlgProc(hwnd, msg, mp1, mp2); - - case WM_COMMAND: - switch (SHORT1FROMMP(mp1)) { - case DID_OK: - SearchOpt.ok = 1; - SearchOpt.resCount = 0; - SearchOpt.Options = 0; - strcpy(SearchOpt.strReplace, ""); - WinQueryDlgItemText(hwnd, IDE_FIND, MAXSEARCH, SearchOpt.strSearch); - SearchOpt.strSearch[MAXSEARCH - 1] = 0; - AddInputHistory(HIST_SEARCH, SearchOpt.strSearch); - - if (WinQueryButtonCheckstate(hwnd, IDC_IGNORECASE)) - SearchOpt.Options |= SEARCH_NCASE; - if (WinQueryButtonCheckstate(hwnd, IDC_REGEXPS)) - SearchOpt.Options |= SEARCH_RE; - if (WinQueryButtonCheckstate(hwnd, IDC_WORDS)) - SearchOpt.Options |= SEARCH_WORD; - if (WinQueryButtonCheckstate(hwnd, IDC_BLOCK)) - SearchOpt.Options |= SEARCH_BLOCK; - if (WinQueryButtonCheckstate(hwnd, IDC_GLOBAL)) - SearchOpt.Options |= SEARCH_GLOBAL; - if (WinQueryButtonCheckstate(hwnd, IDC_REVERSE)) - SearchOpt.Options |= SEARCH_BACK; - if (WinQueryButtonCheckstate(hwnd, IDC_ALLOCCURENCES)) - SearchOpt.Options |= SEARCH_ALL; - if (WinQueryButtonCheckstate(hwnd, IDC_JOINLINE)) - SearchOpt.Options |= SEARCH_JOIN; - - if (ReplaceDlg) { - WinQueryDlgItemText(hwnd, IDE_REPLACE, MAXSEARCH, SearchOpt.strReplace); - SearchOpt.strReplace[MAXSEARCH - 1] = 0; - AddInputHistory(HIST_SEARCH, SearchOpt.strReplace); - SearchOpt.Options |= SEARCH_REPLACE; - if (WinQueryButtonCheckstate(hwnd, IDC_NOPROMPTING)) - SearchOpt.Options |= SEARCH_NASK; - } else { - if (WinQueryButtonCheckstate(hwnd, IDC_DELETELINE)) - SearchOpt.Options |= SEARCH_DELETE; - } - - WinShowWindow(hwnd, FALSE); - WinStoreWindowPos("FTEPM", ReplaceDlg ? "ReplaceDlg" : "FindDlg", hwnd); - WinDismissDlg(hwnd, TRUE); - return (MRESULT)FALSE; - - case DID_CANCEL: - WinShowWindow(hwnd, FALSE); - WinStoreWindowPos("FTEPM", ReplaceDlg ? "ReplaceDlg" : "FindDlg", hwnd); - WinDismissDlg(hwnd, FALSE); - return (MRESULT)FALSE; - } - break; - case WM_CLOSE: - WinShowWindow(hwnd, FALSE); - WinStoreWindowPos("FTEPM", ReplaceDlg ? "ReplaceDlg" : "FindDlg", hwnd); - /* passthru */ - default: - return WinDefDlgProc(hwnd, msg, mp1, mp2); - } - return (MRESULT)FALSE; -} - -int DLGGetFind(GView *View, SearchReplaceOptions &sr) { - SearchOpt = sr; - ReplaceDlg = 0; - - if (LONGFROMMR(WinSendMsg(View->Parent->Peer->hwndFrame, UWM_DLGBOX, - PVOIDFROMMP(PFNWP(FindDlgProc)), MPFROMLONG(IDD_FIND))) != DID_OK) - return 0; - - sr = SearchOpt; - - return 1; -} - -int DLGGetFindReplace(GView *View, SearchReplaceOptions &sr) { - SearchOpt = sr; - ReplaceDlg = 1; - - if (LONGFROMMR(WinSendMsg(View->Parent->Peer->hwndFrame, UWM_DLGBOX, - PVOIDFROMMP(PFNWP(FindDlgProc)), MPFROMLONG(IDD_FINDREPLACE))) != DID_OK) - return 0; - - sr = SearchOpt; - - return 1; -} - -struct { - int vk; - TKeyCode kc; - char *name; -} lvirt[] = { -{ VK_F1, kbF1, "F1" }, -{ VK_F2, kbF2, "F2" }, -{ VK_F3, kbF3, "F3" }, -{ VK_F4, kbF4, "F4" }, -{ VK_F5, kbF5, "F5" }, -{ VK_F6, kbF6, "F6" }, -{ VK_F7, kbF7, "F7" }, -{ VK_F8, kbF8, "F8" }, -{ VK_F9, kbF9, "F9" }, -{ VK_F10, kbF10, "F10" }, -{ VK_F11, kbF11, "F11" }, -{ VK_F12, kbF12, "F12" }, - -{ VK_ESC, kbEsc, "Esc" }, -{ VK_ENTER, kbEnter | kfGray, "Enter" }, -{ VK_NEWLINE, kbEnter, "Enter" }, -{ VK_BACKSPACE, kbBackSp, "BackSp" }, -{ VK_SPACE, kbSpace, "Space" }, -{ VK_TAB, kbTab, "Tab" }, -{ VK_BACKTAB, kbTab | kfShift, "Tab" }, - -{ VK_UP, kbUp, "Up" }, -{ VK_DOWN, kbDown, "Down" }, -{ VK_LEFT, kbLeft, "Left" }, -{ VK_RIGHT, kbRight, "Right" }, -{ VK_HOME, kbHome, "Home" }, -{ VK_END, kbEnd, "End" }, -{ VK_PAGEDOWN, kbPgDn, "PgDn" }, -{ VK_PAGEUP, kbPgUp, "PgUp" }, -{ VK_INSERT, kbIns, "Ins" }, -{ VK_DELETE, kbDel, "Del" }, - -{ VK_CTRL, kbCtrl | kfModifier, "Ctrl" }, -{ VK_ALT, kbAlt | kfModifier, "Alt" }, -{ VK_ALTGRAF, kbAlt | kfModifier, "Alt" }, -{ VK_SHIFT, kbShift | kfModifier, "Shift" }, -{ VK_CAPSLOCK, kbCapsLock | kfModifier, "CapsLock" }, -{ VK_NUMLOCK, kbNumLock | kfModifier, "NumLock" }, -{ VK_SCRLLOCK, kbScrollLock | kfModifier, "ScrollLock" }, -{ VK_BREAK, kbBreak, "Break" }, -{ VK_PAUSE, kbPause, "Pause" }, -{ VK_PRINTSCRN, kbPrtScr, "PrtScr" }, -{ VK_SYSRQ, kbSysReq, "SysReq", }, -}; - -char *ConvertKey(int ch, int virt, int flags, int scan, TEvent &Event) { - int keyFlags = 0; - static char name[40]; - char keyname[40]; - TKeyCode keyCode = 0; - - strcpy(keyname, "UNKNOWN"); - - //printf("ch:%d, virt:%d, flags:%d, scan:%d\n", ch, virt, flags, scan); - - name[0] = 0; - - if (flags & KC_CTRL) - keyFlags |= kfCtrl; - if (flags & KC_ALT) - keyFlags |= kfAlt; - if (flags & KC_SHIFT) - keyFlags |= kfShift; - if ((ch != 0xE0) && ((ch & 0xFF) == 0xE0)) - keyFlags |= kfGray; - - if (keyFlags == kfAlt) {// do not produce anything on alt+XXX - switch (scan) { - case 71: case 72: case 73: - case 75: case 76: case 77: - case 79: case 80: case 81: - case 82: case 83: - return name; - } - } - if (ch != 0 && (flags & KC_CHAR)) { - switch (scan) { - case 71: case 72: case 73: - case 75: case 76: case 77: - case 79: case 80: case 81: - case 82: case 83: - virt = 0; - } - } - { - int i; - - for (i = 0; i < (sizeof(lvirt)/sizeof(lvirt[0])); i++) - if (lvirt[i].vk == virt) { - keyCode = lvirt[i].kc; - strcpy(keyname, lvirt[i].name); - break; - } - } - if (keyCode == 0) { - char c[2]; - - if( ch == 0 && scan == 86 ){ - // Fix for OS/2 bug with UK keyboard layout - // This is shift-'\' (to the left of Z), which returns 0 - ch = '|'; - } - - c[0] = char(ch); - c[1] = 0; - - if (ch == '+' && scan == 78) - keyCode = '+' | kfGray; - else if (ch == '-' && scan == 74) - keyCode = '-' | kfGray; - else if (ch == '*' && scan == 55) - keyCode = '*' | kfGray; - else if (ch == '/' && scan == 92) - keyCode = '/' | kfGray; - else { - keyCode = ch; - //if (keyFlags == kfShift) - // keyFlags = 0; - } - - keyname[0] = 0; - - if (keyCode & kfGray) - strcpy(keyname, "G+"); - - strcat(keyname, c); - } - - if ((keyFlags & (kfAlt | kfSpecial | kfGray)) == kfAlt) { - if (keyCode >= 'a' && keyCode <= 'z') - keyCode -= 'a' - 'A'; - } - - if ((keyFlags & (kfCtrl | kfAlt | kfSpecial | kfGray)) == kfCtrl) { - if (keyCode >= 'a' && keyCode < 'a' + 32) - keyCode -= 'a' - 1; - else if (keyCode >= 'A' && keyCode < 'A' + 32) - keyCode -= 'A' - 1; - } - - if (keyFlags & kfCtrl) - if (keyCode < 32) - keyCode += 64; - - keyCode |= keyFlags; - - if (keyCode & kfKeyUp) - strcat(name, "UP "); - else - strcat(name, "DN "); - if (keyCode & kfAlt) - strcat(name, "A+"); - if (keyCode & kfCtrl) - strcat(name, "C+"); - if (keyCode & kfGray) - strcat(name, "G+"); - if (keyCode & kfShift) - strcat(name, "S+"); - strcat(name, keyname); - - Event.What = evKeyDown; - if (flags & KC_KEYUP) { - keyFlags |= kfKeyUp; - Event.What = evKeyUp; - } - Event.Key.Code = keyCode; - return name; -} - -MRESULT CreateChild(HWND parent, GViewPeer *peer, PMData *pmData) { - PMPTR ptr; - - ptr.len = sizeof(PMPTR); - ptr.p = pmData; - - peer->hwndView = WinCreateWindow(parent, - szClient, "FTE", - WS_VISIBLE, 0, 0, 0, 0, - NULLHANDLE, HWND_TOP, FID_CLIENT, - (void *)&ptr, NULL); - - assert(peer->hwndView != NULLHANDLE); - - peer->hwndVscroll = WinCreateWindow(parent, - WC_SCROLLBAR, "", - WS_VISIBLE | SBS_VERT | SBS_AUTOTRACK, 0, 0, 0, 0, - peer->hwndView, HWND_TOP, 0, - (void *)&ptr, NULL); - - assert(peer->hwndVscroll != NULLHANDLE); - - peer->hwndHscroll = WinCreateWindow(parent, - WC_SCROLLBAR, "", - WS_VISIBLE | SBS_HORZ | SBS_AUTOTRACK, 0, 0, 0, 0, - peer->hwndView, HWND_TOP, 0, - (void *)&ptr, NULL); - - assert(peer->hwndHscroll != NULLHANDLE); - - return (MRESULT)TRUE; -} - -BOOL CalcFrameSWP(HWND hwnd, PSWP pswp, BOOL bFrame) { - BOOL bSuccess; - RECTL rcl; - - rcl.xLeft = pswp->x; - rcl.yBottom = pswp->y; - rcl.xRight = pswp->x + pswp->cx; - rcl.yTop = pswp->y + pswp->cy; - - bSuccess = WinCalcFrameRect(hwnd, &rcl, bFrame); - - pswp->x = rcl.xLeft; - pswp->y = rcl.yBottom; - pswp->cx = rcl.xRight - rcl.xLeft; - pswp->cy = rcl.yTop - rcl.yBottom; - - return bSuccess; -} - -MRESULT EXPENTRY FrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { - GFramePeer *peer = (GFramePeer *) WinQueryWindowULong(hwnd, QWL_USER); - - if (peer) switch (msg) { - case UWM_DESTROY: - WinDestroyWindow(hwnd); - return 0; - - case UWM_DESTROYHWND: - WinDestroyWindow(LONGFROMMP(mp1)); - return 0; - - case UWM_FILEDIALOG: - return MRFROMLONG(WinFileDlg(HWND_DESKTOP, hwnd, (FILEDLG *)PVOIDFROMMP(mp1))); - - case UWM_DLGBOX: - return MRFROMLONG(WinDlgBox(HWND_DESKTOP, hwnd, - PFNWP(PVOIDFROMMP(mp1)), 0, LONGFROMMP(mp2), NULL)); - - case UWM_PROCESSDLG: - return MRFROMLONG(WinProcessDlg(HWNDFROMMP(mp1))); - - case UWM_CHOICE: - return MRFROMLONG(DoChoice(hwnd, (ChoiceInfo *)PVOIDFROMMP(mp1))); - - case UWM_CREATECHILD: - //DosBeep(2500, 1000); - return CreateChild(hwnd, (GViewPeer *)PVOIDFROMMP(mp1), (PMData *)PVOIDFROMMP(mp2)); - - case WM_TRANSLATEACCEL: - // check for keys not to be translated - { - QMSG *qmsg = (QMSG *)mp1; - USHORT vk = SHORT2FROMMP((qmsg->mp2)); - USHORT fl = (USHORT)(SHORT1FROMMP((qmsg->mp1)) & (KC_ALT | KC_SHIFT | KC_CTRL | KC_KEYUP)); - USHORT ch = SHORT1FROMMP((qmsg->mp2)); - - if ((vk == VK_MENU || vk == VK_F1) && fl == 0 || - vk == VK_NEWLINE && fl == KC_ALT || - vk == VK_ENTER && fl == KC_ALT || - vk == VK_SPACE && fl == KC_ALT) - return (MRESULT)FALSE; - - if ((ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z') && - (fl & KC_ALT)) - return (MRESULT)FALSE; - - if (PMDisableAccel) - if (fl & KC_ALT) - if (vk >= VK_F1 && vk <= VK_F24) - return (MRESULT)FALSE; - - } - break; - - /*case WM_CALCFRAMERECT: - { - PRECTL rcl = (PRECTL)PVOIDFROMMP(mp1); - USHORT isFrame = SHORT1FROMMP(mp2); - BOOL fSuccess = LONGFROMMR(peer->oldFrameProc(hwnd, msg, mp1, mp2)); - - if (ShowToolBar && fSuccess) { - SWP swpToolBar; - HWND hwndToolBar = WinWindowFromID(hwnd, FID_MTOOLBAR); - - WinQueryWindowPos(hwndToolBar, &swpToolBar); - WinSendMsg(hwndToolBar, - WM_ADJUSTWINDOWPOS, - MPFROMP(&swpToolBar), - MPARAM(0)); - - if (isFrame) - rcl->yTop -= swpToolBar.cy; - else - rcl->yTop += swpToolBar.cy; - } - - return MRFROMLONG(fSuccess); - }*/ - - case WM_QUERYTRACKINFO: - { - MRESULT mr; - - mr = peer->oldFrameProc(hwnd, msg, mp1, mp2); - - if (mr == (MRESULT)FALSE) - return mr; - - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - if ((SHORT1FROMMP(mp1) & TF_MOVE) != TF_MOVE) { - PTRACKINFO pti; - - pti = (PTRACKINFO) PVOIDFROMMP(mp2); - pti->cxGrid = peer->Frame->Top->Peer->pmData->cxChar; - pti->cyGrid = peer->Frame->Top->Peer->pmData->cyChar; - pti->cxKeyboard = peer->Frame->Top->Peer->pmData->cxChar; - pti->cyKeyboard = peer->Frame->Top->Peer->pmData->cyChar; - pti->fs |= TF_GRID; - } - DosReleaseMutexSem(hmtxPMData); - return mr; - } - - case WM_MINMAXFRAME: - { - PSWP pswp = (PSWP) PVOIDFROMMP(mp1); - - if (pswp->fl & SWP_MAXIMIZE) { - GView *v; - int cnt; - SWP swpMenu; - SWP swpToolBar; - HWND hwndMenu = WinWindowFromID(hwnd, FID_MENU); - HWND hwndToolBar = WinWindowFromID(hwnd, FID_MTOOLBAR); - - WinQueryWindowPos(hwndMenu, &swpMenu); - swpMenu.x = 0; - swpMenu.y = 0; - swpMenu.cx = cxScreen - 2 * cxBorder; - swpMenu.cy = cyScreen; - WinSendMsg(hwndMenu, - WM_ADJUSTWINDOWPOS, - MPFROMP(&swpMenu), - MPARAM(0)); - - if (ShowToolBar) { - WinQueryWindowPos(hwndToolBar, &swpToolBar); - swpToolBar.x = 0; - swpToolBar.y = 0; - swpToolBar.cx = cxScreen - 2 * cxBorder; - swpToolBar.cy = cyScreen; - WinSendMsg(hwndToolBar, - WM_ADJUSTWINDOWPOS, - MPFROMP(&swpToolBar), - MPARAM(0)); - } else { - swpToolBar.cy = 0; - } - - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - - pswp->cx = cxScreen - cxScrollBar; - pswp->cy = cyScreen - cyTitleBar - swpMenu.cy - swpToolBar.cy; - - cnt = 0; - v = peer->Frame->Top; - while (v) { - cnt++; - v = v->Prev; - if (v == peer->Frame->Top) break; - } - - pswp->cy -= cnt * cyScrollBar; - - if (pswp->cy < 0) pswp->cy = 0; - - if (v) { - pswp->cx /= v->Peer->pmData->cxChar; - if (pswp->cx > MAXXSIZE) - pswp->cx = MAXXSIZE; - pswp->cx *= v->Peer->pmData->cxChar; - - pswp->cy /= v->Peer->pmData->cyChar; - if (pswp->cy > MAXYSIZE) - pswp->cy = MAXYSIZE; - pswp->cy *= v->Peer->pmData->cyChar; - } - - pswp->cy += cnt * cyScrollBar; - - pswp->cx += cxBorder * 2 + cxScrollBar; - pswp->cy += cyBorder * 2 + cyTitleBar + swpMenu.cy + swpToolBar.cy; - - pswp->y = cyScreen - pswp->cy + cyBorder; - - DosReleaseMutexSem(hmtxPMData); - return (MRESULT)FALSE; - } - } - break; - - case WM_ADJUSTWINDOWPOS: - { - PSWP pswp = (PSWP) PVOIDFROMMP(mp1); - - if (pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_MAXIMIZE)) { - GView *v; - int cnt; - SWP swpToolBar; - - if (pswp->cx < 0 || pswp->cy <= cyTitleBar + 2 * cyBorder) - break; - - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - //printf("Before 1: %d %d | %d %d\n", pswp->cx, pswp->x, pswp->cy, pswp->y); - CalcFrameSWP(hwnd, pswp, TRUE); - - if (ShowToolBar) { - HWND hwndToolBar = WinWindowFromID(hwnd, FID_MTOOLBAR); - - WinQueryWindowPos(hwndToolBar, &swpToolBar); - swpToolBar.x = 0; - swpToolBar.y = 0; - swpToolBar.cx = pswp->cx; - swpToolBar.cy = pswp->cy; - WinSendMsg(hwndToolBar, - WM_ADJUSTWINDOWPOS, - MPFROMP(&swpToolBar), - MPARAM(0)); - } else { - swpToolBar.cy = 0; - } - - pswp->cy -= swpToolBar.cy; - - pswp->cx -= cxScrollBar; - - cnt = 0; - v = peer->Frame->Top; - while (v) { - cnt++; - v = v->Prev; - if (v == peer->Frame->Top) break; - } - - pswp->cy -= cnt * cyScrollBar; - //if (pswp->cy < 0) pswp->cy = 0; - - if (v) { - pswp->cx /= v->Peer->pmData->cxChar; - //if (pswp->cx < 8) pswp->cx = 8; - if (pswp->cx > MAXXSIZE) - pswp->cx = MAXXSIZE; - pswp->cx *= v->Peer->pmData->cxChar; - - pswp->cy /= v->Peer->pmData->cyChar; - //if (pswp->cy < cnt * 2) pswp->cy = cnt * 2; - if (pswp->cy > MAXYSIZE) - pswp->cy = MAXYSIZE; - pswp->cy *= v->Peer->pmData->cyChar; - } - - pswp->cy += cnt * cyScrollBar; - - pswp->cx += cxScrollBar; - pswp->cy += swpToolBar.cy; - CalcFrameSWP(hwnd, pswp, FALSE); - DosReleaseMutexSem(hmtxPMData); - } - } - break; - - case WM_QUERYFRAMECTLCOUNT: - { - SHORT sCount = SHORT1FROMMR(peer->oldFrameProc(hwnd, msg, mp1, mp2)); - GView *v; - - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - v = peer->Frame->Top; - while (v) { - sCount += (SHORT)3; - v = v->Prev; - if (v == peer->Frame->Top) break; - } - if (ShowToolBar) - sCount++; - DosReleaseMutexSem(hmtxPMData); - return MRESULT(sCount - 1); - } - - case WM_FORMATFRAME: - { - SHORT sCount = SHORT1FROMMR(peer->oldFrameProc(hwnd, msg, mp1, mp2)); - PSWP pswp; - HWND Bhwnd; - GView *v; - int x, w, h, fl, y; - int ctl, cnt; - int Hy, H1, yPos; - HWND hwndToolBar = WinWindowFromID(hwnd, FID_MTOOLBAR); - SWP swpToolBar; - PRECTL prcl; - - pswp = (PSWP) mp1; - prcl = (PRECTL) mp2; - - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - sCount--; - - cnt = 0; - v = peer->Frame->Top; - while (v) { - cnt++; - v = v->Prev; - if (v == peer->Frame->Top) break; - } - - if (cnt == 0) { - DosReleaseMutexSem(hmtxPMData); - return MRFROMSHORT(sCount); - } - - fl = pswp[sCount].fl; - x = pswp[sCount].x; - y = pswp[sCount].y; - w = pswp[sCount].cx; - h = pswp[sCount].cy; - Bhwnd = pswp[sCount].hwndInsertBehind; - - if (ShowToolBar) { - swpToolBar = pswp[sCount]; - WinSendMsg(hwndToolBar, - WM_ADJUSTWINDOWPOS, - MPFROMP(&swpToolBar), - MPARAM(0)); - - - pswp[sCount].hwndInsertBehind = Bhwnd; - Bhwnd = pswp[sCount].hwnd = hwndToolBar; - pswp[sCount].fl = fl; - pswp[sCount].x = cxBorder; - pswp[sCount].cx = w; - - if (ShowToolBar == 1) { - pswp[sCount].y = y + h - swpToolBar.cy; - pswp[sCount].cy = swpToolBar.cy; - - h -= swpToolBar.cy; - if (prcl) - prcl->yTop -= swpToolBar.cy; - } else if (ShowToolBar == 2) { - pswp[sCount].y = y; - pswp[sCount].cy = swpToolBar.cy; - - y += swpToolBar.cy; - h -= swpToolBar.cy; - if (prcl) - prcl->yBottom += swpToolBar.cy; - } - sCount++; - } - - ctl = 0; - v = peer->Frame->Top; - - H1 = (h - cyScrollBar * cnt) / cnt; - H1 /= v->Peer->pmData->cyChar; - H1 *= v->Peer->pmData->cyChar; - - yPos = 0; - - while (v) { - v = v->Prev; - if (ctl == cnt - 1) { - Hy = h - yPos - cyScrollBar; - Hy /= v->Peer->pmData->cyChar; - Hy *= v->Peer->pmData->cyChar; - } else { - Hy = H1; - } - - pswp[sCount].fl = fl; - pswp[sCount].hwndInsertBehind = Bhwnd; - Bhwnd = pswp[sCount].hwnd = v->Peer->hwndView; - pswp[sCount].x = x; - pswp[sCount].cx = w - cxScrollBar; - pswp[sCount].y = yPos + y + cyScrollBar; - pswp[sCount].cy = Hy; - - sCount++; - - pswp[sCount].fl = fl; - pswp[sCount].hwndInsertBehind = Bhwnd; - Bhwnd = pswp[sCount].hwnd = v->Peer->hwndHscroll; - pswp[sCount].x = x; - pswp[sCount].cx = w - cxScrollBar; - pswp[sCount].y = yPos + y; - pswp[sCount].cy = cyScrollBar; - - yPos += cyScrollBar; - - sCount++; - - pswp[sCount].fl = fl; - pswp[sCount].hwndInsertBehind = Bhwnd; - Bhwnd = pswp[sCount].hwnd = v->Peer->hwndVscroll; - pswp[sCount].x = x + w - cxScrollBar; - pswp[sCount].cx = cxScrollBar; - pswp[sCount].y = yPos - cyScrollBar + y; - pswp[sCount].cy = Hy + cyScrollBar; - - yPos += Hy; - - sCount++; - - ctl++; - if (v == peer->Frame->Top) break; - } - DosReleaseMutexSem(hmtxPMData); - return MRFROMSHORT(sCount); - } - } - return peer->oldFrameProc(hwnd, msg, mp1, mp2); -} - -/*MRESULT EXPENTRY SizerWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { - switch (msg) { - case WM_CREATE: - break; - case WM_DESTROY: - break; - - case WM_BUTTON1DOWN: - case WM_BUTTON1UP: - case WM_MOUSEMOVE: - break; - - case WM_PAINT: - { - SWP swp; - HPS hps; - RECTL rc; - POINTL pt; - - - WinQueryWindowPos(hwnd, &swp); - hps = WinBeginPaint(hwnd, (HPS)NULL, &rc); - GpiSetColor(hps, CLR_GRAY); - GpiSetBackColor(hps, CLR_PALEGRAY); - if (swp.cy > 2 && swp.cx > 2) { - ptl.x = 1; - ptl.y = 1; - GpiMove(hps, &ptl); - ptl.x += swp.cx - 2; - ptl.y += swp.cy - 2; - GpiBox(hps, DRO_FILL, &ptl, 0, 0); - } - GpiSetColor(hps, CLR_WHITE); - ptl.x = 0; - ptl.y = 0; - GpiMove(hps, &ptl); - ptl.y += swp.cy; - GpiLine(hps, &ptl); - ptl.x += swp.cx; - GpiLine(hps, &ptl); - GpiSetColor(hps, CLR_GRAY); - ptl.y = 0; - GpiLine(hps, &ptl); - ptl.x = 0; - GpiLine(hps, &ptl); - - WinEndPaint(hps); - } - break; - } - return WinDefWndProc(hwnd, msg, mp1, mp2); -} -*/ -MRESULT EXPENTRY AVIOWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { - PMPTR *ptr = 0; - PMData *pmData = (PMData *)WinQueryWindowULong(hwnd, QWL_USER); - BYTE bBlank[2] = " "; - SHORT cxClient, cyClient; - HDC hdc; - SIZEL sizl; - PDRAGINFO pDragInfo; - PDRAGITEM pDragItem; - - switch (msg) { - case WM_CREATE: - ptr = (PMPTR *)mp1; - pmData = ptr ? (PMData *)ptr->p : 0; - assert(pmData != 0); - assert(WinSetWindowULong(hwnd, QWL_USER, (ULONG)pmData) == TRUE); - - hdc = WinOpenWindowDC(hwnd); - VioCreatePS(&pmData->hvps, MAXYSIZE, MAXXSIZE, 0, 1, 0); - sizl.cx = sizl.cy = 0; - pmData->hps = GpiCreatePS(hab, hdc, &sizl, - PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC); - VioAssociate(hdc, pmData->hvps); - if (WindowFont[0] != 0) { - int x, y; - - if (sscanf(WindowFont, "%dx%d", &x, &y) == 2) - VioSetDeviceCellSize((SHORT)y, (SHORT)x, pmData->hvps); - } - VioGetDeviceCellSize(&pmData->cyChar, &pmData->cxChar, pmData->hvps); - bBlank[1] = hcPlain_Background; - VioScrollUp(0, 0, -1, -1, -1, bBlank, pmData->hvps); - return 0; - - case WM_DESTROY: - VioAssociate(NULLHANDLE, pmData->hvps); - VioDestroyPS(pmData->hvps); - GpiDestroyPS(pmData->hps); - pmData->Peer->pmData = 0; - return 0; - - case UWM_DESTROY: - { - GViewPeer *Peer = pmData->Peer; - WinDestroyWindow(Peer->hwndVscroll); - WinDestroyWindow(Peer->hwndHscroll); - WinDestroyWindow(Peer->hwndView); - } - return 0; - - case WM_ERASEBACKGROUND: - return (MRESULT) FALSE; - - case WM_CLOSE: - if (WinPostMsg(pmData->hwndWorker, msg, mp1, mp2) == FALSE) { - WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, - "WinPostMsg failed, WM_CLOSE", "FTE/PM", - 0, MB_OK | MB_ERROR | MB_APPLMODAL | MB_MOVEABLE); - } - return (MRESULT) FALSE; - - case WM_SIZE: - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - { - GViewPeer *Peer = pmData->Peer; - - cxClient = SHORT1FROMMP(mp2); - cyClient = SHORT2FROMMP(mp2); - WinDefAVioWindowProc(hwnd, (USHORT)msg, (ULONG)mp1, (ULONG)mp2); - - if (cxClient <= pmData->cxChar || cyClient <= pmData->cyChar || reportSize == 0) { - DosReleaseMutexSem(hmtxPMData); - break; - } - - Peer->wW = cxClient / pmData->cxChar; - Peer->wH = cyClient / pmData->cyChar; - if (hwnd == WinQueryFocus(HWND_DESKTOP)) { - WinDestroyCursor(hwnd); - WinCreateCursor(hwnd, - pmData->cxChar * Peer->cX, - pmData->cyChar * (Peer->wH - Peer->cY - 1) + - pmData->cyChar * (100 - Peer->cEnd) / 100, - pmData->cxChar, pmData->cyChar * (Peer->cEnd - Peer->cStart) / 100, - CURSOR_TYPE, - NULL); - WinShowCursor(hwnd, TRUE); - } - //DosBeep(500, 100); - if (WinPostMsg(pmData->hwndWorker, msg, mp1, mp2) == FALSE) { - WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, - "WinPostMsg failed, WM_SIZE", "FTE/PM", - 0, MB_OK | MB_ERROR | MB_APPLMODAL | MB_MOVEABLE); - } - } - DosReleaseMutexSem(hmtxPMData); - break; - - case WM_ACTIVATE: - case WM_SETSELECTION: - if (WinPostMsg(pmData->hwndWorker, msg, mp1, mp2) == FALSE) { - WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, - "WinPostMsg failed, WM_SETFOCUS", "FTE/PM", - 0, MB_OK | MB_ERROR | MB_APPLMODAL | MB_MOVEABLE); - } - break; - - case WM_SETFOCUS: - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - { - GViewPeer *Peer = pmData->Peer; - - if (SHORT1FROMMP(mp2)) { - WinCreateCursor(hwnd, - pmData->cxChar * Peer->cX, - pmData->cyChar * (Peer->wH - Peer->cY - 1) + - pmData->cyChar * (100 - Peer->cEnd) / 100, - pmData->cxChar, pmData->cyChar * (Peer->cEnd - Peer->cStart) / 100, - CURSOR_TYPE, - NULL); - WinShowCursor(hwnd, TRUE); - Peer->wState |= sfFocus; - } else { - WinDestroyCursor(hwnd); - Peer->wState &= ~sfFocus; - } - } - DosReleaseMutexSem(hmtxPMData); - if (WinPostMsg(pmData->hwndWorker, msg, mp1, mp2) == FALSE) { - WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, - "WinPostMsg failed, WM_SETFOCUS", "FTE/PM", - 0, MB_OK | MB_ERROR | MB_APPLMODAL | MB_MOVEABLE); - } - break; - - case WM_VSCROLL: - if (WinPostMsg(pmData->hwndWorker, msg, mp1, mp2) == FALSE) { - WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, - "WinPostMsg failed, WM_VSCROLL", "ftePM", - 0, MB_OK | MB_ERROR | MB_APPLMODAL | MB_MOVEABLE); - } - return 0; - - case WM_HSCROLL: - if (WinPostMsg(pmData->hwndWorker, msg, mp1, mp2) == FALSE) { - WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, - "WinPostMsg failed, WM_HSCROLL", "ftePM", - 0, MB_OK | MB_ERROR | MB_APPLMODAL | MB_MOVEABLE); - } - return 0; - - case WM_COMMAND: - if (SHORT1FROMMP(mp1) >= 8192) { - if (WinPostMsg(pmData->hwndWorker, msg, mp1, mp2) == FALSE) { - WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, - "WinPostMsg failed, WM_COMMAND", "ftePM", - 0, MB_OK | MB_ERROR | MB_APPLMODAL | MB_MOVEABLE); - } - } - break; - - case WM_CHAR: - if (WinPostMsg(pmData->hwndWorker, msg, mp1, mp2) == FALSE) { - WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, - "WinPostMsg failed, WM_CHAR", "ftePM", - 0, MB_OK | MB_ERROR | MB_APPLMODAL | MB_MOVEABLE); - } - return (MRESULT) TRUE; - - case WM_MOUSEMOVE: - { - long b; - b = 0; - if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000) - b |= 1; - if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000) - b |= 2; - if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000) - b |= 4; - if (b == 0) - break; - } - case WM_BUTTON1DOWN: - case WM_BUTTON1DBLCLK: - case WM_BUTTON1UP: - case WM_BUTTON2DOWN: - case WM_BUTTON2DBLCLK: - case WM_BUTTON2UP: - case WM_BUTTON3DOWN: - case WM_BUTTON3DBLCLK: - case WM_BUTTON3UP: - if (WinPostMsg(pmData->hwndWorker, msg, mp1, mp2) == FALSE) { - WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, - "WinPostMsg failed, WM_MOUSE", "ftePM", - 0, MB_OK | MB_ERROR | MB_APPLMODAL | MB_MOVEABLE); - } - break; - - case WM_PAINT: - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - { - GViewPeer *Peer = pmData->Peer; - - WinBeginPaint(hwnd, pmData->hps, NULL); - if (Peer->wH > 0 && Peer->wH <= MAXYSIZE && - Peer->wW > 0 && Peer->wW <= MAXXSIZE) - VioShowBuf(0, (SHORT)(MAXXSIZE * Peer->wH * 2), pmData->hvps); - WinEndPaint(pmData->hps); - } - DosReleaseMutexSem(hmtxPMData); - return 0; - - case DM_DRAGOVER: - { - char buf[1024] = ""; - pDragInfo = (PDRAGINFO) mp1; - DrgAccessDraginfo( pDragInfo ); - pDragItem = DrgQueryDragitemPtr( pDragInfo, 0 ); - - // Don't accept multi select and non-file - DrgQueryNativeRMF(pDragItem, sizeof(buf), buf); - - if (pDragInfo->cditem > 1 || strstr(buf, "DRM_OS2FILE") == 0) - return (MRFROM2SHORT((DOR_NEVERDROP), (DO_UNKNOWN))); - else - return (MRFROM2SHORT((DOR_DROP), (DO_UNKNOWN))); - } - - case DM_DROP: - { - pDragInfo = (PDRAGINFO)mp1; - DrgAccessDraginfo(pDragInfo); - pDragItem = DrgQueryDragitemPtr(pDragInfo, 0); - - DrgQueryStrName(pDragItem->hstrContainerName,100,dragname); - DrgQueryStrName(pDragItem->hstrSourceName,100,dragname+strlen(dragname)); - WinPostMsg(pmData->hwndWorker, UWM_DROPPEDFILE, 0, 0); - } - break; - } - return WinDefWindowProc(hwnd, msg, mp1, mp2); -} - -MRESULT EXPENTRY ObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { - switch (msg) { - case WM_CREATE: - PMPTR *ptr = (PMPTR *)mp1; - GViewPeer *peer = ptr ? (GViewPeer *)ptr->p : 0; - assert(WinSetWindowULong(hwnd, QWL_USER, (ULONG)peer) == TRUE); - break; - } - return WinDefWindowProc(hwnd, msg, mp1, mp2); -} - -MRESULT EXPENTRY CreatorWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { - switch (msg) { - case UWM_CREATEWORKER: - { - GViewPeer *peer = (GViewPeer *)mp1; - PMData *pmData = (PMData *)mp2; - PMPTR ptr; - - ptr.len = sizeof(ptr); - ptr.p = peer; - - //DosBeep(2500, 1000); - - peer->hwndWorker = pmData->hwndWorker = - WinCreateWindow(HWND_OBJECT, - szObject, - "Worker", - 0, - 0, 0, 0, 0, - HWND_OBJECT, HWND_TOP, - 0, (void *)&ptr, NULL); - - assert(peer->hwndWorker != NULLHANDLE); - - return (MRESULT)TRUE; - } - - case UWM_CREATEFRAME: - { - GFramePeer *peer = (GFramePeer *)PVOIDFROMMP(mp1); - FRAMECDATA fcdata; - - fcdata.cb = sizeof(FRAMECDATA); - fcdata.flCreateFlags = flFrame; - fcdata.hmodResources = 0; - fcdata.idResources = 1; - - //DosBeep(2500, 1000); - - peer->hwndFrame = WinCreateWindow(HWND_DESKTOP, - WC_FRAME, NULL, 0, 0, 0, 0, 0, - hwndCreatorUser, HWND_TOP, 1, - &fcdata, NULL); - - assert(peer->hwndFrame != NULLHANDLE); - - WinSetWindowULong(peer->hwndFrame, QWL_USER, (ULONG)peer); - - peer->oldFrameProc = WinSubclassWindow(peer->hwndFrame, (PFNWP) FrameWndProc); - - if (ShowToolBar) { - peer->hwndToolBar = CreateToolBar(peer->hwndFrame, peer->hwndFrame, FID_MTOOLBAR); - assert(peer->hwndToolBar != NULLHANDLE); - } - - - return (MRESULT)TRUE; - } - - case UWM_CREATEMAINMENU: - { - GFramePeer *peer = (GFramePeer *)mp1; - char *Menu = (char *)PVOIDFROMMP(mp2); - HWND hwnd, hwndMenu; - char font[256]; - ULONG AttrFound = 0; - LONG len = -1; - - hwnd = WinWindowFromID(peer->hwndFrame, FID_MENU); - if (hwnd != NULLHANDLE) { - if (len == -1) { - AttrFound = 0; - len = WinQueryPresParam(hwnd, PP_FONTNAMESIZE, PP_FONTHANDLE, &AttrFound, sizeof(font), font, 0); - } - WinDestroyWindow(hwnd); - } - - hwndMenu = CreatePMMainMenu(peer->hwndFrame, peer->hwndFrame, Menu); - - if (len > 0) - WinSetPresParam(hwndMenu, AttrFound, len, font); - WinSendMsg(peer->hwndFrame, WM_UPDATEFRAME, MPFROMLONG(FCF_MENU), 0); - - return (MRESULT)hwndMenu; - } - - case UWM_CREATEPOPUPMENU: - { - GFramePeer *peer = (GFramePeer *)mp1; - int MenuId = LONGFROMMP(mp2); - - static HWND hwnd = 0; - POINTL ptl; - char font[256]; - ULONG AttrFound = 0; - ULONG len; - - if (hwnd != 0) { - WinDestroyWindow(hwnd); - hwnd = 0; - } - - hwnd = CreatePMMenu(HWND_DESKTOP, peer->hwndFrame, MenuId, 0, 0); - - WinQueryMsgPos(hab, &ptl); - - len = WinQueryPresParam(peer->menuBar, PP_FONTNAMESIZE, PP_FONTHANDLE, &AttrFound, sizeof(font), font, 0); - if (len > 0) - WinSetPresParam(hwnd, AttrFound, len, font); - - WinPopupMenu(HWND_DESKTOP, peer->Frame->Active->Peer->hwndView, hwnd, - ptl.x, ptl.y, - 0, - PU_HCONSTRAIN | PU_VCONSTRAIN | - PU_NONE | PU_KEYBOARD | - PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 | PU_MOUSEBUTTON3); - - return (MRESULT)TRUE; - } - } - return WinDefWindowProc(hwnd, msg, mp1, mp2); -} - -int ConGetEvent(TEventMask EventMask, TEvent *Event, int WaitTime, int Delete, GView **view) { - QMSG qmsg; - GFrame *f; - GView *v; - - if (view) - *view = 0; - - if (EventBuf.What != evNone) { - *Event = EventBuf; - if (Delete) EventBuf.What = evNone; - return 0; - } - EventBuf.What = evNone; - Event->What = evNone; - - //DosBeep(800, 10); - - if (WaitTime != -1) { - if (WinPeekMsg(hab, &qmsg, NULLHANDLE, 0, 0, PM_NOREMOVE) == FALSE) - return 0; - } - if (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0) == FALSE) - return -1; - - //DosBeep(800, 10); - - f = frames; - while (f) { - v = f->Top; - while (frames && v) { - if (v->Peer->hwndWorker == qmsg.hwnd) { - if (FocusCapture && v != FocusCapture) { - WinSetFocus(HWND_DESKTOP, FocusCapture->Peer->hwndView); - frames = f; - break; - } - if (view) - *view = v; - switch (qmsg.msg) { - /*case WM_ACTIVATE: - case WM_SETSELECTION: - if (SHORT1FROMMP(qmsg.mp1) == TRUE) { - if (!v->IsActive()) - v->Parent->SelectView(v); - DosBeep(800, 10); - return 0; - } - break;*/ - case WM_SETFOCUS: - if (SHORT1FROMMP(qmsg.mp2) == TRUE) { - if (!v->IsActive()) - v->Parent->SelectView(v); - //DosBeep(800, 10); - return 0; - } - break; - - case UWM_NOTIFY: - //DosBeep(200, 200); - Event->What = evNotify; - Event->Msg.View = v; - Event->Msg.Model = (EModel *)qmsg.mp1; - Event->Msg.Command = cmPipeRead; - Event->Msg.Param1 = (long)qmsg.mp2; - frames = f; - return 0; - - case UWM_DROPPEDFILE: - if (!v->IsActive()) - v->Parent->SelectView(v); - Event->What = evCommand; - Event->Msg.View = v; - Event->Msg.Command = cmDroppedFile; - Event->Msg.Param1 = 0; - Event->Msg.Param2 = &dragname; - frames = f; - return 0; - - case WM_SIZE: - frames = f; - //DosBeep(500, 500); - v->Resize(v->Peer->wW, v->Peer->wH); - return 0; - - case WM_VSCROLL: - //DosBeep(200, 2000); - if (!v->IsActive()) - v->Parent->SelectView(v); - Event->What = evNone; - Event->Msg.View = v; - Event->Msg.Param1 = 0; - Event->Msg.Param2 = 0; - switch (SHORT2FROMMP(qmsg.mp2)) { - case SB_LINEUP: - Event->What = evCommand; - Event->Msg.Command = cmVScrollUp; - break; - - case SB_LINEDOWN: - Event->What = evCommand; - Event->Msg.Command = cmVScrollDown; - break; - - case SB_PAGEUP: - Event->What = evCommand; - Event->Msg.Command = cmVScrollPgUp; - break; - - case SB_PAGEDOWN: - Event->What = evCommand; - Event->Msg.Command = cmVScrollPgDn; - break; - - case SB_ENDSCROLL: - WinSetFocus(HWND_DESKTOP, v->Parent->Active->Peer->hwndView); - /* no break */ - case SB_SLIDERPOSITION: - case SB_SLIDERTRACK: - { - SHORT x = SHORT1FROMMP(qmsg.mp2); - - if (x != 0) { - Event->What = evCommand; - Event->Msg.Command = cmVScrollMove; - if (v->Peer->sbVtotal > 32000) - Event->Msg.Param1 = (x - 1) * v->Peer->sbVtotal / 32000; - else - Event->Msg.Param1 = x - 1; - } - } - break; - } - return 0; - - case WM_HSCROLL: - //DosBeep(800, 2000); - if (!v->IsActive()) - v->Parent->SelectView(v); - Event->What = evNone; - Event->Msg.View = v; - Event->Msg.Param1 = 0; - Event->Msg.Param2 = 0; - switch (SHORT2FROMMP(qmsg.mp2)) { - case SB_LINEUP: - Event->What = evCommand; - Event->Msg.Command = cmHScrollLeft; - break; - - case SB_LINEDOWN: - Event->What = evCommand; - Event->Msg.Command = cmHScrollRight; - break; - - case SB_PAGEUP: - Event->What = evCommand; - Event->Msg.Command = cmHScrollPgLt; - break; - - case SB_PAGEDOWN: - Event->What = evCommand; - Event->Msg.Command = cmHScrollPgRt; - break; - - case SB_ENDSCROLL: - WinSetFocus(HWND_DESKTOP, v->Parent->Active->Peer->hwndView); - /* no break */ - case SB_SLIDERPOSITION: - case SB_SLIDERTRACK: - { - SHORT x = SHORT1FROMMP(qmsg.mp2); - - if (x != 0) { - Event->What = evCommand; - Event->Msg.Command = cmHScrollMove; - if (v->Peer->sbHtotal > 32000) - Event->Msg.Param1 = (x - 1) * v->Peer->sbHtotal / 32000; - else - Event->Msg.Param1 = x - 1; - } - } - break; - } - return 0; - - case WM_CLOSE: - //DosBeep(500, 1500); - frames = f; - Event->What = evCommand; - Event->Msg.View = v->Parent->Active; - Event->Msg.Command = cmClose; - return 0; - - case WM_COMMAND: - //DosBeep(50, 2500); - if (SHORT1FROMMP(qmsg.mp1) >= 8192) { - Event->What = evCommand; - Event->Msg.View = v->Parent->Active; - Event->Msg.Command = (SHORT1FROMMP(qmsg.mp1) - 8192) + 65536; - frames = f; - return 0; - } - break; - - case WM_CHAR: - //DosBeep(50, 500); - Event->What = evNone; - Event->Msg.View = v; - ConvertKey(SHORT1FROMMP(qmsg.mp2), /* char */ - SHORT2FROMMP(qmsg.mp2), /* virtual */ - SHORT1FROMMP(qmsg.mp1), /* flags */ - CHAR4FROMMP(qmsg.mp1), /* scan */ - *Event); - frames = f; - return 0; - - case WM_BUTTON1DOWN: - case WM_BUTTON2DOWN: - case WM_BUTTON3DOWN: - case WM_BUTTON1DBLCLK: - case WM_BUTTON2DBLCLK: - case WM_BUTTON3DBLCLK: - if (!v->IsActive()) - v->Parent->SelectView(v); - case WM_BUTTON1UP: - case WM_BUTTON2UP: - case WM_BUTTON3UP: - case WM_MOUSEMOVE: - Event->Mouse.What = evNone; - Event->Msg.View = v; - Event->Mouse.X = ((SHORT)SHORT1FROMMP(qmsg.mp1)) / v->Peer->pmData->cxChar; - Event->Mouse.Y = v->Peer->wH - ((SHORT)SHORT2FROMMP(qmsg.mp1)) / v->Peer->pmData->cyChar - 1; - Event->Mouse.Buttons = 1; - Event->Mouse.Count = 1; - Event->Mouse.KeyMask = 0; - if (WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) - Event->Mouse.KeyMask |= kfCtrl; - if (WinGetKeyState(HWND_DESKTOP, VK_ALT) & 0x8000) - Event->Mouse.KeyMask |= kfAlt; - if (WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) - Event->Mouse.KeyMask |= kfShift; -// printf("KeyFlags: %d\n", Event->Mouse.KeyMask); - //DosBeep(2000, 50); - frames = f; - - switch (qmsg.msg) { - case WM_BUTTON1DOWN: - Event->What = evMouseDown; - v->Peer->OldMouseX = Event->Mouse.X; - v->Peer->OldMouseY = Event->Mouse.Y; - return 0; - - case WM_BUTTON1DBLCLK: - Event->What = evMouseDown; - Event->Mouse.Count = 2; - v->Peer->OldMouseX = Event->Mouse.X; - v->Peer->OldMouseY = Event->Mouse.Y; - return 0; - - case WM_BUTTON1UP: - Event->What = evMouseUp; - v->Peer->OldMouseX = Event->Mouse.X; - v->Peer->OldMouseY = Event->Mouse.Y; - return 0; - - case WM_BUTTON2DOWN: - Event->What = evMouseDown; - Event->Mouse.Buttons = 2; - v->Peer->OldMouseX = Event->Mouse.X; - v->Peer->OldMouseY = Event->Mouse.Y; - return 0; - - case WM_BUTTON2DBLCLK: - Event->What = evMouseDown; - Event->Mouse.Buttons = 2; - Event->Mouse.Count = 2; - v->Peer->OldMouseX = Event->Mouse.X; - v->Peer->OldMouseY = Event->Mouse.Y; - return 0; - - case WM_BUTTON2UP: - Event->What = evMouseUp; - Event->Mouse.Buttons = 2; - v->Peer->OldMouseX = Event->Mouse.X; - v->Peer->OldMouseY = Event->Mouse.Y; - return 0; - - case WM_BUTTON3DOWN: - Event->What = evMouseDown; - Event->Mouse.Buttons = 4; - v->Peer->OldMouseX = Event->Mouse.X; - v->Peer->OldMouseY = Event->Mouse.Y; - return 0; - - case WM_BUTTON3DBLCLK: - Event->What = evMouseDown; - Event->Mouse.Buttons = 4; - Event->Mouse.Count = 2; - v->Peer->OldMouseX = Event->Mouse.X; - v->Peer->OldMouseY = Event->Mouse.Y; - return 0; - - case WM_BUTTON3UP: - Event->What = evMouseUp; - Event->Mouse.Buttons = 4; - v->Peer->OldMouseX = Event->Mouse.X; - v->Peer->OldMouseY = Event->Mouse.Y; - return 0; - - case WM_MOUSEMOVE: - Event->What = evMouseMove; - Event->Mouse.Buttons = 0; - if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000) - Event->Mouse.Buttons |= 1; - if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000) - Event->Mouse.Buttons |= 2; - if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000) - Event->Mouse.Buttons |= 4; - - if (Event->Mouse.Buttons != 0) { - if (Event->Mouse.X != v->Peer->OldMouseX || - Event->Mouse.Y != v->Peer->OldMouseY) - { - v->Peer->OldMouseX = Event->Mouse.X; - v->Peer->OldMouseY = Event->Mouse.Y; - return 0; - } else if (Event->Mouse.X >= 0 && - Event->Mouse.Y >= 0 && - Event->Mouse.X < v->Peer->wW && - Event->Mouse.Y < v->Peer->wH) - { - Event->What = evNone; - } - } - } - break; - - default: - WinDispatchMsg(hab, &qmsg); - return 0; - } - } - v = v->Next; - if (v == f->Top) break; - } - f = f->Next; - if (f == frames) break; - } - WinDispatchMsg(hab, &qmsg); - return 0; -} - -static void _LNK_CONV WorkThread(void *) { - habW = WinInitialize(0); - hmqW = WinCreateMsgQueue(hab, 0); - - hwndCreatorWorker = WinCreateWindow(HWND_OBJECT, - szCreator, - "Creator", - 0, - 0, 0, 0, 0, - HWND_OBJECT, HWND_TOP, - 0, NULL, NULL); - - assert(hwndCreatorWorker != 0); - - // work thread started - DosPostEventSem(WorkerStarted); - - ULONG ulPostCount; - DosWaitEventSem(StartInterface, SEM_INDEFINITE_WAIT); - DosResetEventSem(StartInterface, &ulPostCount); - - //DosBeep(200, 200); - if (gui->Start(gui->fArgc, gui->fArgv) == 0) { - gui->doLoop = 1; - //DosBeep(500, 500); - while (gui->doLoop) - gui->ProcessEvent(); - - gui->Stop(); - } - - WinDestroyMsgQueue(hmqW); - WinTerminate(habW); - //DosBeep(500, 500); - WinPostQueueMsg(hmq, WM_QUIT, 0, 0); - _endthread(); -} - -/////////////////////////////////////////////////////////////////////////// - -GViewPeer::GViewPeer(GView *view, int XSize, int YSize) { - HWND parent; - - View = view; -// wX = 0; -// wY = 0; - wW = XSize; - wH = YSize; - sbVtotal = 0; - sbVstart = 0; - sbVamount = 0; - sbHtotal = 0; - sbHstart = 0; - sbHamount = 0; - wState = 0; - cVisible = 1; - cStart = 0; // % - cEnd = 100; - OldMouseX = OldMouseY = 0xFFFF; - - pmData = (PMData *)malloc(sizeof(PMData)); - - pmData->Peer = this; - pmData->hvps = 0; - pmData->cxChar = 8; - pmData->cyChar = 14; - pmData->hwndWorker = 0; - - parent = View->Parent->Peer->hwndFrame; - - WinSendMsg(hwndCreatorWorker, UWM_CREATEWORKER, MPFROMP(this), MPFROMP(pmData)); - - WinSendMsg(parent, UWM_CREATECHILD, MPFROMP(this), MPFROMP(pmData)); -} - -GViewPeer::~GViewPeer() { - WinSendMsg(hwndView, UWM_DESTROY, 0, 0); - WinDestroyWindow(hwndWorker); - free(pmData); -} - -int GViewPeer::ConPutBox(int X, int Y, int W, int H, PCell Cell) { - int I; - char *p = (char *) Cell; - int Hidden = 0; - - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - if (Y < 0 || Y >= wH || X < 0 || X >= wW || - Y + H < 0 || Y + H > wH || X + W < 0 || X + W > wW) - { - //fprintf(stderr, - // "X:%d, Y:%d, W:%d, H:%d, wW:%d, wH:%d\n", - // X, Y, W, H, wW, wH); - DosReleaseMutexSem(hmtxPMData); - return -1; - } - for (I = 0; I < H; I++) { - if (I + Y == cY) - Hidden = PMHideCursor(); - VioWrtCellStr(p, (USHORT)(W << 1), (USHORT)(Y + I), (USHORT)X, pmData->hvps); - if (Hidden) - PMShowCursor(); - p += W << 1; - } - DosReleaseMutexSem(hmtxPMData); - return 0; -} - -int GViewPeer::ConGetBox(int X, int Y, int W, int H, PCell Cell) { - int I; - USHORT WW = (USHORT)(W << 1); - char *p = (char *) Cell; - - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - if (Y < 0 || Y >= wH || X < 0 || X >= wW || - Y + H < 0 || Y + H > wH || X + W < 0 || X + W > wW) - { - //fprintf(stderr, - // "X:%d, Y:%d, W:%d, H:%d, wW:%d, wH:%d\n", - // X, Y, W, H, wW, wH); - DosReleaseMutexSem(hmtxPMData); - return -1; - } - for (I = 0; I < H; I++) { - VioReadCellStr((char *)p, &WW, (USHORT)(Y + I), (USHORT)X, pmData->hvps); - p += W << 1; - } - DosReleaseMutexSem(hmtxPMData); - return 0; -} - -int GViewPeer::ConPutLine(int X, int Y, int W, int H, PCell Cell) { - int I; - char *p = (char *) Cell; - int Hidden = 0; - - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - if (Y < 0 || Y >= wH || X < 0 || X >= wW || - Y + H < 0 || Y + H > wH || X + W < 0 || X + W > wW) - { - //fprintf(stderr, - // "X:%d, Y:%d, W:%d, H:%d, wW:%d, wH:%d\n", - // X, Y, W, H, wW, wH); - DosReleaseMutexSem(hmtxPMData); - return -1; - } - for (I = 0; I < H; I++) { - if (I + Y == cY) - Hidden = PMHideCursor(); - VioWrtCellStr(p, (USHORT)(W << 1), (USHORT)(Y + I), (USHORT)X, pmData->hvps); - if (Hidden) - PMShowCursor(); - } - DosReleaseMutexSem(hmtxPMData); - return 0; -} - -int GViewPeer::ConSetBox(int X, int Y, int W, int H, TCell Cell) { - int I; - char *p = (char *) &Cell; - int Hidden = 0; - - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - if (Y < 0 || Y >= wH || X < 0 || X >= wW || - Y + H < 0 || Y + H > wH || X + W < 0 || X + W > wW) - { - //fprintf(stderr, - // "X:%d, Y:%d, W:%d, H:%d, wW:%d, wH:%d\n", - // X, Y, W, H, wW, wH); - DosReleaseMutexSem(hmtxPMData); - return -1; - } - for (I = 0; I < H; I++) { - if (I + Y == cY) - Hidden = PMHideCursor(); - VioWrtNCell(p, (USHORT)(W), (USHORT)(Y + I), (USHORT)X, pmData->hvps); - if (Hidden) - PMShowCursor(); - } - DosReleaseMutexSem(hmtxPMData); - return 0; -} - -int GViewPeer::ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count) { - TCell FillCell = (TCell)(Fill << 8); - int Hidden = 0; - - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - if (Y < 0 || Y >= wH || X < 0 || X >= wW || - Y + H < 0 || Y + H > wH || X + W < 0 || X + W > wW) - { - //fprintf(stderr, - // "X:%d, Y:%d, W:%d, H:%d, wW:%d, wH:%d\n", - // X, Y, W, H, wW, wH); - DosReleaseMutexSem(hmtxPMData); - return -1; - } - Hidden = PMHideCursor(); - switch (Way) { - case csUp: - VioScrollUp((USHORT)Y, (USHORT)X, (USHORT)(Y + H - 1), (USHORT)(X + W - 1), (USHORT)Count, (PBYTE)&FillCell, pmData->hvps); - break; - case csDown: - VioScrollDn((USHORT)Y, (USHORT)X, (USHORT)(Y + H - 1), (USHORT)(X + W - 1), (USHORT)Count, (PBYTE)&FillCell, pmData->hvps); - break; - case csLeft: - VioScrollLf((USHORT)Y, (USHORT)X, (USHORT)(Y + H - 1), (USHORT)(X + W - 1), (USHORT)Count, (PBYTE)&FillCell, pmData->hvps); - break; - case csRight: - VioScrollRt((USHORT)Y, (USHORT)X, (USHORT)(Y + H - 1), (USHORT)(X + W - 1), (USHORT)Count, (PBYTE)&FillCell, pmData->hvps); - break; - } - if (Hidden) - PMShowCursor(); - DosReleaseMutexSem(hmtxPMData); - return 0; -} - -int GViewPeer::ConSetSize(int X, int Y) { - wW = X; - wH = Y; - return 1; -} - -int GViewPeer::ConQuerySize(int *X, int *Y) { - if (X) *X = wW; - if (Y) *Y = wH; - return 1; -} - -int GViewPeer::ConSetCursorPos(int X, int Y) { - if (X < 0) X = 0; - if (X >= wW) X = wW - 1; - if (Y < 0) Y = 0; - if (Y >= wH) Y = wH - 1; - cX = X; - cY = Y; - if (wState & sfFocus) - return PMSetCursorPos(); - else - return 1; -} - -int GViewPeer::ConQueryCursorPos(int *X, int *Y) { - if (X) *X = cX; - if (Y) *Y = cY; - return 1; -} - -int GViewPeer::ConShowCursor() { - cVisible = 1; - if (wState & sfFocus) - return PMShowCursor(); - else - return 1; -} - -int GViewPeer::ConHideCursor() { - cVisible = 0; - if (wState & sfFocus) - return PMHideCursor(); - else - return 1; -} - -int GViewPeer::ConCursorVisible() { - return cVisible; -} - -int GViewPeer::ConSetCursorSize(int Start, int End) { - cStart = Start; - cEnd = End; - if (wState & sfFocus) - return PMSetCursorPos(); - else - return 1; -} - -int GViewPeer::ExpandHeight(int DeltaY) { - if (View->Parent->Top == View->Next) - return -1; - if (DeltaY + wH < 3) - return -1; - if (View->Next->Peer->wH - DeltaY < 3) - return -1; - ConSetSize(wW, wH + DeltaY); - //View->Next->Peer->wY += DeltaY; - View->Next->ConSetSize(View->Next->Peer->wW, View->Next->Peer->wH - DeltaY); - View->Parent->Peer->SizeFrame(); - return 0; -} - -int GViewPeer::QuerySbVPos() { - return sbVstart; -} - -int GViewPeer::SetSbVPos(int Start, int Amount, int Total) { - if (sbVstart != Start || - sbVamount != Amount || - sbVtotal != Total) - { - sbVstart = Start; - sbVamount = Amount; - sbVtotal = Total; - - if (View->Parent == 0) - return 0; - - WinEnableWindowUpdate(hwndVscroll, FALSE); - if (sbVamount < sbVtotal) { - if (sbVtotal > 32000) { - int total = 32000; - int start = total * sbVstart / sbVtotal; - int amount = total * sbVamount / sbVtotal; - - WinSendMsg(hwndVscroll, SBM_SETTHUMBSIZE, - (MPFROM2SHORT((amount), (total))), 0); - WinSendMsg(hwndVscroll, SBM_SETSCROLLBAR, - (MPFROMSHORT((start + 1))), - (MPFROM2SHORT((1), (total - amount + 2)))); - } else { - WinSendMsg(hwndVscroll, SBM_SETTHUMBSIZE, - (MPFROM2SHORT((sbVamount), (sbVtotal))), 0); - WinSendMsg(hwndVscroll, SBM_SETSCROLLBAR, - (MPFROMSHORT((sbVstart + 1))), - (MPFROM2SHORT((1), (sbVtotal - sbVamount + 2)))); - } - } else { - WinSendMsg(hwndVscroll, SBM_SETTHUMBSIZE, - MPFROM2SHORT(0, 0), 0); - WinSendMsg(hwndVscroll, SBM_SETSCROLLBAR, - MPFROMSHORT(0), - MPFROM2SHORT(0, 0)); - } - WinEnableWindowUpdate(hwndVscroll, TRUE); - } - return 1; -} - -int GViewPeer::SetSbHPos(int Start, int Amount, int Total) { - if (sbHstart != Start || - sbHamount != Amount || - sbHtotal != Total) - { - sbHstart = Start; - sbHamount = Amount; - sbHtotal = Total; - - if (View->Parent == 0) - return 0; - - WinEnableWindowUpdate(hwndHscroll, FALSE); - if (sbHtotal > sbHamount) { - if (sbHtotal > 32000) { - int total = 32000; - int start = total * sbVstart / sbVtotal; - int amount = total * sbVamount / sbVtotal; - - WinSendMsg(hwndHscroll, SBM_SETTHUMBSIZE, - (MPFROM2SHORT(amount, total)), 0); - WinSendMsg(hwndHscroll, SBM_SETSCROLLBAR, - (MPFROMSHORT(start + 1)), - (MPFROM2SHORT(1, total - amount + 2))); - } else { - WinSendMsg(hwndHscroll, SBM_SETTHUMBSIZE, - (MPFROM2SHORT(sbHamount, sbHtotal)), 0); - WinSendMsg(hwndHscroll, SBM_SETSCROLLBAR, - (MPFROMSHORT(sbHstart + 1)), - (MPFROM2SHORT(1, sbHtotal - sbHamount + 2))); - } - } else { - WinSendMsg(hwndHscroll, SBM_SETTHUMBSIZE, - (MPFROM2SHORT(0, 0)), 0); - WinSendMsg(hwndHscroll, SBM_SETSCROLLBAR, - (MPFROMSHORT(0)), - (MPFROM2SHORT(0, 0))); - } - WinEnableWindowUpdate(hwndHscroll, TRUE); - } - return 1; -} - -int GViewPeer::UpdateCursor() { - ConSetCursorPos(cX, cY); - ConSetCursorSize(cStart, cEnd); - if (cVisible) - ConShowCursor(); - else - ConHideCursor(); - return 1; -} - -int GViewPeer::PMShowCursor() { - if (wState & sfFocus) - WinShowCursor(hwndView, TRUE); - return 1; -} - -int GViewPeer::PMHideCursor() { - if (wState & sfFocus) - WinShowCursor(hwndView, FALSE); - return 1; -} - -int GViewPeer::PMSetCursorPos() { - if (wState & sfFocus) { - WinDestroyCursor(hwndView); - WinCreateCursor(hwndView, - pmData->cxChar * cX, - pmData->cyChar * (wH - cY - 1) + - pmData->cyChar * (100 - cEnd) / 100, - pmData->cxChar, pmData->cyChar * (cEnd - cStart) / 100, - CURSOR_TYPE, - NULL); - WinShowCursor(hwndView, TRUE); - } - return 1; -} - -/////////////////////////////////////////////////////////////////////////// - -GView::GView(GFrame *parent, int XSize, int YSize) { - Parent = parent; - Prev = Next = 0; - Peer = new GViewPeer(this, XSize, YSize); - if (Parent) - Parent->AddView(this); -} - -GView::~GView() { - if (FocusCapture == this) - CaptureFocus(0); - if (MouseCapture == this) - CaptureMouse(0); - if (Parent) - Parent->RemoveView(this); - if (Peer) { - Peer->View = 0; - delete Peer; - Peer = 0; - } -} - -int GView::ConClear() { - int W, H; - TDrawBuffer B; - - ConQuerySize(&W, &H); - MoveChar(B, 0, W, ' ', 0x07, 1); - ConSetBox(0, 0, W, H, B[0]); - return 1; -} - -int GView::ConPutBox(int X, int Y, int W, int H, PCell Cell) { - return Peer->ConPutBox(X, Y, W, H, Cell); -} - -int GView::ConGetBox(int X, int Y, int W, int H, PCell Cell) { - return Peer->ConGetBox(X, Y, W, H, Cell); -} - -int GView::ConPutLine(int X, int Y, int W, int H, PCell Cell) { - return Peer->ConPutLine(X, Y, W, H, Cell); -} - -int GView::ConSetBox(int X, int Y, int W, int H, TCell Cell) { - return Peer->ConSetBox(X, Y, W, H, Cell); -} - -int GView::ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count) { - return Peer->ConScroll(Way, X, Y, W, H, Fill, Count); -} - -int GView::ConSetSize(int X, int Y) { - if (Peer->ConSetSize(X, Y)) - Resize(X, Y); - else - return 0; - return 1; -} - -int GView::ConQuerySize(int *X, int *Y) { - return Peer->ConQuerySize(X, Y); -} - -int GView::ConSetCursorPos(int X, int Y) { - return Peer->ConSetCursorPos(X, Y); -} - -int GView::ConQueryCursorPos(int *X, int *Y) { - return Peer->ConQueryCursorPos(X, Y); -} - -int GView::ConShowCursor() { - return Peer->ConShowCursor(); -} - -int GView::ConHideCursor() { - return Peer->ConHideCursor(); -} - -int GView::ConCursorVisible() { - return Peer->ConCursorVisible(); -} - -int GView::ConSetCursorSize(int Start, int End) { - return Peer->ConSetCursorSize(Start, End); -} - -int GView::QuerySbVPos() { - return Peer->QuerySbVPos(); -} - -int GView::SetSbVPos(int Start, int Amount, int Total) { - return Peer->SetSbVPos(Start, Amount, Total); -} - -int GView::SetSbHPos(int Start, int Amount, int Total) { - return Peer->SetSbHPos(Start, Amount, Total); -} - -int GView::ExpandHeight(int DeltaY) { - return Peer->ExpandHeight(DeltaY); -} - -void GView::Update() { -} - -void GView::Repaint() { -} - -void GView::HandleEvent(TEvent &Event) { -} - -void GView::Resize(int width, int height) { - Repaint(); -} - -void GView::EndExec(int NewResult) { - Result = NewResult; -} - -int GView::Execute() { - int SaveRc = Result; - int NewResult; - int didFocus = 0; - - if (FocusCapture == 0) { - if (CaptureFocus(1) == 0) return -1; - didFocus = 1; - } else - if (FocusCapture != this) - return -1; - Result = -2; - while (Result == -2 && frames != 0) - gui->ProcessEvent(); - NewResult = Result; - Result = SaveRc; - if (didFocus) - CaptureFocus(0); - return NewResult; -} - -int GView::IsActive() { - return (Parent->Active == this && Parent == frames); -} - -void GView::Activate(int gotfocus) { - if (gotfocus) { - Peer->wState |= sfFocus; - Peer->UpdateCursor(); - } else { - Peer->wState &= ~sfFocus; - } - Repaint(); -} - -int GView::CaptureMouse(int grab) { - if (MouseCapture == 0) { - if (grab) { - MouseCapture = this; - WinSetCapture(HWND_DESKTOP, Peer->hwndView); - } else - return 0; - } else { - if (grab || MouseCapture != this) - return 0; - else { - MouseCapture = 0; - WinSetCapture(HWND_DESKTOP, NULLHANDLE); - } - } - return 1; -} - -int GView::CaptureFocus(int grab) { - if (FocusCapture == 0) { - if (grab) { - FocusCapture = this; - WinSetFocus(HWND_DESKTOP, Peer->hwndView); - } else - return 0; - } else { - if (grab || FocusCapture != this) - return 0; - else - FocusCapture = 0; - } - return 1; -} - -/////////////////////////////////////////////////////////////////////////// - -GFramePeer::GFramePeer(GFrame *aFrame, int Width, int Height) { - Frame = aFrame; - - WinSendMsg(hwndCreatorUser, UWM_CREATEFRAME, MPFROMP(this), MPFROMLONG(0)); - - if (Width != -1 && Height != -1) - ConSetSize(Width, Height); -} - -GFramePeer::~GFramePeer() { - WinStoreWindowPos("FTEPM", "Frame1", hwndFrame); - WinSendMsg(hwndFrame, UWM_DESTROY, 0, 0); -} - -int GFramePeer::ConSetSize(int X, int Y) { - //return ::ConSetSize(X, Y); - return 0; -} - -int GFramePeer::ConQuerySize(int *X, int *Y) { -// ::ConQuerySize(&fW, &fH); -// if (X) *X = fW; -// if (Y) *Y = fH; - return 1; -} - -int GFramePeer::ConSetTitle(char *Title, char *STitle) { - char szTitle[256] = {0}; - - JustFileName(Title, szTitle); - if (szTitle[0] == '\0') // if there is no filename, try the directory name. - JustLastDirectory(Title, szTitle); - - if (szTitle[0] != '\0') // if there is something... - strncat(szTitle, " - ", sizeof(szTitle) - 1 - strlen(szTitle)); - strncat(szTitle, Title, sizeof(szTitle) - 1 - strlen(szTitle)); - - WinSetWindowText(hwndFrame, szTitle); - return 1; -} - -int GFramePeer::ConGetTitle(char *Title, int MaxLen, char *STitle, int SMaxLen) { - WinQueryWindowText(hwndFrame, MaxLen, Title); - WinQueryWindowText(hwndFrame, SMaxLen, STitle); - return 1; -} - -void GFramePeer::MapFrame() { - if (frames != frames->Next || WinRestoreWindowPos("FTEPM", "Frame1", hwndFrame) == FALSE) { - WinQueryTaskSizePos(hab, 0, &swp); - - WinSetWindowPos(hwndFrame, HWND_TOP, - swp.x, - swp.y, - swp.cx, - swp.cy, - SWP_MOVE | SWP_SIZE); - } - // WinSendMsg(Peer->hwndFrame, WM_UPDATEFRAME, 0, 0); - SizeFrame(); - ShowFrame(); -} - -void GFramePeer::ShowFrame() { - WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, 0, 0, - SWP_ZORDER | SWP_SHOW | SWP_ACTIVATE); -} - -void GFramePeer::SizeFrame() { - POINTL ptl; - GView *v = Frame->Top; - SWP swp; - SWP swpMenu; - HWND hwndMenu = WinWindowFromID(hwndFrame, FID_MENU); - SWP swpToolBar; - - if (ShowToolBar) { - HWND hwndToolBar = WinWindowFromID(hwndFrame, FID_MTOOLBAR); - - WinQueryWindowPos(hwndToolBar, &swpToolBar); - WinSendMsg(hwndToolBar, - WM_ADJUSTWINDOWPOS, - MPFROMP(&swpToolBar), - MPARAM(0)); - } else { - swpToolBar.cy = 0; - } - - WinQueryWindowPos(hwndMenu, &swpMenu); - WinSendMsg(hwndMenu, - WM_ADJUSTWINDOWPOS, - MPFROMP(&swpMenu), - MPARAM(0)); - - //WinEnableWindowUpdate(hwndFrame, FALSE); - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - ptl.x = v->Peer->wW * v->Peer->pmData->cxChar + cxScrollBar + 2 * cxBorder; - ptl.y = 2 * cyBorder + cyTitleBar + swpMenu.cy + swpToolBar.cy; - - while (v) { - v = v->Prev; - ptl.y += v->Peer->wH * v->Peer->pmData->cyChar + cyScrollBar; - if (v == Frame->Top) break; - } - - reportSize = 0; - DosReleaseMutexSem(hmtxPMData); - WinQueryWindowPos(hwndFrame, &swp); - swp.y = swp.y + swp.cy - ptl.y; - swp.cx = ptl.x; - swp.cy = ptl.y; - WinSendMsg(hwndFrame, - WM_ADJUSTWINDOWPOS, - MPFROMP(&swp), - MPARAM(0)); - WinSetWindowPos(hwndFrame, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, SWP_SIZE | SWP_MOVE); - DosRequestMutexSem(hmtxPMData, SEM_INDEFINITE_WAIT); - reportSize = 1; - DosReleaseMutexSem(hmtxPMData); - swp.x = cxBorder; - swp.y = cyBorder; - if (ShowToolBar == 2) { - swp.y += swpToolBar.cy; - } - v = Frame->Top; - while (v) { - v = v->Prev; - swp.cx = v->Peer->wW * v->Peer->pmData->cxChar; - swp.cy = cyScrollBar; - WinSetWindowPos(v->Peer->hwndHscroll, 0, - swp.x, swp.y, swp.cx, swp.cy, SWP_SIZE | SWP_MOVE); - swp.y += cyScrollBar; - swp.cy = v->Peer->wH * v->Peer->pmData->cyChar; - WinSetWindowPos(v->Peer->hwndView, 0, - swp.x, swp.y, swp.cx, swp.cy, SWP_SIZE | SWP_MOVE); - swp.x = v->Peer->wW * v->Peer->pmData->cxChar + cxBorder; - swp.y -= cyScrollBar; - swp.cx = cxScrollBar; - swp.cy = cyScrollBar + v->Peer->wH * v->Peer->pmData->cyChar; - WinSetWindowPos(v->Peer->hwndVscroll, 0, - swp.x, swp.y, swp.cx, swp.cy, SWP_SIZE | SWP_MOVE); - swp.y += cyScrollBar + v->Peer->wH * v->Peer->pmData->cyChar; - swp.x = cxBorder; - if (v == Frame->Top) - break; - } - //WinEnableWindowUpdate(hwndFrame, TRUE); -} - -/////////////////////////////////////////////////////////////////////////// - -GFrame::GFrame(int XSize, int YSize) { - Menu = 0; - if (frames == 0) { - frames = Prev = Next = this; - } else { - Next = frames->Next; - Prev = frames; - frames->Next->Prev = this; - frames->Next = this; - frames = this; - } - Top = Active = 0; - Peer = new GFramePeer(this, XSize, YSize); -} - -GFrame::~GFrame() { - GView *P = Top, *Q; - if (P) do { - Q = P; - P = Q->Next; - Q->Parent = 0; - delete Q; - } while (P != Top); - - Top = Active = 0; - if (Peer) { - delete Peer; - Peer = 0; - } - if (Next == this) { - frames = 0; - //DosBeep(500, 500); -// printf("No more frames\x7\x7\n"); - } else { - Next->Prev = Prev; - Prev->Next = Next; - frames = Next; - frames->Activate(); - } - Next = Prev = 0; -} - -int GFrame::ConSetTitle(char *Title, char *STitle) { - return Peer->ConSetTitle(Title, STitle); -} - -int GFrame::ConGetTitle(char *Title, int MaxLen, char *STitle, int SMaxLen) { - return Peer->ConGetTitle(Title, MaxLen, STitle, SMaxLen); -} - -int GFrame::ConSetSize(int X, int Y) { - return Peer->ConSetSize(X, Y); -} - -int GFrame::ConQuerySize(int *X, int *Y) { - return Peer->ConQuerySize(X, Y); -} - -int GFrame::ConSplitView(GView *view, GView *newview) { - int dmy; - - newview->Parent = this; - view->ConQuerySize(&newview->Peer->wW, &dmy); - newview->Peer->wH = view->Peer->wH - view->Peer->wH / 2 - 1; - view->Peer->wH /= 2; - InsertView(view, newview); - view->ConSetSize(view->Peer->wW, view->Peer->wH); - newview->ConSetSize(newview->Peer->wW, newview->Peer->wH); - Peer->SizeFrame(); - return 0; -} - -int GFrame::ConCloseView(GView *view) { - return 0; -} - -int GFrame::ConResizeView(GView *view, int DeltaY) { - return 0; -} - -int GFrame::AddView(GView *view) { - if (Active != 0) { - return ConSplitView(Active, view); - } else { -// int W, H; - - view->Parent = this; - view->Prev = view->Next = 0; - -// view->Peer->wX = 0; -// view->Peer->wY = 0; -// ConQuerySize(&W, &H); -// view->ConSetSize(W, H); - InsertView(Top, view); - return 0; - } -} - -void GFrame::Update() { - GView *v = Active; - - UpdateMenu(); - while (v) { - v->Update(); - v = v->Next; - if (v == Active) - break; - } -} - -void GFrame::UpdateMenu() { -} - -void GFrame::Repaint() { - GView *v = Active; - - while (v) { - v->Repaint(); - v = v->Next; - if (v == Active) - break; - } -} - -void GFrame::InsertView(GView *Prev, GView *view) { - if (!view) return ; - if (Prev) { - view->Prev = Prev; - view->Next = Prev->Next; - Prev->Next = view; - view->Next->Prev = view; - } else { - view->Prev = view->Next = view; - Top = view; - } - if (Active == 0) { - Active = view; - Active->Activate(1); - } -} - -void GFrame::RemoveView(GView *view) { - if (!view) return ; - - if (Active == view) - Active->Activate(0); - if (view->Next == view) { - Top = Active = 0; - delete this; - } else { - view->Next->Prev = view->Prev; - view->Prev->Next = view->Next; - - if (Top == view) { - Top = view->Next; - Top->ConSetSize(Top->Peer->wW, Top->Peer->wH + view->Peer->wH + 1); - } else { - view->Prev->ConSetSize(view->Prev->Peer->wW, - view->Prev->Peer->wH + view->Peer->wH + 1); - } - - if (Active == view) { - Active = view->Prev; - WinSetFocus(HWND_DESKTOP, Active->Peer->hwndView); - Active->Activate(1); - } - } - Peer->SizeFrame(); -} - -void GFrame::SelectNext(int back) { - GView *c = Active; - - if (c == 0 && Top == 0) - return; - else if (c == 0) - c = Active = Top; - else - if (back) { - Active = Active->Prev; - } else { - Active = Active->Next; - } - if (c != Active) { - c->Activate(0); - Active->Activate(1); - WinSetFocus(HWND_DESKTOP, Active->Peer->hwndView); - } -} - -int GFrame::SelectView(GView *view) { - if (Top == 0) - return 0; - - if (FocusCapture != 0 || MouseCapture != 0) - return 0; - - if (Active) - Active->Activate(0); - Active = view; - if (Active) { - Active->Activate(1); - } - //DosBeep(50, 500); - frames = this; - return 1; -} - -void GFrame::Resize(int width, int height) { - if (!Top) - return; - - if (width < 8 || height < 2) - return; - - if (Top == Top->Next) { - Top->ConSetSize(width, height); - } else { - } -} - -int GFrame::SetMenu(const char *Name) { - //WinAlarm(HWND_DESKTOP, WA_NOTE); - if (Menu && Name && strcmp(Name, Menu) == 0) - return 1; - - free(Menu); - Menu = strdup(Name); - - Peer->menuBar = (HWND)WinSendMsg(hwndCreatorUser, - UWM_CREATEMAINMENU, - MPFROMP(Peer), - MPFROMP(Menu)); - - return 1; -} - -int GFrame::ExecMainMenu(char Sub) { - HWND hwnd; - - hwnd = WinWindowFromID(Peer->hwndFrame, FID_MENU); - if (Sub != 0) { - int count = LONGFROMMR(WinSendMsg(hwnd, MM_QUERYITEMCOUNT, 0, 0)); - SHORT id; - char buf[256]; - int len; - char srch[3] = "~x"; - - srch[1] = (char)toupper(Sub); - - //puts("mainmenu"); - for (SHORT i = 0; i < count; i++) { - id = SHORT1FROMMR(WinSendMsg(hwnd, MM_ITEMIDFROMPOSITION, MPFROMSHORT(i), 0)); - if (id == MIT_ERROR) { - puts("error"); - } else { - //printf("got %d %d\n", i, id); - len = SHORT1FROMMR(WinSendMsg(hwnd, MM_QUERYITEMTEXT, MPFROM2SHORT((id), (sizeof(buf) - 1)), MPFROMP(buf))); - buf[len] = 0; - //puts(buf); - srch[1] = (char)toupper(Sub); - if (strstr(buf, srch) != 0) { - WinSendMsg(hwnd, MM_SELECTITEM, (MPFROM2SHORT(id, 0)), 0); - //printf("select %d %d\n", i, id); - } else { - srch[1] = (char)tolower(Sub); - if (strstr(buf, srch) != 0) { - WinSendMsg(hwnd, MM_SELECTITEM, (MPFROM2SHORT(id, 0)), 0); - //printf("select %d %d\n", i, id); - } - } - } - } - } else { - WinPostMsg(hwnd, MM_STARTMENUMODE, MPFROM2SHORT((Sub ? TRUE : FALSE), FALSE), 0); - } - return 0; -} - -int GFrame::PopupMenu(const char *Name) { - int id = GetMenuId(Name); - - if (id == -1) - return 0; - - - WinSendMsg(hwndCreatorUser, - UWM_CREATEPOPUPMENU, - MPFROMP(Peer), - MPFROMLONG(id)); - return 0; -} - -void GFrame::Show() { - Update(); - Peer->MapFrame(); -} - -void GFrame::Activate() { - frames = this; - Update(); - Peer->ShowFrame(); -} - -// GUI - -GUI::GUI(int &argc, char **argv, int XSize, int YSize) { - fArgc = argc; - fArgv = argv; - hab = WinInitialize(0); - hmq = WinCreateMsgQueue(hab, 0); - assert(0 == DosCreateMutexSem(0, &hmtxPMData, 0, 0)); - - cxBorder = WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER); - cyBorder = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER); - cxScrollBar = WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL); - cyScrollBar = WinQuerySysValue(HWND_DESKTOP, SV_CYHSCROLL); - cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN); - cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN); - cyTitleBar = WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR); - - // edit window class - WinRegisterClass(hab, szClient, (PFNWP)AVIOWndProc, CS_SIZEREDRAW, 4); - //WinRegisterClass(hab, szSizer, (PFNWP)SizerWndProc, CS_SIZEREDRAW, 4); - - // worker object-window class - WinRegisterClass(hab, szObject, (PFNWP)ObjectWndProc, 0, 4); - - // window that created windows in thr 1 for thr 2 - WinRegisterClass(hab, szCreator, (PFNWP)CreatorWndProc, 0, 0); - - hwndCreatorUser = WinCreateWindow(HWND_DESKTOP, - szCreator, - "FTEPM", - 0, - 0, 0, 0, 0, - HWND_DESKTOP, HWND_TOP, - 0, NULL, NULL); - - assert(0 == DosCreateEventSem(0, &WorkerStarted, 0, 0)); - assert(0 == DosCreateEventSem(0, &StartInterface, 0, 0)); - - _beginthread(WorkThread, FAKE_BEGINTHREAD_NULL PM_STACK_SIZE, 0); - - ULONG ulPostCount; - DosWaitEventSem(WorkerStarted, SEM_INDEFINITE_WAIT); - DosResetEventSem(WorkerStarted, &ulPostCount); - - gui = this; -} - -GUI::~GUI() { - WinDestroyMsgQueue(hmq); - WinTerminate(hab); - gui = 0; -} - -int GUI::ConGrabEvents(TEventMask EventMask) { - return 0; -} - -void GUI::DispatchEvent(GFrame *frame, GView *view, TEvent &Event) { - if (Event.What != evNone) { - if (view) - view->HandleEvent(Event); - } -} - -int GUI::ConSuspend(void) { return 0; } - -int GUI::ConContinue(void) { return 0; } - -int GUI::ConGetEvent(TEventMask EventMask, TEvent *Event, int WaitTime, int Delete, GView **view) { - return ::ConGetEvent(EventMask, Event, WaitTime, Delete, view); -} - -int GUI::ConPutEvent(TEvent Event) { - EventBuf = Event; - return 0; -} - -int GUI::ConFlush(void) { - return 0; -} - -void GUI::ProcessEvent() { - TEvent E; - GView *v; - - if (frames == 0) - return ; - - E.What = evNone; - if (E.What == evNone) { - if (ConGetEvent(evMouseDown | evCommand | evKeyDown, &E, 0, 1, &v) == -1) - ; - } - if (E.What == evNone) { - //DosBeep(500, 100); - frames->Update(); - //DosBeep(1000, 100); - if (ConGetEvent(evMouseDown | evCommand | evKeyDown, &E, -1, 1, &v) == -1) - ; - } - if (E.What != evNone) { - v = E.Msg.View; - DispatchEvent(v->Parent, v, E); - } -} - -int GUI::Run() { - QMSG qmsg; - doLoop = 1; - DosPostEventSem(StartInterface); - while (doLoop != 0 && WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0)) - WinDispatchMsg(hab, &qmsg); - return 0; -} - -int GUI::ShowEntryScreen() { - return 1; -} - -int GUI::RunProgram(int mode, char *Command) { - char FailBuf[256]; - char *Args; - char *Prog; - int rc; - PID pid; - ULONG sid; - - Prog = getenv("COMSPEC"); - - Args = (char *)malloc(3 + strlen(Command) + 1); - if (Args == NULL) { - return -1; - } - - if (*Command != 0) { - strcpy(Args, "/c "); - strcat(Args, Command); - } else { - Args[0] = 0; - } - - { - STARTDATA sd; - - memset((void *)&sd, 0, sizeof(sd)); - sd.Length = sizeof(sd); - sd.Related = SSF_RELATED_INDEPENDENT; - sd.FgBg = SSF_FGBG_FORE; - sd.TraceOpt = SSF_TRACEOPT_NONE; - sd.PgmTitle = (Command && Command[0] != 0) ? Command : 0; - sd.PgmName = Prog; - sd.PgmInputs = Args; - sd.TermQ = 0; - sd.Environment = 0; - sd.InheritOpt = SSF_INHERTOPT_PARENT; - sd.SessionType = SSF_TYPE_DEFAULT; - sd.IconFile = 0; - sd.PgmHandle = 0; - sd.PgmControl = SSF_CONTROL_VISIBLE;// | ((Command && Command[0] != 0) ? SSF_CONTROL_NOAUTOCLOSE : 0); - sd.ObjectBuffer = FailBuf; - sd.ObjectBuffLen = sizeof(FailBuf); - rc = DosStartSession(&sd, &sid, &pid); - } - - free(Args); - - return rc; -} - -static int CreatePipeChild(ULONG *sid, PID *pid, HPIPE &hfPipe, char *Command) { - static int PCount = 0; - char szPipe[32]; - char FailBuf[256]; - char *Args; - char *Prog; -#if 0 - int arglen = 0; - RESULTCODES rc_code; -#endif - ULONG ulAction; - //ULONG ulNew; - HPIPE hfChildPipe; - HFILE hfNewStdOut = (HFILE)-1, hfNewStdErr = (HFILE)-1; - HFILE hfStdOut = (HFILE)1, hfStdErr = (HFILE)2; - int rc; - - sprintf(szPipe, "\\PIPE\\FTE%d\\CHILD%d", getpid(), PCount); - PCount++; - - rc = DosCreateNPipe(szPipe, &hfPipe, - NP_NOINHERIT | NP_ACCESS_INBOUND, - NP_NOWAIT | NP_TYPE_BYTE | NP_READMODE_BYTE | 1, - 0, 4096, 0); - if (rc != 0) - return -1; - - rc = DosConnectNPipe (hfPipe); - if (rc != 0 && rc != ERROR_PIPE_NOT_CONNECTED) { - DosClose(hfPipe); - return -1; - } - - rc = DosSetNPHState (hfPipe, NP_WAIT | NP_READMODE_BYTE); - if (rc != 0) { - DosClose(hfPipe); - return -1; - } - - rc = DosOpen (szPipe, &hfChildPipe, &ulAction, 0, - FILE_NORMAL, - OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW, - OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYREADWRITE, - NULL); - if (rc != 0) { - DosClose (hfPipe); - return -1; - } - - // Duplicate handles - DosDupHandle(hfStdOut, &hfNewStdOut); - DosDupHandle(hfStdErr, &hfNewStdErr); - // Close existing handles for current process - DosClose(hfStdOut); - DosClose(hfStdErr); - // Redirect existing handles to new file - DosDupHandle(hfChildPipe, &hfStdOut); - DosDupHandle(hfChildPipe, &hfStdErr); - // Let started program inherit handles from parent - - Prog = getenv("COMSPEC"); - -#if 0 - Args = (char *)malloc(strlen(Prog) + 1 - + 3 + strlen(Command) + 1 - + 1); - if (Args == NULL) { - DosClose(hfPipe); - return -1; - } - - strcpy(Args, Prog); - arglen = strlen(Args) + 1; - strcpy(Args + arglen, "/c "); - arglen += 3; - strcpy(Args + arglen, Command); - arglen += strlen(Command) + 1; - Args[arglen] = '\0'; -#else - Args = (char *)malloc(3 + strlen(Command) + 1); - if (Args == NULL) { - DosClose(hfPipe); - return -1; - } - - strcpy(Args, "/c "); - strcat(Args, Command); -#endif - - -#if 0 - rc = DosExecPgm(FailBuf, sizeof(FailBuf), - EXEC_ASYNCRESULT, // | EXEC_BACKGROUND, - Args, - 0, - &rc_code, - Prog); -#else - { - STARTDATA sd; - - memset((void *)&sd, 0, sizeof(sd)); - sd.Length = sizeof(sd); - sd.Related = SSF_RELATED_INDEPENDENT; - sd.FgBg = SSF_FGBG_BACK; - sd.TraceOpt = SSF_TRACEOPT_NONE; - sd.PgmTitle = 0; - sd.PgmName = Prog; - sd.PgmInputs = Args; - sd.TermQ = 0; - sd.Environment = 0; - sd.InheritOpt = SSF_INHERTOPT_PARENT; - sd.SessionType = SSF_TYPE_DEFAULT; - sd.IconFile = 0; - sd.PgmHandle = 0; - sd.PgmControl = SSF_CONTROL_INVISIBLE; - sd.ObjectBuffer = FailBuf; - sd.ObjectBuffLen = sizeof(FailBuf); - rc = DosStartSession(&sd, sid, pid); - } -#endif - - free(Args); - - // Get back original handles - DosDupHandle(hfNewStdOut, &hfStdOut); - DosDupHandle(hfNewStdErr, &hfStdErr); - // Close the duplicated handles - no longer needed - DosClose(hfNewStdOut); - DosClose(hfNewStdErr); - - DosClose(hfChildPipe); // pipe one way, close out write end - - if (rc != 0) { - DosClose(hfPipe); - return -1; - } - -#if 0 - pid = rc_code.codeTerminate; // get pid when successful - sid = 0; -#endif - - return 0; -} - -static void _LNK_CONV PipeThread(void *p) { - GPipe *pipe = (GPipe *)p; - HAB hab; - ULONG ulPostCount; - ULONG used; - PID pid; - ULONG sid; - HPIPE hfPipe; -#if 0 - RESULTCODES rc_code; -#endif - int rc; - - hab = WinInitialize(0); - - rc = CreatePipeChild(&sid, &pid, hfPipe, pipe->Command); - - if (rc != 0) { - DosRequestMutexSem(pipe->Access, SEM_INDEFINITE_WAIT); - pipe->reading = 0; - if (pipe->notify) - WinPostMsg(frames->Active->Peer->hwndWorker, UWM_NOTIFY, MPFROMLONG(pipe->notify), MPFROMLONG(pipe->id)); - DosReleaseMutexSem(pipe->Access); - WinTerminate(hab); - return; - } -// fprintf(stderr, "Pipe: Begin: %d\n", pipe->id); - while (1) { - rc = DosRead(hfPipe, pipe->buffer, pipe->buflen, &used); - if (rc < 0) - used = 0; - - DosRequestMutexSem(pipe->Access, SEM_INDEFINITE_WAIT); - pipe->bufused = used; -// fprintf(stderr, "Pipe: fread: %d %d\n", pipe->id, pipe->bufused); - DosResetEventSem(pipe->ResumeRead, &ulPostCount); - if (pipe->bufused == 0) - break; - if (pipe->notify && pipe->stopped) { - WinPostMsg(frames->Active->Peer->hwndWorker, UWM_NOTIFY, MPFROMLONG(pipe->notify), MPFROMLONG(pipe->id)); - pipe->stopped = 0; - } - DosReleaseMutexSem(pipe->Access); - if (pipe->DoTerm) - break; - DosWaitEventSem(pipe->ResumeRead, SEM_INDEFINITE_WAIT); - if (pipe->DoTerm) - break; - } -// fprintf(stderr, "Pipe: pClose: %d\n", pipe->id); - DosClose(hfPipe); - //fprintf(stderr, "Pipe: pClose: %d\n", pipe->id); -#if 0 - rc = DosWaitChild(DCWA_PROCESS, DCWW_WAIT, - &rc_code, - &pid, - pid); - pipe->RetCode = rc_code.codeResult; -#else - //DosStopSession(STOP_SESSION_SPECIFIED, sid); - pipe->RetCode = 0; -#endif - pipe->reading = 0; - if (pipe->notify) - WinPostMsg(frames->Active->Peer->hwndWorker, UWM_NOTIFY, MPFROMLONG(pipe->notify), MPFROMLONG(pipe->id)); - DosReleaseMutexSem(pipe->Access); - WinTerminate(hab); -} - -int GUI::OpenPipe(char *Command, EModel *notify) { - int i; - - for (i = 0; i < MAX_PIPES; i++) { - if (Pipes[i].used == 0) { - Pipes[i].reading = 1; - Pipes[i].stopped = 1; - Pipes[i].id = i; - Pipes[i].bufused = 0; - Pipes[i].bufpos = 0; - Pipes[i].buflen = PIPE_BUFLEN; - Pipes[i].Command = strdup(Command); - Pipes[i].notify = notify; - Pipes[i].DoTerm = 0; - if ((Pipes[i].buffer = (char *)malloc(PIPE_BUFLEN)) == 0) - return -1; - - if (0 != DosCreateMutexSem(0, &Pipes[i].Access, 0, 0)) { - free(Pipes[i].Command); - free(Pipes[i].buffer); - return -1; - } - - if (0 != DosCreateEventSem(0, &Pipes[i].ResumeRead, 0, 0)) { - free(Pipes[i].Command); - free(Pipes[i].buffer); - DosCloseMutexSem(Pipes[i].Access); - return -1; - } - - Pipes[i].tid = _beginthread(PipeThread, - FAKE_BEGINTHREAD_NULL - 16384, &Pipes[i]); - - Pipes[i].used = 1; -// fprintf(stderr, "Pipe Open: %d\n", i); - return i; - } - } - return -1; -} - -int GUI::SetPipeView(int id, EModel *notify) { - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - DosRequestMutexSem(Pipes[id].Access, SEM_INDEFINITE_WAIT); -// fprintf(stderr, "Pipe View: %d %08X\n", id, notify); - Pipes[id].notify = notify; - DosReleaseMutexSem(Pipes[id].Access); - return 0; -} - -int GUI::ReadPipe(int id, void *buffer, int len) { - int l; - //ULONG ulPostCount; - - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; -// DosQueryEventSem(Pipes[id].ResumeRead, &ulPostCount); -// if (ulPostCount != 0) -// return 0; - DosRequestMutexSem(Pipes[id].Access, SEM_INDEFINITE_WAIT); -// fprintf(stderr, "Pipe Read: Get %d %d\n", id, len); - if (Pipes[id].bufused - Pipes[id].bufpos > 0) { - l = len; - if (l > Pipes[id].bufused - Pipes[id].bufpos) { - l = Pipes[id].bufused - Pipes[id].bufpos; - } - memcpy(buffer, - Pipes[id].buffer + Pipes[id].bufpos, - l); - Pipes[id].bufpos += l; - if (Pipes[id].bufpos == Pipes[id].bufused) { - Pipes[id].bufused = 0; - Pipes[id].bufpos = 0; -// fprintf(stderr, "Pipe Resume Read: %d\n", id); - Pipes[id].stopped = 1; - DosPostEventSem(Pipes[id].ResumeRead); - } - } else if (Pipes[id].reading == 0) - l = -1; - else { - l = 0; - //DosBeep(200, 200); - } -// fprintf(stderr, "Pipe Read: Got %d %d\n", id, l); - DosReleaseMutexSem(Pipes[id].Access); - return l; -} - -int GUI::ClosePipe(int id) { - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - if (Pipes[id].reading == 1) { - Pipes[id].DoTerm = 1; - DosPostEventSem(Pipes[id].ResumeRead); - DosWaitThread(&Pipes[id].tid, DCWW_WAIT); - } - free(Pipes[id].buffer); - free(Pipes[id].Command); - DosCloseEventSem(Pipes[id].ResumeRead); - DosCloseMutexSem(Pipes[id].Access); -// fprintf(stderr, "Pipe Close: %d\n", id); - Pipes[id].used = 0; - return Pipes[id].RetCode; -} - -int GUI::multiFrame() { - return 1; -} - -void DieError(int rc, const char *msg, ...) { - va_list ap; - char str[1024]; - - va_start(ap, msg); - vsprintf(str, msg, ap); - va_end(ap); - if (hab == 0) - hab = WinInitialize(0); - if (hmq == 0) - hmq = WinCreateMsgQueue(hab, 0); - WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, str, "FTE", 0, MB_OK | MB_ERROR); - WinDestroyMsgQueue(hmq); - WinTerminate(hab); - exit(rc); -} - -char ConGetDrawChar(int index) { - static char tab[] = "\xDA\xBF\xC0\xD9\xC4\xB3\xC2\xC3\xB4\xC1\xC5\x1A\xFA\x04\xC4\x18\x19\xB1\xB0\x1B\x1A"; - - assert(index >= 0 && index < (signed)strlen(tab)); - - return tab[index]; -} diff --git a/src/g_qt.cpp b/src/g_qt.cpp deleted file mode 100644 index 03bc9fb..0000000 --- a/src/g_qt.cpp +++ /dev/null @@ -1,2138 +0,0 @@ -/* g_motif.cpp - * - * Copyright (c) 1994-1996, Marko Macek - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sysdep.h" -#include "console.h" -#include "gui.h" - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include // conflicts with above - -#include -#include - -#include -#include - -#define DEBUGX(x) //printf x - -#define EDIT_BORDER 2 -#define SCROLLBAR_SIZE 16 - -#define MAX_PIPES 4 - -typedef struct { - int used; - int id; - int fd; - int pid; - int stopped; - EModel *notify; - //XtInputId input; -} GPipe; - -static GPipe Pipes[MAX_PIPES] = { - { 0 }, { 0 }, { 0 }, { 0 } -}; - -#define sfFocus 1 - -class QEText: public QWidget { - Q_OBJECT -public: - GViewPeer *view; - - QEText(GViewPeer *peer, QWidget *parent = 0, const char *name = 0); - virtual ~QEText(); - - virtual void handleKeyPressEvent(QKeyEvent *qe); - void ActiveEvent(TEvent &Event); -protected: - void handleMouse(QMouseEvent *qe); - - virtual void resizeEvent(QResizeEvent *qe); - virtual void paintEvent(QPaintEvent *qe); - virtual void mousePressEvent(QMouseEvent *qe); - virtual void mouseMoveEvent(QMouseEvent *qe); - virtual void mouseReleaseEvent(QMouseEvent *qe); - virtual void keyPressEvent(QKeyEvent *qe); - virtual void focusInEvent(QFocusEvent *qe); - virtual void focusOutEvent(QFocusEvent *qe); -}; - -class QEView: public QFrame { - Q_OBJECT -public: - GViewPeer *view; - QEText *text; - QScrollBar *horz; - QScrollBar *vert; - - QEView(GViewPeer *peer, QWidget *parent = 0, const char *name = 0); - virtual ~QEView(); - - void ActiveEvent(TEvent &Event); - void setViewPos(int x, int y, int w, int h); - -//protected: -// virtual void resizeEvent(QResizeEvent *qe); - -protected slots: - void sbHmoveLeft(); - void sbHmoveRight(); - void sbHpageLeft(); - void sbHpageRight(); - void sbHmoveTo(int pos); - - void sbVmoveUp(); - void sbVmoveDown(); - void sbVpageUp(); - void sbVpageDown(); - void sbVmoveTo(int pos); -}; - -class QEFrame : public QFrame { - Q_OBJECT -public: - QMenuBar *menubar; - QEFrame(GFramePeer *peer, QWidget *parent = 0, const char *name = 0); - - QMenuBar *CreateMenuBar(QWidget *parent, int Id); - QPopupMenu *CreatePopup(QWidget *parent, int Id, int do_connect); - -protected: - virtual void resizeEvent(QResizeEvent *qe); - virtual void closeEvent(QCloseEvent *qe); -public slots: - void selectedMain(int id); - void timerDone(); -private: - GFramePeer *frame; -}; - -class GViewPeer { -public: - QEView *qView; - GC GCs[256]; - - GView *View; -// int wX, wY; - int wW, wH, wState, wRefresh; - int cX, cY, cVisible, cStart, cEnd; - int sbVstart, sbVamount, sbVtotal; - int sbHstart, sbHamount, sbHtotal; - int VertPos, HorzPos; - unsigned char *ScreenBuffer; - - GViewPeer(GView *view, int XSize, int YSize); - ~GViewPeer(); - - int AllocBuffer(); - void DrawCursor(/*QPainter *painter, */int Show); - void UpdateWindow(int xx, int yy, int ww, int hh); - - int ConPutBox(int X, int Y, int W, int H, PCell Cell); - int ConGetBox(int X, int Y, int W, int H, PCell Cell); - int ConPutLine(int X, int Y, int W, int H, PCell Cell); - int ConSetBox(int X, int Y, int W, int H, TCell Cell); - int ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count); - - int ConSetSize(int X, int Y); - int ConQuerySize(int *X, int *Y); - - int ConSetCursorPos(int X, int Y); - int ConQueryCursorPos(int *X, int *Y); - int ConShowCursor(); - int ConHideCursor(); - int ConCursorVisible(); - int ConSetCursorSize(int Start, int End); - - int QuerySbVPos(); - int SetSbVPos(int Start, int Amount, int Total); - int SetSbHPos(int Start, int Amount, int Total); - int ExpandHeight(int DeltaY); - - int UpdateCursor(); - int PMShowCursor(); - int PMHideCursor(); - int PMSetCursorPos(); -}; - -class GFramePeer { -public: - GFrame *Frame; - QEFrame *qFrame; - - GFramePeer(GFrame *aFrame, int Width, int Height); - ~GFramePeer(); - - int ConSetTitle(char *Title, char *STitle); - int ConGetTitle(char *Title, int MaxLen, char *STitle, int SMaxLen); - - int ConSetSize(int X, int Y); - int ConQuerySize(int *X, int *Y); - void MapFrame(); - void ShowFrame(); -}; - -int ShowVScroll = 1; -int ShowHScroll = 0; -int ShowMenuBar = 1; -int ShowToolBar = 0; - -GFrame *frames = 0; -GUI *gui = 0; - -static GView *MouseCapture = 0; -static GView *FocusCapture = 0; - -static int cxChar = 1; -static int cyChar = 1; -static int fmAscent; -static int FinalExit = 0; - -TEvent EventBuf = { evNone }; - -typedef struct _qEvent { - TEvent event; - struct _qEvent *next; -} qEvent; - -TEvent NextEvent = { evNone }; -static QColor colors[16] = { - black, - darkBlue, - darkGreen, - darkCyan, - darkRed, - darkMagenta, - darkYellow, - gray, - - darkGray, - blue, - green, - cyan, - red, - magenta, - yellow, - white, -}; - -static XFontStruct *fontStruct; -static Display *display; - -static QPoint LastMousePos; - -static int LastMouseX = -1, LastMouseY = -1; - -static qEvent *event_head = 0; -static qEvent *event_tail = 0; - -static int qPutEvent(TEvent &Event) { - qEvent *q = new qEvent; - - q->event = Event; - q->next = 0; - - if (event_tail) { - event_tail->next = q; - event_tail = q; - } else { - event_head = event_tail = q; - } - FinalExit = 0; - qApp->exit_loop(); - return 0; -} - -static int qHasEvent() { - return event_head ? 1 : 0; -} - -static void qGetEvent(TEvent &Event) { - qEvent *q = event_head; - - Event = q->event; - event_head = q->next; - if (!event_head) - event_tail = 0; - delete q; -} - -QEView::QEView(GViewPeer *peer, QWidget *parent, const char *name): QFrame(parent, name) -{ - view = peer; - - text = new QEText(peer, this); - CHECK_PTR(text); - horz = new QScrollBar(QScrollBar::Horizontal, parent, 0); - CHECK_PTR(horz); - vert = new QScrollBar(QScrollBar::Vertical, parent, 0); - CHECK_PTR(vert); - horz->show(); - vert->show(); - - setFrameStyle(Panel|Sunken); - setLineWidth(EDIT_BORDER); - - connect(vert, SIGNAL(valueChanged(int)), SLOT(sbVmoveTo(int))); - connect(vert, SIGNAL(sliderMoved(int)), SLOT(sbVmoveTo(int))); - connect(vert, SIGNAL(prevLine()), SLOT(sbVmoveUp())); - connect(vert, SIGNAL(nextLine()), SLOT(sbVmoveDown())); - connect(vert, SIGNAL(prevPage()), SLOT(sbVpageUp())); - connect(vert, SIGNAL(nextPage()), SLOT(sbVpageDown())); - - connect(horz, SIGNAL(valueChanged(int)), SLOT(sbHmoveTo(int))); - connect(horz, SIGNAL(sliderMoved(int)), SLOT(sbHmoveTo(int))); - connect(horz, SIGNAL(prevLine()), SLOT(sbHmoveLeft())); - connect(horz, SIGNAL(nextLine()), SLOT(sbHmoveRight())); - connect(horz, SIGNAL(prevPage()), SLOT(sbHpageLeft())); - connect(horz, SIGNAL(nextPage()), SLOT(sbHpageRight())); -} - -QEView::~QEView() { - delete horz; - delete vert; -} - -void QEView::setViewPos(int x, int y, int w, int h) { - setGeometry(x, y, w - SCROLLBAR_SIZE, h - SCROLLBAR_SIZE); - text->setGeometry(contentsRect()); - vert->setGeometry(x + w - SCROLLBAR_SIZE, y, SCROLLBAR_SIZE, h - SCROLLBAR_SIZE); - horz->setGeometry(x, y + h - SCROLLBAR_SIZE, w - SCROLLBAR_SIZE, SCROLLBAR_SIZE); -} - -void QEView::ActiveEvent(TEvent &Event) { - if (!view->View->IsActive()) - view->View->Parent->SelectView(view->View); - qPutEvent(Event); -} - -void QEView::sbHmoveLeft() { - NextEvent.What = evCommand; - NextEvent.Msg.View = view->View; - NextEvent.Msg.Command = cmHScrollLeft; - ActiveEvent(NextEvent); -} - -void QEView::sbHmoveRight() { - NextEvent.What = evCommand; - NextEvent.Msg.View = view->View; - NextEvent.Msg.Command = cmHScrollRight; - ActiveEvent(NextEvent); -} - -void QEView::sbHpageLeft() { - NextEvent.What = evCommand; - NextEvent.Msg.View = view->View; - NextEvent.Msg.Command = cmHScrollPgLt; - ActiveEvent(NextEvent); -} - -void QEView::sbHpageRight() { - NextEvent.What = evCommand; - NextEvent.Msg.View = view->View; - NextEvent.Msg.Command = cmHScrollPgRt; - ActiveEvent(NextEvent); -} - -void QEView::sbHmoveTo(int pos) { - NextEvent.What = evCommand; - NextEvent.Msg.View = view->View; - NextEvent.Msg.Command = cmHScrollMove; - NextEvent.Msg.Param1 = pos; - ActiveEvent(NextEvent); -} - -void QEView::sbVmoveUp() { - NextEvent.What = evCommand; - NextEvent.Msg.View = view->View; - NextEvent.Msg.Command = cmVScrollUp; - ActiveEvent(NextEvent); -} - -void QEView::sbVmoveDown() { - NextEvent.What = evCommand; - NextEvent.Msg.View = view->View; - NextEvent.Msg.Command = cmVScrollDown; - ActiveEvent(NextEvent); -} - -void QEView::sbVpageUp() { - NextEvent.What = evCommand; - NextEvent.Msg.View = view->View; - NextEvent.Msg.Command = cmVScrollPgUp; - ActiveEvent(NextEvent); -} - -void QEView::sbVpageDown() { - NextEvent.What = evCommand; - NextEvent.Msg.View = view->View; - NextEvent.Msg.Command = cmVScrollPgDn; - ActiveEvent(NextEvent); -} - -void QEView::sbVmoveTo(int pos) { - NextEvent.What = evCommand; - NextEvent.Msg.View = view->View; - NextEvent.Msg.Command = cmVScrollMove; - NextEvent.Msg.Param1 = pos; - ActiveEvent(NextEvent); -} - - -QEText::QEText(GViewPeer *peer, QWidget *parent, const char *name): QWidget(parent, name) { - view = peer; - - setAcceptFocus(TRUE); - setMinimumSize(100, 80); -} - -QEText::~QEText() { -} - -void QEText::resizeEvent(QResizeEvent *qe) { - int X, Y; - - DEBUGX(("A: %X\n", qe)); - QWidget::resizeEvent(qe); - DEBUGX(("B\n")); - - X = qe->size().width(); - Y = qe->size().height(); //qe->size().height() - frameWidth() * 2; - DEBUGX(("Resize %d, %d\n", X, Y)); - X /= cxChar; - Y /= cyChar; - DEBUGX(("!! Resize %d, %d\n", X, Y)); - if (X > 0 && Y > 0) { - view->ConSetSize(X, Y); - NextEvent.What = evCommand; - NextEvent.Msg.View = view->View; - NextEvent.Msg.Command = cmResize; - qPutEvent(NextEvent); - } -} - -void QEText::paintEvent(QPaintEvent *qe) { - view->UpdateWindow(qe->rect().x(), - qe->rect().y(), - qe->rect().width(), - qe->rect().height()); -} - -void QEText::handleMouse(QMouseEvent *qe) { - int event = qe->button(); - int state = qe->state(); - int X = (qe->pos().x()/* - frameWidth()*/) / cxChar; - int Y = (qe->pos().y()/* - frameWidth()*/) / cyChar; - - NextEvent.Mouse.View = view->View; - - LastMousePos = mapToGlobal(qe->pos()); - - switch (qe->type()) { - case Event_MouseButtonPress: - case Event_MouseButtonDblClick: - if (!view->View->IsActive()) - view->View->Parent->SelectView(view->View); - NextEvent.What = evMouseDown; - break; - case Event_MouseButtonRelease: - NextEvent.What = evMouseUp; - break; - case Event_MouseMove: - NextEvent.What = evMouseMove; - break; - default: - return ; - } - NextEvent.Mouse.Buttons = 0; - - if (NextEvent.What == evMouseMove) { - if (state & LeftButton) - NextEvent.Mouse.Buttons |= 1; - if (state & RightButton) - NextEvent.Mouse.Buttons |= 2; - if (state & MidButton) - NextEvent.Mouse.Buttons |= 4; - } else { - if (event & LeftButton) - NextEvent.Mouse.Buttons |= 1; - if (event & RightButton) - NextEvent.Mouse.Buttons |= 2; - if (event & MidButton) - NextEvent.Mouse.Buttons |= 4; - } - NextEvent.Mouse.KeyMask = 0; - if (state & ShiftButton) - NextEvent.Mouse.KeyMask |= kfShift; - if (state & ControlButton) - NextEvent.Mouse.KeyMask |= kfCtrl; - if (state & AltButton) - NextEvent.Mouse.KeyMask |= kfAlt; - - NextEvent.Mouse.Count = 1; - if (qe->type() == Event_MouseButtonDblClick) - NextEvent.Mouse.Count = 2; - NextEvent.Mouse.X = X; - NextEvent.Mouse.Y = Y; - qPutEvent(NextEvent); -} - - -void QEText::mousePressEvent(QMouseEvent *qe) { - handleMouse(qe); -} - -void QEText::mouseMoveEvent(QMouseEvent *qe) { - handleMouse(qe); -} - -void QEText::mouseReleaseEvent(QMouseEvent *qe) { - handleMouse(qe); -} - -static struct { - unsigned int q_code; - TKeyCode keyCode; -} key_table[] = { -{ Key_Escape, kbEsc }, -{ Key_Tab, kbTab }, -{ Key_Backtab, kbTab | kfShift }, -{ Key_Backspace, kbBackSp }, -{ Key_Return, kbEnter }, -{ Key_Enter, kbEnter }, -{ Key_Insert, kbIns }, -{ Key_Delete, kbDel }, -{ Key_Pause, kbPause }, -{ Key_Print, kbPrtScr }, -{ Key_SysReq, kbSysReq }, -{ Key_Home, kbHome }, -{ Key_End, kbEnd }, -{ Key_Left, kbLeft }, -{ Key_Up, kbUp }, -{ Key_Right, kbRight }, -{ Key_Down, kbDown }, -{ Key_Prior, kbPgUp }, -{ Key_Next, kbPgDn }, -{ Key_Shift, kbShift | kfModifier }, -{ Key_Control, kbCtrl | kfModifier }, -{ Key_Meta, kbAlt | kfModifier }, -{ Key_Alt, kbAlt | kfModifier }, -{ Key_CapsLock, kbCapsLock | kfModifier }, -{ Key_NumLock, kbNumLock | kfModifier }, -{ Key_ScrollLock, kbScrollLock | kfModifier }, -{ Key_F1, kbF1 }, -{ Key_F2, kbF2 }, -{ Key_F3, kbF3 }, -{ Key_F4, kbF4 }, -{ Key_F5, kbF5 }, -{ Key_F6, kbF6 }, -{ Key_F7, kbF7 }, -{ Key_F8, kbF8 }, -{ Key_F9, kbF9 }, -{ Key_F10, kbF10 }, -{ Key_F11, kbF11 }, -{ Key_F12, kbF12 }, -}; - -void QEText::ActiveEvent(TEvent &Event) { - if (!view->View->IsActive()) - view->View->Parent->SelectView(view->View); - qPutEvent(Event); -} - -void QEText::handleKeyPressEvent(QKeyEvent *qe) { - TKeyCode keyCode; - TKeyCode keyFlags; - int state = qe->state(); - int ascii = qe->ascii(); - int key = qe->key(); - - DEBUGX(("key: %d, ascii: %d(%c) state:%X\n", - qe->key(), - qe->ascii(), - qe->ascii(), - qe->state())); - - keyFlags = 0; - if (state & ShiftButton) - keyFlags |= kfShift; - if (state & ControlButton) - keyFlags |= kfCtrl; - if (state & AltButton) - keyFlags |= kfAlt; - - keyCode = 0; - for (int i = 0; i < (sizeof(key_table)/sizeof(key_table[0])); i++) { - if (key == key_table[i].q_code) { - keyCode = key_table[i].keyCode; - break; - } - } - if (keyCode == 0 && ascii != 0) { - if (keyFlags & (kfCtrl | kfAlt)) { - keyCode = toupper(ascii); - } else { - keyCode = ascii; - } - } - if (keyCode == 0) { - QWidget::keyPressEvent(qe); - return; - } - - DEBUGX(("key: %d, flags:%d\n", keyCode, keyFlags)); - - NextEvent.What = evKeyDown; - NextEvent.Key.View = view->View; - NextEvent.Key.Code = keyCode | keyFlags; - qPutEvent(NextEvent); -} - -void QEText::keyPressEvent(QKeyEvent *qe) { - handleKeyPressEvent(qe); -} - -//void QEFrame::keyPressEvent(QKeyEvent *qe) { -// frame->Frame->Active->Peer->qView->handleKeyPressEvent(qe); -//} - -void QEText::focusInEvent(QFocusEvent *qe) { - //repaint(FALSE); - DEBUGX(("got focus\n")); -} - -void QEText::focusOutEvent(QFocusEvent *qe) { - //repaint(FALSE); - DEBUGX(("lost focus\n")); -} - -QEFrame::QEFrame(GFramePeer *peer, QWidget *parent, const char *name): QFrame(parent, name) -{ - frame = peer; - menubar = 0; - //setAcceptFocus(TRUE); -} - -void QEFrame::resizeEvent(QResizeEvent *qe) { - int y = 0; - int x = 0; - int h = qe->size().height(); - int w = qe->size().width(); - int count, cur; - int cy, ch; - - GView *p; - - if (menubar) { - h -= menubar->height(); - y += menubar->height(); - } - - p = frame->Frame->Top; - count = 0; - if (p) do { - count++; - p = p->Next; - } while (p != frame->Frame->Top); - - DEBUGX(("count: %d size: %d %d\n", count, w, h)); - - p = frame->Frame->Top; - cur = 0; - if (p) do { - ch = h / count; - if (p->Next == frame->Frame->Top) - ch = h - (h / count) * (count - 1); - cy = y + h * cur / count; - cur++; - DEBUGX(("setting: %d %d %d %d\n", x, cy, w, ch)); - p->Peer->qView->setViewPos(x, cy, w, ch); - p = p->Next; - } while (p != frame->Frame->Top); - -// frame->Frame->Top->Peer->qView->SetViewGeom(x, y, w, h); -} - -void QEFrame::closeEvent(QCloseEvent *qe) { - DEBUGX(("Close Selected: %d\n", id)); - NextEvent.What = evCommand; - NextEvent.Msg.View = frame->Frame->Active; - NextEvent.Msg.Command = cmClose; - qPutEvent(NextEvent); -} - -void QEFrame::selectedMain(int id) { - DEBUGX(("Menu Selected: %d\n", id)); - NextEvent.What = evCommand; - NextEvent.Msg.View = frame->Frame->Active; - NextEvent.Msg.Command = id; - qPutEvent(NextEvent); -} - -#include "g_qt.moc" - -#if 0 - -void ProcessXEvents(XEvent *event, TEvent *Event, GViewPeer *Peer) { - XAnyEvent *anyEvent = (XAnyEvent *) event; - XExposeEvent *exposeEvent = (XExposeEvent *) event; - XButtonEvent *buttonEvent = (XButtonEvent *) event; - XKeyEvent *keyEvent = (XKeyEvent *) event; - XKeyEvent keyEvent1; - XConfigureEvent *configureEvent = (XConfigureEvent *) event; - XGraphicsExposeEvent *gexposeEvent = (XGraphicsExposeEvent *) event; - XMotionEvent *motionEvent = (XMotionEvent *) event; - KeySym key, key1; - int state; - char keyName[32]; - char keyName1[32]; - static int hasConfig = 0; - - Event->What = evNone; - Event->Msg.View = Peer->View; - - switch (event->type) { - case ButtonRelease: - case ButtonPress: - LastRelease = *buttonEvent; - ConvertClickToEvent(event->type, buttonEvent->x, buttonEvent->y, buttonEvent->button, buttonEvent->state, Event, motionEvent->time); - break; - case KeyPress: - case KeyRelease: - state = keyEvent->state; - - keyEvent1 = *keyEvent; - keyEvent1.state &= ~(ShiftMask | ControlMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask); - - XLookupString(keyEvent, keyName, sizeof(keyName), &key, 0); - XLookupString(&keyEvent1, keyName1, sizeof(keyName1), &key1, 0); - //key1 = XLookupKeysym(keyEvent, 0); - ConvertKeyToEvent(key, key1, keyName, event->type, state, Event); - break; - case MotionNotify: - ConvertClickToEvent(event->type, motionEvent->x, motionEvent->y, 0, motionEvent->state, Event, motionEvent->time); - break; - } -} - -static void CloseWindow(Widget w, GFramePeer *frame, XEvent *event, Boolean *cont) { - if (event->type != ClientMessage || - ((XClientMessageEvent *)event)->data.l[0] != WM_DELETE_WINDOW) - { - return ; - } - NextEvent.What = evCommand; - NextEvent.Msg.Command = cmClose; - *cont = False; -} - -#endif -/////////////////////////////////////////////////////////////////////////// - -GViewPeer::GViewPeer(GView *view, int XSize, int YSize) { - - View = view; - - // wX = 0; - // wY = 0; - wW = XSize; - wH = YSize; - sbVtotal = 0; - sbVstart = 0; - sbVamount = 0; - sbHtotal = 0; - sbHstart = 0; - sbHamount = 0; - wState = 0; - cVisible = 1; - cStart = 0; // % - cEnd = 100; - wRefresh = 0; - ScreenBuffer = 0; - cX = -1; - cY = -1; - VertPos = HorzPos = -1; - - for (int jj = 0; jj < 256; jj++) - GCs[jj] = 0; - - qView = new QEView(this, frames->Peer->qFrame); - qView->show(); -} - -GViewPeer::~GViewPeer() { - delete qView; -} - -int GViewPeer::AllocBuffer() { - int i; - unsigned char *p; - - ScreenBuffer = (unsigned char *)malloc(2 * wW * wH); - if (ScreenBuffer == NULL) return -1; - for (i = 0, p = ScreenBuffer; i < wW * wH; i++) { - *p++ = 32; - *p++ = 0x07; - } - return 0; -} - -#define InRange(x,a,y) (((x) <= (a)) && ((a) < (y))) -#define CursorXYPos(x,y) (ScreenBuffer + ((x) + ((y) * wW)) * 2) - -void GViewPeer::DrawCursor(/*QPainter *painter, */int Show) { - if (!(View && View->Parent)) - return ; - - if (qView->text->winId() == 0) - return ; - - if (!(wState & sfFocus)) - Show = 0; - - if (cX >= wW || cY >= wW || - cX + 1 > wW || cY + 1 > wH) - { - DEBUGX(("bounds %d %d\n", wW, wH)); - return; - } - - DEBUGX(("DrawCursor %d %d\n", cX, cY)); - // if (!XtIsManaged(TextWin)) return ; - - if (cVisible && cX >= 0 && cY >= 0) { - char *p = CursorXYPos(cX, cY); - unsigned char attr; - - attr = p[1]; - //if (Show) attr = ((((attr << 4) & 0xF0)) | (attr >> 4)) ^ 0x77; - if (Show) attr = (attr ^ 0x77); - - if (GCs[attr] == 0) { - XGCValues gcv; - - gcv.foreground = colors[attr & 0xF].pixel(); - gcv.background = colors[(attr >> 4) & 0xF].pixel(); - gcv.font = fontStruct->fid; - GCs[attr] = XCreateGC(display, qView->text->winId(), - GCForeground | GCBackground | GCFont, - &gcv); - } - - XDrawImageString(display, qView->text->winId(), GCs[attr & 0xFF], - /*qView->frameWidth() +*/ cX * cxChar, - /*qView->frameWidth() +*/ fontStruct->max_bounds.ascent + cY * cyChar, - (char *)p, 1); - - /*inter->setPen(colors[attr & 0xF]); - painter->setBackgroundColor(colors[(attr >> 4) & 0xF]); - - painter->drawText(qView->frameWidth() + cX * cxChar, - qView->frameWidth() + cY * cyChar + fmAscent, - p, 1);*/ - } -} - -int GViewPeer::ConPutBox(int X, int Y, int W, int H, PCell Cell) { - int i; - unsigned char temp[256], attr; - unsigned char *p, *ps, *c, *ops; - int len, x, l, ox, olen, skip; - //int local_painter = 0; - - - if (!(View && View->Parent)) - return 1; - - if (qView->text->winId() == 0) - return 1; - - //if (Visibility == VisibilityFullyObscured) - // return - 1; - - if (X >= wW || Y >= wH || - X + W > wW || Y + H > wH) - { - DEBUGX(("bounds %d %d\n",wW, wH)); - return -1; - } - - /*if (qView->Painter == 0) { - DEBUGX(("{{{ New painter\n")); - qView->Painter = new QPainter(); - qView->Painter->begin(qView); - local_painter = 1; - } - qView->Painter->setBackgroundMode(OpaqueMode); - qView->Painter->setFont(Font);*/ - - DEBUGX(("PutBox %d | %d %d %d %d | %d %d\n", wRefresh, X, Y, W, H, wW, wH)); - for (i = 0; i < H; i++) { - len = W; - p = CursorXYPos(X, Y + i); - ps = (unsigned char *) Cell; - x = X; - while (len > 0) { - if (!wRefresh) { - c = CursorXYPos(x, Y + i); - skip = 0; - ops = ps; - ox = x; - olen = len; - while ((len > 0) && (*(unsigned short *) c == *(unsigned short *)ps)) x++, len--, ps+=2, c+=2, skip++; - if (len <= 0) break; - if (skip <= 4) { - ps = ops; - x = ox; - len = olen; - } - } - p = ps; - l = 1; - temp[0] = *ps++; attr = *ps++; - while ((l < len) && ((unsigned char) (ps[1]) == attr)) { - temp[l++] = *ps++; - ps++; - } - - /*qView->Painter->setPen(colors[attr & 0xF]); - qView->Painter->setBackgroundColor(colors[(attr >> 4) & 0xF]); - - qView->Painter->drawText(qView->frameWidth() + x * cxChar, - qView->frameWidth() + (Y + i) * cyChar + fmAscent, - (char *)temp, l);*/ - - if (GCs[attr] == 0) { - XGCValues gcv; - - gcv.foreground = colors[attr & 0xF].pixel(); - gcv.background = colors[(attr >> 4) & 0xF].pixel(); - gcv.font = fontStruct->fid; - GCs[attr] = XCreateGC(display, qView->text->winId(), - GCForeground | GCBackground | GCFont, - &gcv); - } - - XDrawImageString(display, qView->text->winId(), GCs[attr & 0xFF], - /*qView->frameWidth() +*/ x * cxChar, - /*qView->frameWidth() +*/ fontStruct->max_bounds.ascent + (Y + i) * cyChar, - (char *)temp, l); - - x += l; - len -= l; - } - p = CursorXYPos(X, Y + i); - memcpy(p, Cell, W * 2); - if (i + Y == cY) - DrawCursor(1); - Cell += W; - } - /*if (local_painter) { - DEBUGX(("}}} Destroying painter\n")); - qView->Painter->end(); - delete qView->Painter; - qView->Painter = 0; - }*/ - DEBUGX(("done putbox\n")); - return 0; -} - -void GViewPeer::UpdateWindow(int xx, int yy, int ww, int hh) { - PCell p; - int i; - ww /= cxChar; ww += 2; - hh /= cyChar; hh += 2; - xx /= cxChar; - yy /= cyChar; - if (xx + ww > wW) ww = wW - xx; - if (yy + hh > wH) hh = wH - yy; - wRefresh = 1; - p = (PCell) CursorXYPos(xx, yy); - for (i = 0; i < hh; i++) { - ConPutBox(xx, yy + i, ww, 1, p); - p += wW; - } - //XFlush(display); - wRefresh = 0; -} - -int GViewPeer::ConGetBox(int X, int Y, int W, int H, PCell Cell) { - int i; - - for (i = 0; i < H; i++) { - memcpy(Cell, CursorXYPos(X, Y + i), 2 * W); - Cell += W; - } - return 0; -} - -int GViewPeer::ConPutLine(int X, int Y, int W, int H, PCell Cell) { - int i; - - for (i = 0; i < H; i++) { - if (ConPutBox(X, Y + i, W, 1, Cell) != 0) return -1; - } - return 0; -} - -int GViewPeer::ConSetBox(int X, int Y, int W, int H, TCell Cell) { - TDrawBuffer B; - int i; - - for (i = 0; i < W; i++) B[i] = Cell; - ConPutLine(X, Y, W, H, B); - return 0; -} - -int GViewPeer::ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count) { - TCell Cell; - int l; - int fw = 0; //qView->frameWidth(); - - if (qView->text->winId() == 0) - return 1; - - if (GCs[Fill] == 0) { - XGCValues gcv; - - gcv.foreground = colors[Fill & 0xF].pixel(); - gcv.background = colors[(Fill >> 4) & 0xF].pixel(); - gcv.font = fontStruct->fid; - GCs[Fill] = XCreateGC(display, qView->text->winId(), - GCForeground | GCBackground | GCFont, - &gcv); - } - - MoveCh(&Cell, ' ', Fill, 1); - DrawCursor(0); - if (Way == csUp) { - XCopyArea(display, qView->text->winId(), qView->text->winId(), GCs[Fill], - fw + X * cxChar, - fw + (Y + Count) * cyChar, - W * cxChar, - (H - Count) * cyChar, - fw + X * cxChar, - fw + Y * cyChar - ); - for (l = 0; l < H - Count; l++) { - memcpy(CursorXYPos(X, Y + l), CursorXYPos(X, Y + l + Count), 2 * W); - } - if (ConSetBox(X, Y + H - Count, W, Count, Cell) == -1) return -1; - } else if (Way == csDown) { - XCopyArea(display, qView->text->winId(), qView->text->winId(), GCs[Fill], - fw + X * cxChar, - fw + Y * cyChar, - W * cxChar, - (H - Count) * cyChar, - fw + X * cxChar, - fw + (Y + Count)* cyChar - ); - for (l = H - 1; l >= Count; l--) { - memcpy(CursorXYPos(X, Y + l), CursorXYPos(X, Y + l - Count), 2 * W); - } - if (ConSetBox(X, Y, W, Count, Cell) == -1) return -1; - } - DrawCursor(1); - return 0; - - /*TCell Cell; - int l; - - MoveCh(&Cell, ' ', Fill, 1); - QPainter painter; - painter.begin(qView); - painter.setBackgroundMode(OpaqueMode); - painter.setFont(Font); - DrawCursor(&painter, 0); - if (Way == csUp) { - bitBlt(qView, - qView->frameWidth() + X * cxChar, - qView->frameWidth() + Y * cyChar, - qView, - qView->frameWidth() + X * cxChar, - qView->frameWidth() + (Y + Count) * cyChar, - W * cxChar, (H - Count) * cyChar, - CopyROP, TRUE); - for (l = 0; l < H - Count; l++) { - memcpy(CursorXYPos(X, Y + l), CursorXYPos(X, Y + l + Count), 2 * W); - } - } else if (Way == csDown) { - bitBlt(qView, - qView->frameWidth() + X * cxChar, - qView->frameWidth() + (Y + Count) * cyChar, - qView, - qView->frameWidth() + X * cxChar, - qView->frameWidth() + Y * cyChar, - W * cxChar, (H - Count) * cyChar, - CopyROP, TRUE); - for (l = H - 1; l >= Count; l--) { - memcpy(CursorXYPos(X, Y + l), CursorXYPos(X, Y + l - Count), 2 * W); - } - } - DrawCursor(&painter, 1); - painter.end(); - if (Way == csUp) { - ConSetBox(X, Y, W, Count, Cell); - } else if (Way == csDown) { - ConSetBox(X, Y + H - Count, W, Count, Cell); - } - return 0;*/ -} - -int GViewPeer::ConSetSize(int X, int Y) { - unsigned char *NewBuffer; - unsigned char *p; - int i; - unsigned int MX, MY; - - p = NewBuffer = (unsigned char *) malloc(X * Y * 2); - if (NewBuffer == NULL) return -1; - for (i = 0; i < X * Y; i++) { - *p++ = ' '; - *p++ = 0x07; - } - if (ScreenBuffer) { - MX = wW; if (X < MX) MX = X; - MY = wH; if (Y < MY) MY = Y; - if (X < MX) MX = X; - p = NewBuffer; - for (i = 0; i < MY; i++) { - memcpy(p, CursorXYPos(0, i), MX * 2); - p += X * 2; - } - free(ScreenBuffer); - } - ScreenBuffer = NewBuffer; - wW = X; - wH = Y; - wRefresh = 1; - View->Resize(wW, wH); - ConPutBox(0, 0, wW, wH, (PCell) ScreenBuffer); - wRefresh = 0; -// if (Refresh == 0) -// qView->setSize(0, -// XResizeWindow(display, win, ScreenCols * cxChar, ScreenRows * cyChar); - qView->show(); - return 1; -} - -int GViewPeer::ConQuerySize(int *X, int *Y) { - if (X) *X = wW; - if (Y) *Y = wH; - return 1; -} - -int GViewPeer::ConSetCursorPos(int X, int Y) { - if (X < 0) X = 0; - if (X >= wW) X = wW - 1; - if (Y < 0) Y = 0; - if (Y >= wH) Y = wH - 1; - - /*QPainter painter; - painter.begin(qView); - painter.setBackgroundMode(OpaqueMode); - painter.setFont(Font);*/ - DrawCursor(0); - cX = X; - cY = Y; - DrawCursor(1); - //painter.end(); - return 1; -} - -int GViewPeer::ConQueryCursorPos(int *X, int *Y) { - if (X) *X = cX; - if (Y) *Y = cY; - return 1; -} - -int GViewPeer::ConShowCursor() { - cVisible = 1; -// DrawCursor(1); - return 1; -} - -int GViewPeer::ConHideCursor() { - cVisible = 0; - // DrawCursor(0); - return 1; -} - -int GViewPeer::ConCursorVisible() { - return cVisible; -} - -int GViewPeer::ConSetCursorSize(int Start, int End) { - cStart = Start; - cEnd = End; - if (wState & sfFocus) - return 1; //PMSetCursorSize(Start, End); - else - return 1; -} - -int GViewPeer::ExpandHeight(int DeltaY) { - return 0; -} - -int GViewPeer::QuerySbVPos() { - return sbVstart; -} - -int GViewPeer::SetSbVPos(int Start, int Amount, int Total) { - if (sbVstart != Start || - sbVamount != Amount || - sbVtotal != Total) - { - sbVstart = Start; - sbVamount = Amount; - sbVtotal = Total; - - if (View->Parent == 0) - return 0; - if (Amount < 1 || Start + Amount > Total) { - qView->vert->setRange(0, 0); - qView->vert->setSteps(0, 0); - qView->vert->setValue(0); - } else { - qView->vert->setRange(0, Total - Amount); - qView->vert->setSteps(1, Amount); - qView->vert->setValue(Start); - } - } - return 1; -} - -int GViewPeer::SetSbHPos(int Start, int Amount, int Total) { - if (sbHstart != Start || - sbHamount != Amount || - sbHtotal != Total) - { - sbHstart = Start; - sbHamount = Amount; - sbHtotal = Total; - - if (View->Parent == 0) - return 0; - - if (Amount < 1 || Start + Amount > Total) { - qView->horz->setRange(0, 0); - qView->horz->setSteps(0, 0); - qView->horz->setValue(0); - } else { - qView->horz->setRange(0, Total - Amount); - qView->horz->setSteps(1, Amount); - qView->horz->setValue(Start); - } - } - return 1; -} - -int GViewPeer::UpdateCursor() { - ConSetCursorPos(cX, cY); - ConSetCursorSize(cStart, cEnd); - if (cVisible) - ConShowCursor(); - else - ConHideCursor(); - return 1; -} - -int GViewPeer::PMShowCursor() { - return 1; -} - -int GViewPeer::PMHideCursor() { - return 1; -} - -int GViewPeer::PMSetCursorPos() { - return 1; -} - -/////////////////////////////////////////////////////////////////////////// - -GView::GView(GFrame *parent, int XSize, int YSize) { - Parent = parent; - Prev = Next = 0; - Peer = new GViewPeer(this, XSize, YSize); - if (Parent) - Parent->AddView(this); -} - -GView::~GView() { - if (Parent) - Parent->RemoveView(this); - if (Peer) - delete Peer; -} - -int GView::ConClear() { - int W, H; - TDrawBuffer B; - - ConQuerySize(&W, &H); - MoveChar(B, 0, W, ' ', 0x07, 1); - ConSetBox(0, 0, W, H, B[0]); - return 1; -} - -int GView::ConPutBox(int X, int Y, int W, int H, PCell Cell) { - return Peer->ConPutBox(X, Y, W, H, Cell); -} - -int GView::ConGetBox(int X, int Y, int W, int H, PCell Cell) { - return Peer->ConGetBox(X, Y, W, H, Cell); -} - -int GView::ConPutLine(int X, int Y, int W, int H, PCell Cell) { - return Peer->ConPutLine(X, Y, W, H, Cell); -} - -int GView::ConSetBox(int X, int Y, int W, int H, TCell Cell) { - return Peer->ConSetBox(X, Y, W, H, Cell); -} - -int GView::ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count) { - return Peer->ConScroll(Way, X, Y, W, H, Fill, Count); -} - -int GView::ConSetSize(int X, int Y) { - if (Peer->ConSetSize(X, Y)) ; -// Resize(X, Y); - else - return 0; - return 1; -} - -int GView::ConQuerySize(int *X, int *Y) { - return Peer->ConQuerySize(X, Y); -} - -int GView::ConSetCursorPos(int X, int Y) { - return Peer->ConSetCursorPos(X, Y); -} - -int GView::ConQueryCursorPos(int *X, int *Y) { - return Peer->ConQueryCursorPos(X, Y); -} - -int GView::ConShowCursor() { - return Peer->ConShowCursor(); -} - -int GView::ConHideCursor() { - return Peer->ConHideCursor(); -} - -int GView::ConCursorVisible() { - return Peer->ConCursorVisible(); -} - -int GView::ConSetCursorSize(int Start, int End) { - return Peer->ConSetCursorSize(Start, End); -} - -int GView::QuerySbVPos() { - return Peer->QuerySbVPos(); -} - -int GView::SetSbVPos(int Start, int Amount, int Total) { - return Peer->SetSbVPos(Start, Amount, Total); -} - -int GView::SetSbHPos(int Start, int Amount, int Total) { - return Peer->SetSbHPos(Start, Amount, Total); -} - -int GView::ExpandHeight(int DeltaY) { - return Peer->ExpandHeight(DeltaY); -} - -void GView::Update() { -} - -void GView::Repaint() { -} - -void GView::HandleEvent(TEvent &Event) { -} - -void GView::Resize(int width, int height) { - Repaint(); -} - -void GView::EndExec(int NewResult) { - Result = NewResult; -} - -int GView::Execute() { - int SaveRc = Result; - int NewResult; - - Result = -2; - while (Result == -2 && frames != 0) - gui->ProcessEvent(); - NewResult = Result; - Result = SaveRc; - return NewResult; -} - -int GView::IsActive() { - return (Parent->Active == this); -} - -void GView::Activate(int gotfocus) { - if (gotfocus) { - Peer->wState |= sfFocus; - Peer->UpdateCursor(); - } else { - Peer->wState &= ~sfFocus; - } - Repaint(); -} - -int GView::CaptureMouse(int grab) { - if (MouseCapture == 0) { - if (grab) - MouseCapture = this; - else - return 0; - } else { - if (grab || MouseCapture != this) - return 0; - else - MouseCapture = 0; - } - return 1; -} - -/////////////////////////////////////////////////////////////////////////// - -GFramePeer::GFramePeer(GFrame *aFrame, int Width, int Height) { - Frame = aFrame; - qFrame = new QEFrame(this, 0, 0); - CHECK_PTR(qFrame); - - if (Width != -1 && Height != -1) - ConSetSize(Width, Height); -} - -GFramePeer::~GFramePeer() { - delete qFrame; -} - -int GFramePeer::ConSetSize(int X, int Y) { - //return ::ConSetSize(X, Y); - return 0; -} - -int GFramePeer::ConQuerySize(int *X, int *Y) { -// ::ConQuerySize(&fW, &fH); -// if (X) *X = fW; -// if (Y) *Y = fH; - return 1; -} - -//int GFrame::ConQuerySize(int *X, int *Y) { -// ::ConQuerySize(X, Y); -// if (ShowVScroll) -// --*X; -//} - -int GFramePeer::ConSetTitle(char *Title, char *STitle) { - qFrame->setCaption(Title); - qFrame->setIconText(STitle); - return 1; -} - -int GFramePeer::ConGetTitle(char *Title, int MaxLen, char *STitle, int SMaxLen) { - strncpy(Title, qFrame->caption(), MaxLen); - Title[MaxLen - 1] = 0; - strncpy(STitle, qFrame->iconText(), SMaxLen); - STitle[SMaxLen - 1] = 0; - return 1; -} - -void GFramePeer::MapFrame() { - qApp->setMainWidget(qFrame); - qFrame->menubar->show(); - - int menubarHeight = - qFrame->menubar->height(); - - qFrame->setMinimumSize(30 * cxChar + SCROLLBAR_SIZE + EDIT_BORDER * 2, - 8 * cyChar + SCROLLBAR_SIZE + EDIT_BORDER * 2 + - menubarHeight); - qFrame->setMaximumSize(160 * cxChar + SCROLLBAR_SIZE + EDIT_BORDER * 2, - 100 * cyChar + SCROLLBAR_SIZE + EDIT_BORDER * 2 + - menubarHeight); - - qFrame->resize(80 * cxChar + SCROLLBAR_SIZE + EDIT_BORDER * 2, - 40 * cyChar + SCROLLBAR_SIZE + EDIT_BORDER * 2 + - menubarHeight); - qFrame->show(); - - // qFrame->setSizeIncrement(cxChar, cyChar); - { - XSizeHints hints; - - hints.flags = PBaseSize | PResizeInc; - hints.width_inc = cxChar; - hints.height_inc = cyChar; - hints.base_width = SCROLLBAR_SIZE + EDIT_BORDER * 2; - hints.base_height = SCROLLBAR_SIZE + EDIT_BORDER * 2 + menubarHeight; - - XSetWMNormalHints(display, qFrame->winId(), &hints); - } -} - -void GFramePeer::ShowFrame() { - qFrame->show(); -} - -/////////////////////////////////////////////////////////////////////////// - -GFrame::GFrame(int XSize, int YSize) { - Menu = 0; - if (frames == 0) { - frames = Prev = Next = this; - } else { - Next = frames->Next; - Prev = frames; - frames->Next->Prev = this; - frames->Next = this; - frames = this; - } - Top = Active = 0; - Peer = new GFramePeer(this, XSize, YSize); -} - -GFrame::~GFrame() { - if (Peer) { - delete Peer; - Peer = 0; - } - if (Next == this) { - frames = 0; -// DEBUGX(("No more frames\x7\x7\n")); - } else { - Next->Prev = Prev; - Prev->Next = Next; - frames = Next; - } - Next = Prev = 0; -} - -int GFrame::ConSetTitle(char *Title, char *STitle) { - return Peer->ConSetTitle(Title, STitle); -} - -int GFrame::ConGetTitle(char *Title, int MaxLen, char *STitle, int SMaxLen) { - return Peer->ConGetTitle(Title, MaxLen, STitle, SMaxLen); -} - -int GFrame::ConSetSize(int X, int Y) { - return Peer->ConSetSize(X, Y); -} - -int GFrame::ConQuerySize(int *X, int *Y) { - return Peer->ConQuerySize(X, Y); -} - -int GFrame::ConSplitView(GView *view, GView *newview) { - int dmy; - - newview->Parent = this; -// newview->Peer->wX = 0; - ConQuerySize(&newview->Peer->wW, &dmy); -// newview->Peer->wY = view->Peer->wY + view->Peer->wH / 2; - newview->Peer->wH = view->Peer->wH - view->Peer->wH / 2; - view->Peer->wH /= 2; - InsertView(view, newview); - view->ConSetSize(view->Peer->wW, view->Peer->wH); - newview->ConSetSize(newview->Peer->wW, newview->Peer->wH); - return 0; -} - -int GFrame::ConCloseView(GView *view) { - return 0; -} - -int GFrame::ConResizeView(GView *view, int DeltaY) { - return 0; -} - -int GFrame::AddView(GView *view) { - if (Top != 0) { - return ConSplitView(Top, view); - } else { -// int W, H; - - view->Parent = this; - view->Prev = view->Next = 0; - -// view->Peer->wX = 0; -// view->Peer->wY = 0; -// ConQuerySize(&W, &H); -// view->ConSetSize(W, H); - InsertView(Top, view); - return 0; - } -} - -void GFrame::Update() { - GView *v = Active; - - UpdateMenu(); - while (v) { - v->Update(); - v = v->Next; - if (v == Active) - break; - } -} - -void GFrame::UpdateMenu() { -} - -void GFrame::Repaint() { - GView *v = Active; - - while (v) { - v->Repaint(); - v = v->Next; - if (v == Active) - break; - } -} - -void GFrame::InsertView(GView *Prev, GView *view) { - if (!view) return ; - if (Prev) { - view->Prev = Prev; - view->Next = Prev->Next; - Prev->Next = view; - view->Next->Prev = view; - } else { - view->Prev = view->Next = view; - Top = view; - } - if (Active == 0) { - Active = view; - Active->Activate(1); - } -} - -void GFrame::RemoveView(GView *view) { - if (!view) return ; - - if (Active == view) - Active->Activate(0); - if (view->Next == view) { - Top = Active = 0; - delete this; - } else { - view->Next->Prev = view->Prev; - view->Prev->Next = view->Next; - - if (Top == view) { - Top = view->Next; -// Top->Peer->wY -= view->Peer->wH; -// Top->ConSetSize(Top->Peer->wW, Top->Peer->wH + view->Peer->wH); - } else { -// view->Prev->ConSetSize(view->Prev->Peer->wW, -// view->Prev->Peer->wH + view->Peer->wH); - } - - if (Active == view) { - Active = view->Prev; - Active->Activate(1); - } - } -} - -void GFrame::SelectNext(int back) { - GView *c = Active; - - if (c == 0 && Top == 0) - return; - else if (c == 0) - c = Active = Top; - else - if (back) { - Active = Active->Prev; - } else { - Active = Active->Next; - } - if (c != Active) { - c->Activate(0); - Active->Activate(1); - } - //if (Active) - // XtSetKeyboardFocus(Peer->PanedWin, Active->Peer->TextWin); -} - -int GFrame::SelectView(GView *view) { - if (Top == 0) - return 0; - - if (FocusCapture != 0 || MouseCapture != 0) - return 0; - - if (Active) - Active->Activate(0); - Active = view; - if (Active) - Active->Activate(1); - //if (Active) - // XtSetKeyboardFocus(Peer->PanedWin, Active->Peer->TextWin); - return 1; -} - -void GFrame::Resize(int width, int height) { - if (!Top) - return; - - if (width < 8 || height < 2) - return; - - if (Top == Top->Next) { - Top->ConSetSize(width, height); - } else { - } -} - -void GFrame::Show() { - Update(); - Peer->MapFrame(); -} - -void GFrame::Activate() { - frames = this; - Update(); - Peer->ShowFrame(); -} - -QPopupMenu *QEFrame::CreatePopup(QWidget *parent, int Id, int do_connect) { - QPopupMenu *menu = new QPopupMenu(parent); - CHECK_PTR(menu); - - //menu->setFont(QFont("Helvetica", 12, QFont::Bold)); - for (int i = 0; i < Menus[Id].Count; i++) { - if (Menus[Id].Items[i].Name) { - //puts(Menus[Id].Items[i].Name); - if (Menus[Id].Items[i].SubMenu != -1) { - QPopupMenu *submenu = - CreatePopup(0, - Menus[Id].Items[i].SubMenu, 0); - CHECK_PTR(submenu); - - menu->insertItem(Menus[Id].Items[i].Name, - submenu); - } else { - menu->insertItem(Menus[Id].Items[i].Name, - Menus[Id].Items[i].Cmd); - } - } else { - menu->insertSeparator(); - } - } - if (do_connect) - connect(menu, SIGNAL(activated(int)), SLOT(selectedMain(int))); - return menu; -} - -QMenuBar *QEFrame::CreateMenuBar(QWidget *parent, int Id) { - QMenuBar *menu = new QMenuBar(parent); - CHECK_PTR(menu); - - //menu->setFont(QFont("Helvetica", 12, QFont::Bold)); - for (int i = 0; i < Menus[Id].Count; i++) { - if (Menus[Id].Items[i].Name) { - //puts(Menus[Id].Items[i].Name); - - if (Menus[Id].Items[i].SubMenu != -1) { - QPopupMenu *submenu = - CreatePopup(0, - Menus[Id].Items[i].SubMenu, 0); - CHECK_PTR(submenu); - - menu->insertItem(Menus[Id].Items[i].Name, - submenu); - } else { - menu->insertItem(Menus[Id].Items[i].Name, - Menus[Id].Items[i].Cmd); - } - } else { - menu->insertSeparator(); - } - } - connect(menu, SIGNAL(activated(int)), SLOT(selectedMain(int))); - return menu; -} - -int GFrame::SetMenu(const char *Name) { - int id = GetMenuId(Name); - - if (Menu) - free(Menu); - Menu = strdup(Name); - - if (Peer->qFrame->menubar) { - delete Peer->qFrame->menubar; - Peer->qFrame->menubar = 0; - } - - DEBUGX(("setting main menu: %s, id=%d\n", Name, id)); - Peer->qFrame->menubar = Peer->qFrame->CreateMenuBar(Peer->qFrame, id); - //Peer->qFrame->menubar->setFrameStyle(QFrame::Raised | QFrame::Panel); - //Peer->qFrame->menubar->setLineWidth(1); - Peer->qFrame->menubar->show(); - return 1; -} - -int GFrame::ExecMainMenu(char Sub) { - return 0; -} - -int GFrame::PopupMenu(const char *Name) { - int id = GetMenuId(Name); - - QPopupMenu *popup = Peer->qFrame->CreatePopup(0, id, 1); - popup->popup(LastMousePos); - return 1; -} - -void QEFrame::timerDone() { - FinalExit = 0; - qApp->exit_loop(); -} - -// GUI - - -GUI::GUI(int &argc, char **argv, int XSize, int YSize) { - - fArgc = argc; - fArgv = argv; - - new QApplication(argc, argv); - - display = qt_xdisplay(); - - char *fs = getenv("VIOFONT"); - fontStruct = NULL; - if (fs == 0 && WindowFont[0] != 0) - fs = WindowFont; - if (fs) - fontStruct = XLoadQueryFont(display, fs); - if (fontStruct == NULL) - fontStruct = XLoadQueryFont(display, "8x13"); - if (fontStruct == NULL) - fontStruct = XLoadQueryFont(display, "fixed"); - if (fontStruct == NULL) - return ; - - cxChar = fontStruct->max_bounds.width; - cyChar = fontStruct->max_bounds.ascent + fontStruct->max_bounds.descent; - - gui = this; -} - -GUI::~GUI() { - gui = 0; -} - -int GUI::ConGrabEvents(TEventMask EventMask) { - return 0; -} - -void GUI::DispatchEvent(GFrame *frame, GView *view, TEvent &Event) { - if (Event.What != evNone) { - if (view) - view->HandleEvent(Event); - } -} - -int GUI::ConSuspend(void) { return 0; } - -int GUI::ConContinue(void) { return 0; } - -int GUI::ConGetEvent(TEventMask EventMask, TEvent *Event, int WaitTime, int Delete, GView **view) { - //return ::ConGetEvent(EventMask, Event, WaitTime, Delete, view); - assert(1 == 0); - return 0; -} - -int GUI::ConPutEvent(TEvent Event) { - EventBuf = Event; - return 0; -} - -int GUI::ConFlush(void) { - return 0; -} - -void GUI::ProcessEvent() { - static int need_update = 1; - - /* should process until no more events, - * but this is close enough */ - - if (need_update) - QTimer::singleShot(10, frames->Peer->qFrame, SLOT(timerDone())); - - FinalExit = 1; - NextEvent.What = evNone; - qApp->enter_loop(); - if (FinalExit && NextEvent.What == evNone) { - DEBUGX(("Final exit\n")); - //delete frames; - //frames = 0; - //return ; - } - - if (need_update) { - DEBUGX(("Updating\n")); - frames->Update(); - need_update = 0; - } - while (doLoop && qHasEvent()) { - NextEvent.What = evNone; - qGetEvent(NextEvent); - DEBUGX(("Got event: %d\n", NextEvent.What)); - if (NextEvent.What == evMouseDown) { - DEBUGX(("x:%d, y:%d, buttons:%d\n", - NextEvent.Mouse.X, - NextEvent.Mouse.Y, - NextEvent.Mouse.Buttons)); - } - DispatchEvent(frames, NextEvent.Msg.View, NextEvent); - NextEvent.What = evNone; - need_update = 1; - } -} - -int GUI::Run() { - if (Start(fArgc, fArgv) == 0) { - doLoop = 1; - frames->Show(); - - while (doLoop) - ProcessEvent(); - - Stop(); - return 0; - } - return 1; -} - -int GUI::ShowEntryScreen() { - return 1; -} - -int GUI::RunProgram(char *Command) { - char Cmd[1024]; - - char* xterm = getenv("TERM"); - if (NULL == xterm || 0 == *xterm) - xterm = "xterm"; - - strcpy(Cmd, xterm); - - if (*Command == 0) // empty string = shell - strcat(Cmd, " -ls &"); - else { - strcat(Cmd, " -e "); - // buffer overflow problem: -2 for possible async. - strncat(Cmd, Command, sizeof(Cmd) - strlen(Cmd) - 2); - Cmd[sizeof(Cmd) - 3] = 0; - if (mode == RUN_ASYNC) - strcat(Cmd, " &"); - } - rc = system(Cmd); - return rc; -} - -/*void PipeCallback(GPipe *pipe, int *source, int *input) { - if (pipe && pipe->notify && *source == pipe->fd) { - NextEvent.What = evNotify; - NextEvent.Msg.View = frames->Active; - NextEvent.Msg.Model = pipe->notify; - NextEvent.Msg.Command = cmPipeRead; - NextEvent.Msg.Param1 = pipe->id; - pipe->stopped = 0; - } - DEBUGX(("Pipe %d\n", *source)); -} - */ -int GUI::OpenPipe(char *Command, EModel *notify) { - int i; - - for (i = 0; i < MAX_PIPES; i++) { - if (Pipes[i].used == 0) { - int pfd[2]; - - Pipes[i].id = i; - Pipes[i].notify = notify; - Pipes[i].stopped = 1; - - if (pipe((int *)pfd) == -1) - return -1; - - switch (Pipes[i].pid = fork()) { - case -1: /* fail */ - return -1; - case 0: /* child */ - close(pfd[0]); - close(0); - dup2(pfd[1], 1); - dup2(pfd[1], 2); - exit(system(Command)); - default: - close(pfd[1]); - fcntl(pfd[0], F_SETFL, O_NONBLOCK); - Pipes[i].fd = pfd[0]; - } - //Pipes[i].input = - // XtAppAddInput(AppContext, Pipes[i].fd, XtInputReadMask, PipeCallback, &Pipes[i]); - Pipes[i].used = 1; - DEBUGX(("Pipe Open: %d\n", i)); - return i; - } - } - return -1; -} - -int GUI::SetPipeView(int id, EModel *notify) { - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - DEBUGX(("Pipe View: %d %08X\n", id, notify)); - Pipes[id].notify = notify; - if (notify != Pipes[id].notify) - if (notify) { - //Pipes[id].input = - // XtAppAddInput(AppContext, Pipes[id].fd, XtInputReadMask, PipeCallback, &Pipes[id]); - } else { - //if (Pipes[id].input != 0) { - // XtRemoveInput(Pipes[id].input); - // Pipes[id].input = 0; - //} - } - return 0; -} - -int GUI::ReadPipe(int id, void *buffer, int len) { - int rc; - - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - DEBUGX(("Pipe Read: Get %d %d\n", id, len)); - - rc = read(Pipes[id].fd, buffer, len); - DEBUGX(("Pipe Read: Got %d %d\n", id, len)); - if (rc == 0) { - //if (Pipes[id].input != 0) { - //XtRemoveInput(Pipes[id].input); - // Pipes[id].input = 0; - // } - close(Pipes[id].fd); - return -1; - } - if (rc == -1) { - Pipes[id].stopped = 1; - return 0; - } - return rc; -} - -int GUI::ClosePipe(int id) { - int status; - - if (id < 0 || id > MAX_PIPES) - return -1; - if (Pipes[id].used == 0) - return -1; - waitpid(Pipes[id].pid, &status, 0); - DEBUGX(("Pipe Close: %d\n", id)); - Pipes[id].used = 0; - return WEXITSTATUS(status); -} - -int GUI::multiFrame() { return 1; } - -int GetXSelection(int *len, char **data) { - QClipboard *cb = QApplication::clipboard(); - const char *text; - - text = cb->text(); - if (text == 0) - return -1; - - *len = strlen(text); - *data = (char *)malloc(*len); - if (*data == 0) - return -1; - memcpy(*data, text, *len); - return 0; -} - -int SetXSelection(int len, char *data) { - QClipboard *cb = QApplication::clipboard(); - char *text = (char *)malloc(len + 1); - if (text == 0) - return -1; - memcpy(text, data, len); - text[len] = 0; - free(text); - return 0; -} - -void DieError(int rc, const char *msg, ...) { - va_list ap; - - va_start(ap, msg); - vfprintf(stderr, msg, ap); - va_end(ap); - exit(rc); -} - -char ConGetDrawChar(int index) { - static char tab[] = "\x0D\x0C\x0E\x0B\x12\x19____+>\x1F\x01\x12 "; - - assert(index >= 0 && index < strlen(tab)); - - return tab[index]; -} diff --git a/src/g_qt.moc b/src/g_qt.moc deleted file mode 100644 index 54f63bf..0000000 --- a/src/g_qt.moc +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** QEText meta object code from reading C++ file 'g_qt.cpp' -** -** Created: Sat May 23 17:43:55 1998 -** by: The Qt Meta Object Compiler ($Revision: 1.1.1.1 $) -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - -#if !defined(Q_MOC_OUTPUT_REVISION) -#define Q_MOC_OUTPUT_REVISION 2 -#elif Q_MOC_OUTPUT_REVISION != 2 -#error Moc format conflict - please regenerate all moc files -#endif - -#include - - -const char *QEText::className() const -{ - return "QEText"; -} - -QMetaObject *QEText::metaObj = 0; - -void QEText::initMetaObject() -{ - if ( metaObj ) - return; - if ( strcmp(QWidget::className(), "QWidget") != 0 ) - badSuperclassWarning("QEText","QWidget"); - if ( !QWidget::metaObject() ) - QWidget::initMetaObject(); - metaObj = new QMetaObject( "QEText", "QWidget", - 0, 0, - 0, 0 ); -} - - -const char *QEView::className() const -{ - return "QEView"; -} - -QMetaObject *QEView::metaObj = 0; - -void QEView::initMetaObject() -{ - if ( metaObj ) - return; - if ( strcmp(QFrame::className(), "QFrame") != 0 ) - badSuperclassWarning("QEView","QFrame"); - if ( !QFrame::metaObject() ) - QFrame::initMetaObject(); - typedef void(QEView::*m1_t0)(); - typedef void(QEView::*m1_t1)(); - typedef void(QEView::*m1_t2)(); - typedef void(QEView::*m1_t3)(); - typedef void(QEView::*m1_t4)(int); - typedef void(QEView::*m1_t5)(); - typedef void(QEView::*m1_t6)(); - typedef void(QEView::*m1_t7)(); - typedef void(QEView::*m1_t8)(); - typedef void(QEView::*m1_t9)(int); - m1_t0 v1_0 = &QEView::sbHmoveLeft; - m1_t1 v1_1 = &QEView::sbHmoveRight; - m1_t2 v1_2 = &QEView::sbHpageLeft; - m1_t3 v1_3 = &QEView::sbHpageRight; - m1_t4 v1_4 = &QEView::sbHmoveTo; - m1_t5 v1_5 = &QEView::sbVmoveUp; - m1_t6 v1_6 = &QEView::sbVmoveDown; - m1_t7 v1_7 = &QEView::sbVpageUp; - m1_t8 v1_8 = &QEView::sbVpageDown; - m1_t9 v1_9 = &QEView::sbVmoveTo; - QMetaData *slot_tbl = new QMetaData[10]; - slot_tbl[0].name = "sbHmoveLeft()"; - slot_tbl[1].name = "sbHmoveRight()"; - slot_tbl[2].name = "sbHpageLeft()"; - slot_tbl[3].name = "sbHpageRight()"; - slot_tbl[4].name = "sbHmoveTo(int)"; - slot_tbl[5].name = "sbVmoveUp()"; - slot_tbl[6].name = "sbVmoveDown()"; - slot_tbl[7].name = "sbVpageUp()"; - slot_tbl[8].name = "sbVpageDown()"; - slot_tbl[9].name = "sbVmoveTo(int)"; - slot_tbl[0].ptr = *((QMember*)&v1_0); - slot_tbl[1].ptr = *((QMember*)&v1_1); - slot_tbl[2].ptr = *((QMember*)&v1_2); - slot_tbl[3].ptr = *((QMember*)&v1_3); - slot_tbl[4].ptr = *((QMember*)&v1_4); - slot_tbl[5].ptr = *((QMember*)&v1_5); - slot_tbl[6].ptr = *((QMember*)&v1_6); - slot_tbl[7].ptr = *((QMember*)&v1_7); - slot_tbl[8].ptr = *((QMember*)&v1_8); - slot_tbl[9].ptr = *((QMember*)&v1_9); - metaObj = new QMetaObject( "QEView", "QFrame", - slot_tbl, 10, - 0, 0 ); -} - - -const char *QEFrame::className() const -{ - return "QEFrame"; -} - -QMetaObject *QEFrame::metaObj = 0; - -void QEFrame::initMetaObject() -{ - if ( metaObj ) - return; - if ( strcmp(QFrame::className(), "QFrame") != 0 ) - badSuperclassWarning("QEFrame","QFrame"); - if ( !QFrame::metaObject() ) - QFrame::initMetaObject(); - typedef void(QEFrame::*m1_t0)(int); - typedef void(QEFrame::*m1_t1)(); - m1_t0 v1_0 = &QEFrame::selectedMain; - m1_t1 v1_1 = &QEFrame::timerDone; - QMetaData *slot_tbl = new QMetaData[2]; - slot_tbl[0].name = "selectedMain(int)"; - slot_tbl[1].name = "timerDone()"; - slot_tbl[0].ptr = *((QMember*)&v1_0); - slot_tbl[1].ptr = *((QMember*)&v1_1); - metaObj = new QMetaObject( "QEFrame", "QFrame", - slot_tbl, 2, - 0, 0 ); -} diff --git a/src/g_qt_dlg.cpp b/src/g_qt_dlg.cpp deleted file mode 100644 index cbddd24..0000000 --- a/src/g_qt_dlg.cpp +++ /dev/null @@ -1,214 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "sysdep.h" -#include "console.h" -#include "gui.h" -#include "s_files.h" - -#include -#include -#include -#include -#include -#include -#include - -#define DEBUGX(x) // printf x - -unsigned long HaveGUIDialogs = GUIDLG_FILE | GUIDLG_CHOICE; - -int DLGGetFile(GView *v, const char *Prompt, unsigned int BufLen, char *FileName, int Flags) { - QString fn; - char filter[MAXPATH] = "*"; - char directory[MAXPATH]; - - assert(BufLen > 0); - - JustDirectory(FileName, directory); - - DEBUGX(("Doing file dialog\n")); - if (Flags & GF_SAVEAS) { - fn = QFileDialog::getSaveFileName(directory, filter); - } else { - fn = QFileDialog::getOpenFileName(directory, filter); - } - DEBUGX(("File dialog done\n")); - if (fn.isNull()) - return 0; - strncpy(FileName, fn, BufLen); - FileName[BufLen - 1] = 0; - DEBUGX(("selected %s\n", FileName)); - return FileName[0] ? 1 : 0; -} - -const int kMaxButton = 16; - -class QChoiceBox : public QDialog { - Q_OBJECT -public: - QChoiceBox(QWidget *parent=0, const char *name=0); - - void setText(const char *text); - void addButton(const char *text); - - void adjustSize(); - - int getChoice() { return buttonActivated; } - -public slots: - void pressed(); - void released(); - void clicked(); - -protected: - void resizeEvent(QResizeEvent *); - -private: - QLabel *label; - QPushButton *button[kMaxButton]; - int buttonCount; - int buttonArmed; - int buttonSelected; - int buttonActivated; - void *reserved1; - void *reserved2; -}; - - -QChoiceBox::QChoiceBox(QWidget *parent, const char *name) - : QDialog(parent, name, TRUE) -{ - initMetaObject(); - - buttonSelected = -1; - buttonCount = 0; - buttonActivated = -1; - buttonArmed = -1; - - label = new QLabel(this, "text"); - CHECK_PTR(label); - label->setAlignment(AlignLeft); - QFont font("Helvetica", 12, QFont::Bold); - label->setFont(font ); -} - -void QChoiceBox::setText(const char *text) { - label->setText(text); -} - -void QChoiceBox::addButton(const char *text) { - assert(buttonCount < kMaxButton); - - button[buttonCount] = new QPushButton(this); - CHECK_PTR(button[buttonCount]); - connect(button[buttonCount], SIGNAL(clicked()), SLOT(clicked())); - connect(button[buttonCount], SIGNAL(pressed()), SLOT(pressed())); - connect(button[buttonCount], SIGNAL(released()), SLOT(released())); - button[buttonCount]->setFont(QFont("Helvetica", 12, QFont::Bold)); - button[buttonCount]->setText(text ? text : "?" ); - buttonCount++; -} - -void QChoiceBox::adjustSize() { - int w_buttons = 0; - - for (int i = 0; i < buttonCount; i++) { - button[i]->adjustSize(); - w_buttons += button[i]->width() + 10; - } - - label->adjustSize(); - - QString labelStr = label->text(); - int nlines = labelStr.contains('\n'); - QFontMetrics fm = label->fontMetrics(); - nlines += 2; - int w = QMAX(w_buttons, label->width()); - int h = button[0]->height() + fm.lineSpacing()*nlines; - resize( w + w/3, h + h/3 ); -} - -void QChoiceBox::resizeEvent( QResizeEvent * ) { - int i; - - for (i = 0; i < buttonCount; i++) { - button[i]->adjustSize(); - } - label->adjustSize(); - int h = (height() - button[0]->height() - label->height())/3; - int x = 10; - - for (i = 0; i < buttonCount; i++) { - button[i]->move(x, height() - h - button[i]->height()); - x += button[i]->width() + 10; - } - label->move( 10, h ); -} - -void QChoiceBox::pressed() { - int i; - - buttonSelected = -1; - for (i = 0; i < buttonCount; i++) - if (button[i]->isDown()) - buttonSelected = i; - buttonArmed = buttonSelected; - DEBUGX(("selected: %d\n", buttonSelected)); -} - -void QChoiceBox::released() { - buttonSelected = -1; - DEBUGX(("released\n")); -} - -void QChoiceBox::clicked() { - buttonActivated = buttonArmed; - DEBUGX(("activated: %d\n", buttonActivated)); - accept(); -} - -#include "g_qt_dlg.moc" - -int DLGPickChoice(GView *v, char *ATitle, int NSel, va_list ap, int Flags) { - QChoiceBox *cb = new QChoiceBox(); - CHECK_PTR(cb); - cb->setCaption( ATitle ); - - for (int i = 0; i < NSel; i++) - cb->addButton(va_arg(ap, char *)); - - char msg[1024]; - char *fmt; - fmt = va_arg(ap, char *); - vsprintf(msg, fmt, ap); - - cb->setText(msg); - - int retcode = cb->exec(); - - delete cb; - if (retcode == QDialog::Accepted) - return cb->getChoice(); - return -1; -} - -int DLGGetFind(GView *View, SearchReplaceOptions &sr) { - assert(1==0); - return 0; -} - -int DLGGetFindReplace(GView *View, SearchReplaceOptions &sr) { - assert(1==0); - return 0; -} - -int DLGGetStr(GView *View, char *Prompt, unsigned int BufLen, char *Str, int HistId, int Flags) { - assert(1 == 0); - return 0; -} - diff --git a/src/g_qt_dlg.moc b/src/g_qt_dlg.moc deleted file mode 100644 index 54a0829..0000000 --- a/src/g_qt_dlg.moc +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** QChoiceBox meta object code from reading C++ file 'g_qt_dlg.cpp' -** -** Created: Sat May 23 17:42:27 1998 -** by: The Qt Meta Object Compiler ($Revision: 1.1.1.1 $) -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - -#if !defined(Q_MOC_OUTPUT_REVISION) -#define Q_MOC_OUTPUT_REVISION 2 -#elif Q_MOC_OUTPUT_REVISION != 2 -#error Moc format conflict - please regenerate all moc files -#endif - -#include - - -const char *QChoiceBox::className() const -{ - return "QChoiceBox"; -} - -QMetaObject *QChoiceBox::metaObj = 0; - -void QChoiceBox::initMetaObject() -{ - if ( metaObj ) - return; - if ( strcmp(QDialog::className(), "QDialog") != 0 ) - badSuperclassWarning("QChoiceBox","QDialog"); - if ( !QDialog::metaObject() ) - QDialog::initMetaObject(); - typedef void(QChoiceBox::*m1_t0)(); - typedef void(QChoiceBox::*m1_t1)(); - typedef void(QChoiceBox::*m1_t2)(); - m1_t0 v1_0 = &QChoiceBox::pressed; - m1_t1 v1_1 = &QChoiceBox::released; - m1_t2 v1_2 = &QChoiceBox::clicked; - QMetaData *slot_tbl = new QMetaData[3]; - slot_tbl[0].name = "pressed()"; - slot_tbl[1].name = "released()"; - slot_tbl[2].name = "clicked()"; - slot_tbl[0].ptr = *((QMember*)&v1_0); - slot_tbl[1].ptr = *((QMember*)&v1_1); - slot_tbl[2].ptr = *((QMember*)&v1_2); - metaObj = new QMetaObject( "QChoiceBox", "QDialog", - slot_tbl, 3, - 0, 0 ); -} diff --git a/src/icons/ftepm.ico b/src/icons/ftepm.ico deleted file mode 100644 index ce1ba493b868a9aedbc5ee03bcbb0c4fa9c8aa27..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3344 zcmeHJv2NQi5WUnY9Hau0!BZD!^q4=en`$Z0p`VbkW5;Z9CXfA{04*8;4&X%};UYuF zW(-in*Y}R3BvN)7Brdv?#?#}yJKm9$MEUg1NJP#7wzuzI<9dYOa!({j|5zrnhaZ}% zw)`)G{}|qk{;6SVG=()~tEx(&D@K#R%%gg0b?>0DxxD+bFH59i-6K>^>(YPrGWd_4 zQTHPklu6Ik9mqhIKJQ3Abn4Q7w(shWWb}->Tx(PJKn`U3%H& z+DRj_OSAu9cC!QF5CJdyNC_@eK6LsVx19cz%b_0^cx?8<$IVjq`DYz=b!PThscz<5 zug?RoWXyTZ?>c;8Iu{5(&&-WHcKRF?#rK_!71rK0b7v^YL0|DmIr%S_5-wOPqgFBe!!h`T*d~-5M9|fs2dR`>@tb#^M^&dQZ}_ zqC3{FG0Nw(;yuslP}elhzx4_HgH}dkgWCOL`v_Kx&7LrP}be$vl%7- zJBI3==>3W4FEDZc$?+HTiK`RQYcO!_@wJaW#?1gSaS1S2x8<$<3|}EeMg7)aokkBI iI2Rr1b$outfile"); } -else { open(OUTFILE, ">&STDOUT"); } -print OUTFILE "/* do not edit */\nchar DefaultConfig[] = {\n"; -binmode INFILE; # NT needs this -local($len); -while (($len = read(INFILE, $buf, 256)) > 0) { - #$buf =~ s/(.)/sprintf "0x%02X", ord($1))/goe; - #for ($i = 0; $i < $len; $i++) { - # $out .= sprintf "0x%02X", ord(substr($buf, $i, 1,)); - # if ($n++ % 10) { - # $out .= ", "; - # } else { - # $out .= ",\n"; - # } - #} - - @c = split(//, $buf); - for ($i = 0; $i < $len; $i++) { - $out .= sprintf("0x%02X", ord($c[$i])); - if ($n++ % 10) { - $out .= ", "; - } else { - $out .= ",\n"; - } - } - - print OUTFILE $out; - $out = ""; - print STDERR "."; -} -print OUTFILE "\n};\n"; -close(INFILE); -close(OUTFILE); -print STDERR "\n"; - diff --git a/src/namemaps.h b/src/namemaps.h deleted file mode 100644 index 951ca8f..0000000 --- a/src/namemaps.h +++ /dev/null @@ -1,27 +0,0 @@ -/* M$VC++ !!! */ -#ifndef __NAMEMAPS_H__ -#define __NAMEMAPS_H__ - -#define access _access -#define chmod _chmod -#define chsize _chsize -#define close _close -#define creat _creat -#define dup _dup -#define dup2 _dup2 -#define eof _eof -#define filelength _filelength -#define isatty _isatty -#define locking _locking -#define lseek _lseek -#define mktemp _mktemp -#define open _open -#define read _read -#define setmode _setmode -#define sopen _sopen -#define tell _tell -#define umask _umask -#define unlink _unlink -#define write _write - -#endif diff --git a/src/pm_tool.cpp b/src/pm_tool.cpp deleted file mode 100644 index e33b6c9..0000000 --- a/src/pm_tool.cpp +++ /dev/null @@ -1,403 +0,0 @@ - -#define InRange(a,x,b) (((a) <= (x)) && ((x) < (b))) -#define Min(a,b) (((a) < (b))?(a):(b)) -#define Max(a,b) (((a) > (b))?(a):(b)) - -#define TYBORDER 6 // border on top and bottom of icon (all of it) -#define TXBORDER 6 -#define TXSEPARATOR 4 -#define TYICON 24 -#define TXICON 24 - -MRESULT EXPENTRY ToolBarProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { - if (msg == WM_CREATE) { - WinSetWindowPtr(hwnd, QWL_USER, PVOIDFROMMP(mp1)); - } else { - ToolBarData *td = (ToolBarData *)WinQueryWindowPtr(hwnd, QWL_USER); - ToolBarItem *items = td->pItems; - - switch (msg) { - case WM_DESTROY: - free(td); - free(items); - break; - - case WM_PAINT: - { - HPS hps; - RECTL rcl; - POINTL ptl; - SWP swp; - int xpos, ypos, item; - - WinQueryWindowPos(hwnd, &swp); - - hps = WinBeginPaint(hwnd, 0, &rcl); - - /* top outside 3D border */ - if (rcl.yBottom < 1) { - GpiSetColor(hps, CLR_DARKGRAY); - ptl.x = rcl.xLeft; - ptl.y = 0; - GpiMove(hps, &ptl); - ptl.x = Min(rcl.xRight, swp.cx - 2); - GpiLine(hps, &ptl); - } - - /* bottom outside 3D border */ - if (rcl.yTop >= swp.cy - 1 - 1) { - GpiSetColor(hps, CLR_WHITE); - ptl.x = Max(rcl.xLeft, 1); - ptl.y = swp.cy - 1; - GpiMove(hps, &ptl); - ptl.x = rcl.xRight; - GpiLine(hps, &ptl); - } - - /* 3D corners */ - GpiSetColor(hps, CLR_PALEGRAY); - ptl.x = 0; - ptl.y = 0; - GpiSetPel(hps, &ptl); - ptl.x = swp.cx - 1; - ptl.y = swp.cy - 1; - GpiSetPel(hps, &ptl); - - /* bottom space */ - if (rcl.yBottom < TYBORDER - 1) { - for (ptl.y = 1; ptl.y < TYBORDER - 2; ptl.y++) { - ptl.x = Max(rcl.xLeft, 1); - GpiMove(hps, &ptl); - ptl.x = Min(rcl.xRight, swp.cx - 1); - GpiLine(hps, &ptl); - } - } - - /* top space */ - if (rcl.yTop >= swp.cy - TYBORDER + 2) { - for (ptl.y = swp.cy - TYBORDER + 2; ptl.y < swp.cy - 1; ptl.y++) { - ptl.x = Max(rcl.xLeft, 1); - GpiMove(hps, &ptl); - ptl.x = Min(rcl.xRight, swp.cx - 1); - GpiLine(hps, &ptl); - } - } - - /* left outside 3D border */ - if (rcl.xLeft < 1) { - GpiSetColor(hps, CLR_WHITE); - ptl.y = Max(1, rcl.yBottom); - ptl.x = 0; - GpiMove(hps, &ptl); - ptl.y = rcl.yTop; - GpiLine(hps, &ptl); - } - - /* right outside 3D border */ - if (rcl.xRight >= swp.cx - 1) { - GpiSetColor(hps, CLR_DARKGRAY); - ptl.y = rcl.yBottom; - ptl.x = swp.cx - 1; - GpiMove(hps, &ptl); - ptl.y = Min(swp.cy - 2, rcl.yTop); - GpiLine(hps, &ptl); - } - - /* left border */ - if (rcl.xLeft < TXBORDER - 2) { - GpiSetColor(hps, CLR_PALEGRAY); - for (ptl.x = 1; ptl.x < TXBORDER - 2; ptl.x++) { - ptl.y = Max(1, rcl.yBottom); - GpiMove(hps, &ptl); - ptl.y = Min(swp.cy - 2, rcl.yTop); - GpiLine(hps, &ptl); - } - } - - /* draw toolbar items */ - xpos = TXBORDER; - ypos = TYBORDER; - - for (item = 0; item < td->ulCount; item++) { - if (items[item].ulType == tiBITMAP) { - if (rcl.xRight >= xpos - 2 && rcl.xLeft <= xpos + TXICON + 1) { - GpiSetColor(hps, CLR_BLACK); - ptl.x = xpos - 2; - ptl.y = ypos - 2; - GpiMove(hps, &ptl); - ptl.x = xpos + TXICON + 1; - ptl.y = ypos + TYICON + 1; - GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0); - if (item == td->ulDepressed && (items[item].ulFlags & tfDEPRESSED)) { - ptl.x = xpos + 1; - ptl.y = ypos - 1; - WinDrawBitmap(hps, - items[item].hBitmap, - 0, - &ptl, - 0, 0, - (items[item].ulFlags & tfDISABLED) ? DBM_INVERT: DBM_NORMAL); - - GpiSetColor(hps, CLR_DARKGRAY); - ptl.x = xpos - 1; - ptl.y = ypos - 1; - GpiMove(hps, &ptl); - ptl.y = ypos + TYICON; - GpiLine(hps, &ptl); - ptl.x = xpos + TXICON; - GpiLine(hps, &ptl); - ptl.y--; - GpiMove(hps, &ptl); - ptl.x = xpos; - GpiLine(hps, &ptl); - ptl.y = ypos - 1; - GpiLine(hps, &ptl); - } else { - ptl.x = xpos; - ptl.y = ypos; - WinDrawBitmap(hps, - items[item].hBitmap, - 0, - &ptl, - 0, 0, - (items[item].ulFlags & tfDISABLED) ? DBM_INVERT: DBM_NORMAL); - - GpiSetColor(hps, CLR_PALEGRAY); - ptl.x = xpos - 1; - ptl.y = ypos - 1; - GpiSetPel(hps, &ptl); - GpiSetColor(hps, CLR_WHITE); - ptl.y++; - GpiMove(hps, &ptl); - ptl.y = ypos + TYICON; - GpiLine(hps, &ptl); - ptl.x = xpos + TXICON - 1; - GpiLine(hps, &ptl); - GpiSetColor(hps, CLR_PALEGRAY); - ptl.x++; - GpiSetPel(hps, &ptl); - ptl.y--; - GpiSetColor(hps, CLR_DARKGRAY); - GpiMove(hps, &ptl); - ptl.y = ypos - 1; - GpiLine(hps, &ptl); - ptl.x = xpos; - GpiLine(hps, &ptl); - } - } - xpos += TXICON + 3; - } else if (items[item].ulType == tiSEPARATOR) { - if (rcl.xRight >= xpos - 1 && rcl.xLeft <= xpos + TXSEPARATOR + 1) { - GpiSetColor(hps, CLR_PALEGRAY); - ptl.x = xpos - 1; - ptl.y = ypos - 2; - GpiMove(hps, &ptl); - ptl.x = xpos + TXSEPARATOR + 1; - ptl.y = ypos + TYICON + 1; - GpiBox(hps, DRO_FILL, &ptl, 0, 0); - } - xpos += TXSEPARATOR + 3; - } - } - GpiSetColor(hps, CLR_PALEGRAY); - ptl.x = xpos - 1; - ptl.y = ypos - 2; - GpiMove(hps, &ptl); - ptl.x = swp.cx - 2; - ptl.y = swp.cy - TYBORDER + 1; - GpiBox(hps, DRO_FILL, &ptl, 0, 0); - - WinEndPaint(hps); - } - break; - - case WM_ADJUSTWINDOWPOS: - { - PSWP pswp = (PSWP)PVOIDFROMMP(mp1); - pswp->cy = TYBORDER + TYICON + TYBORDER; - } - break; - - case WM_BUTTON1DOWN: - case WM_BUTTON1DBLCLK: - { - int item; - POINTL ptl; - RECTL rcl; - - ptl.x = (LONG) SHORT1FROMMP(mp1); - ptl.y = (LONG) SHORT2FROMMP(mp1); - - rcl.yBottom = TYBORDER - 1; - rcl.yTop = TYBORDER + TYICON + 1; - rcl.xLeft = TXBORDER - 1; - rcl.xRight = TXBORDER + TXICON + 1; - - for (item = 0; item < td->ulCount; item++) { - if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y && - rcl.xRight >= ptl.x && rcl.yTop >= ptl.y && - td->pItems[item].ulType == tiBITMAP && - (td->pItems[item].ulFlags & tfDISABLED) == 0) - { - td->ulDepressed = item; - td->pItems[item].ulFlags |= tfDEPRESSED; - WinInvalidateRect(hwnd, &rcl, FALSE); - WinSetCapture(HWND_DESKTOP, hwnd); - break; - } - if (td->pItems[item].ulType == tiBITMAP) { - rcl.xLeft += TXICON + 3; - rcl.xRight += TXICON + 3; - } else if (td->pItems[item].ulType == tiSEPARATOR) { - rcl.xLeft += TXSEPARATOR + 3; - rcl.xRight += TXSEPARATOR + 3; - } - } - } - break; - - case WM_MOUSEMOVE: - { - STARTFUNC("ToolBarProc[WM_MOUSEMOVE]"); - int item; - POINTL ptl; - RECTL rcl; - - if (td->ulDepressed == -1) - break; - - ptl.x = (LONG) SHORT1FROMMP(mp1); - ptl.y = (LONG) SHORT2FROMMP(mp1); - - rcl.yBottom = TYBORDER - 1; - rcl.yTop = TYBORDER + TYICON + 1; - rcl.xLeft = TXBORDER - 1; - rcl.xRight = TXBORDER + TXICON + 1; - - LOG << "Depressed: " << td-> ulDepressed << ENDLINE; - for (item = 0; item < td->ulCount; item++) { - LOG << "Checking item " << item << ENDLINE; - LOG << " pItem -> " << (void*)(td->pItems + item) << ENDLINE; - if (item == td->ulDepressed) { - if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y && - rcl.xRight >= ptl.x && rcl.yTop >= ptl.y) - { - if ((td->pItems[item].ulFlags & tfDEPRESSED) == 0) { - td->pItems[item].ulFlags |= tfDEPRESSED; - WinInvalidateRect(hwnd, &rcl, FALSE); - } - } else { - if (td->pItems[item].ulFlags & tfDEPRESSED) { - td->pItems[item].ulFlags &= ~tfDEPRESSED; - WinInvalidateRect(hwnd, &rcl, FALSE); - } - } - break; - } - if (td->pItems[item].ulType == tiBITMAP) { - rcl.xLeft += TXICON + 3; - rcl.xRight += TXICON + 3; - } else if (td->pItems[item].ulType == tiSEPARATOR) { - rcl.xLeft += TXSEPARATOR + 3; - rcl.xRight += TXSEPARATOR + 3; - } - } - } - break; - - case WM_BUTTON1UP: - { - int item; - POINTL ptl; - RECTL rcl; - - if (td->ulDepressed == -1) - break; - - ptl.x = (LONG) SHORT1FROMMP(mp1); - ptl.y = (LONG) SHORT2FROMMP(mp1); - - rcl.yBottom = TYBORDER - 1; - rcl.yTop = TYBORDER + TYICON + 1; - rcl.xLeft = TXBORDER - 1; - rcl.xRight = TXBORDER + TXICON + 1; - - for (item = 0; item < td->ulCount; item++) { - if (item == td->ulDepressed) { - WinSetCapture(HWND_DESKTOP, (HWND)0); - if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y && - rcl.xRight >= ptl.x && rcl.yTop >= ptl.y && - td->pItems[item].ulFlags & tfDEPRESSED) - { - td->pItems[item].ulFlags &= ~tfDEPRESSED; - WinInvalidateRect(hwnd, &rcl, FALSE); - - // message - WinPostMsg(WinQueryWindow(hwnd, QW_OWNER), WM_COMMAND, MPFROM2SHORT(td->pItems[item].ulCommand, 0), MPFROM2SHORT(CMDSRC_OTHER, TRUE)); - - break; - } - } - if (td->pItems[item].ulType == tiBITMAP) { - rcl.xLeft += TXICON + 3; - rcl.xRight += TXICON + 3; - } else if (td->pItems[item].ulType == tiSEPARATOR) { - rcl.xLeft += TXSEPARATOR + 3; - rcl.xRight += TXSEPARATOR + 3; - } - } - td->ulDepressed = -1; - } - break; - } - } - return WinDefWindowProc(hwnd, msg, mp1, mp2); -} - -void RegisterToolBarClass(HAB hab) { - assert(WinRegisterClass(hab, - WC_MTOOLBAR, - (PFNWP)ToolBarProc, - CS_SIZEREDRAW, - sizeof(void *)) == TRUE); -} - -HWND CreateToolBar(HWND parent, - HWND owner, - ULONG id, - ULONG count, - ToolBarItem *items) -{ - STARTFUNC("CreateToolBar"); - ToolBarData *td; - HWND hwnd; - - td = (ToolBarData *)malloc(sizeof(ToolBarData)); - if (td == 0) - return 0; - td->pItems = (ToolBarItem *)malloc(sizeof(ToolBarItem) * count); - if (td->pItems == 0) - { - free(td); - return 0; - } - - td->cb = sizeof(ToolBarData); - td->ulCount = count; - td->ulDepressed = (LONG)-1; - memcpy((void *)td->pItems, (void *)items, sizeof(ToolBarItem) * count); - - hwnd = WinCreateWindow(parent, - WC_MTOOLBAR, - "ToolBar", - WS_VISIBLE, - 0, 0, 0, 0, - owner, - HWND_TOP, - id, - td, - 0); - - //free(td); <-- Don't do this here as now the window owns the memory! - return hwnd; -} diff --git a/src/pm_tool.h b/src/pm_tool.h deleted file mode 100644 index 628ef49..0000000 --- a/src/pm_tool.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __TOOLBAR_H -#define __TOOLBAR_H - -#define tiBITMAP 1 -#define tiSEPARATOR 2 - -#define tfDISABLED 1 -#define tfDEPRESSED 0x8000 - -#define WC_MTOOLBAR "MToolBar" - -typedef struct { - ULONG ulType; - ULONG ulId; - ULONG ulCommand; - ULONG ulFlags; - HBITMAP hBitmap; -} ToolBarItem; - -typedef struct { - USHORT cb; - LONG ulCount; - ToolBarItem *pItems; - LONG ulDepressed; -} ToolBarData; - -MRESULT EXPENTRY ToolBarProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2); -void RegisterToolBarClass(HAB hab); -HWND CreateToolBar(HWND parent, - HWND owner, - ULONG id, - ULONG count, - ToolBarItem *items); - -#endif diff --git a/src/pmdlg.h b/src/pmdlg.h deleted file mode 100644 index cc619f5..0000000 --- a/src/pmdlg.h +++ /dev/null @@ -1,26 +0,0 @@ -#define IDD_PROMPT 300 -#define IDS_PROMPT 301 -#define IDE_FIELD 302 - -#define IDD_FINDREPLACE 201 -#define IDD_FIND 202 - -#define IDL_FIND 211 -#define IDL_REPLACE 212 - -#define IDE_FIND 221 -#define IDE_REPLACE 222 - -#define IDC_IGNORECASE 231 -#define IDC_REGEXPS 232 -#define IDC_WORDS 233 -#define IDC_BLOCK 234 -#define IDC_GLOBAL 235 -#define IDC_REVERSE 236 -#define IDC_ALLOCCURENCES 237 -#define IDC_NOPROMPTING 238 -#define IDC_JOINLINE 239 -#define IDC_DELETELINE 240 - -#define IDD_FILEDLG 500 - diff --git a/src/pmdlg.rc b/src/pmdlg.rc deleted file mode 100644 index 6254932..0000000 --- a/src/pmdlg.rc +++ /dev/null @@ -1,81 +0,0 @@ -/* pmdlg */ - -#include "pmdlg.h" - -DLGTEMPLATE IDD_FIND -BEGIN - DIALOG "Find text...", IDD_FIND, 10, 13, 240, 79, WS_VISIBLE, FCF_SYSMENU | FCF_TITLEBAR - BEGIN - CONTROL "Find", IDL_FIND, 3, 66, 25, 8, WC_STATIC, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE - CONTROL "", IDE_FIND, 37, 20, 198, 55, WC_COMBOBOX, CBS_DROPDOWN | LS_HORZSCROLL | WS_VISIBLE | WS_GROUP | WS_TABSTOP - CONTROL "Options", 101, 3, 21, 231, 42, WC_STATIC, SS_GROUPBOX | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP - CONTROL "~Ignore Case", IDC_IGNORECASE, 9, 45, 75, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE | WS_GROUP | WS_TABSTOP - CONTROL "Rege~xps", IDC_REGEXPS, 9, 34, 77, 11, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - CONTROL "~Words only", IDC_WORDS, 9, 24, 74, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - CONTROL "~Block", IDC_BLOCK, 86, 45, 60, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - CONTROL "~Global", IDC_GLOBAL, 86, 35, 63, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - CONTROL "~Reverse", IDC_REVERSE, 86, 25, 68, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - CONTROL "~All occurences", IDC_ALLOCCURENCES, 155, 45, 72, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - CONTROL "~Delete line", IDC_DELETELINE, 155, 35, 73, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - CONTROL "~Join line", IDC_JOINLINE, 155, 25, 75, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - DEFPUSHBUTTON "OK", DID_OK, 3, 3, 51, 14, BS_PUSHBUTTON | BS_DEFAULT | WS_VISIBLE | WS_GROUP | WS_TABSTOP - PUSHBUTTON "Cancel", DID_CANCEL, 58, 3, 51, 14 - END - -END - -DLGTEMPLATE IDD_FINDREPLACE -BEGIN - DIALOG "Find and replace...", IDD_FINDREPLACE, 9, 27, 240, 91, WS_VISIBLE, FCF_SYSMENU | FCF_TITLEBAR - BEGIN - CONTROL "Find", IDL_FIND, 4, 78, 29, 8, WC_STATIC, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE - CONTROL "", IDE_FIND, 45, 21, 189, 67, WC_COMBOBOX, CBS_DROPDOWN | LS_HORZSCROLL | WS_VISIBLE | WS_GROUP | WS_TABSTOP - CONTROL "Replace", IDL_REPLACE, 4, 64, 35, 9, WC_STATIC, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP - CONTROL "", IDE_REPLACE, 45, 12, 189, 63, WC_COMBOBOX, CBS_DROPDOWN | LS_HORZSCROLL | WS_VISIBLE | WS_GROUP | WS_TABSTOP - CONTROL "Options", 101, 4, 21, 232, 41, WC_STATIC, SS_GROUPBOX | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP - CONTROL "~Ignore Case", IDC_IGNORECASE, 9, 45, 77, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE | WS_GROUP | WS_TABSTOP - CONTROL "Rege~xps", IDC_REGEXPS, 9, 34, 75, 11, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - CONTROL "~Words only", IDC_WORDS, 9, 24, 77, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - CONTROL "~Block", IDC_BLOCK, 86, 45, 64, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - CONTROL "~Global", IDC_GLOBAL, 86, 35, 64, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - CONTROL "~Reverse", IDC_REVERSE, 86, 25, 68, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - CONTROL "~All occurences", IDC_ALLOCCURENCES, 154, 45, 72, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - CONTROL "~No prompting", IDC_NOPROMPTING, 154, 35, 72, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE - CONTROL "~Join Line", IDC_JOINLINE, 154, 25, 76, 10, WC_BUTTON, BS_AUTOCHECKBOX | WS_VISIBLE | WS_GROUP | WS_TABSTOP - DEFPUSHBUTTON "OK", DID_OK, 4, 3, 51, 14, BS_PUSHBUTTON | BS_DEFAULT | WS_VISIBLE | WS_GROUP | WS_TABSTOP - PUSHBUTTON "Cancel", DID_CANCEL, 59, 3, 51, 14 - END - -END - -DLGTEMPLATE IDD_PROMPT -BEGIN - DIALOG "", IDD_PROMPT, 6, 125, 198, 50, WS_VISIBLE, FCF_SYSMENU | FCF_TITLEBAR - BEGIN - CONTROL "", IDS_PROMPT, 3, 39, 192, 7, WC_STATIC, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP - CONTROL "", IDE_FIELD, 4, 3, 191, 34, WC_COMBOBOX, CBS_DROPDOWN | WS_VISIBLE | WS_GROUP | WS_TABSTOP - DEFPUSHBUTTON "OK", DID_OK, 4, 3, 51, 14 - PUSHBUTTON "Cancel", DID_CANCEL, 59, 3, 51, 14 - END - -END - -DLGTEMPLATE IDD_FILEDLG -BEGIN - DIALOG "", IDD_FILEDLG, 11, -2, 242, 200, FS_DLGBORDER | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SAVEBITS, FCF_TITLEBAR | FCF_SYSMENU - BEGIN - LTEXT "~Name", DID_FILENAME_TXT, 6, 189, 229, 8, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | NOT WS_GROUP - CONTROL "", DID_FILENAME_ED, 5, 143, 234, 45, WC_COMBOBOX, 2 | WS_VISIBLE | WS_GROUP | WS_TABSTOP - LTEXT "~Type of file:", DID_FILTER_TXT, 6, 168, 133, 8, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP - CONTROL "", DID_FILTER_CB, 5, 102, 135, 65, WC_COMBOBOX, 4 | WS_VISIBLE | WS_GROUP | WS_TABSTOP - LTEXT "~Drive:", DID_DRIVE_TXT, 145, 168, 91, 8, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP - CONTROL "", DID_DRIVE_CB, 143, 103, 95, 64, WC_COMBOBOX, 4 | WS_VISIBLE | WS_GROUP | WS_TABSTOP - LTEXT "~File:", DID_FILES_TXT, 125, 146, 114, 8, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP - CONTROL "", DID_FILES_LB, 125, 23, 111, 120, WC_LISTBOX, WS_VISIBLE | WS_TABSTOP - LTEXT "Di~rectory:", DID_DIRECTORY_TXT, 5, 146, 110, 8, SS_TEXT | DT_LEFT | DT_TOP | DT_MNEMONIC | WS_VISIBLE | WS_GROUP - CONTROL "", DID_DIRECTORY_LB, 5, 23, 113, 120, WC_LISTBOX, LS_OWNERDRAW | WS_VISIBLE | WS_TABSTOP - CONTROL "Ok", DID_OK, 5, 4, 40, 14, WC_BUTTON, 1024 | WS_VISIBLE | WS_GROUP | WS_TABSTOP - CONTROL "Cancel", DID_CANCEL, 51, 4, 40, 14, WC_BUTTON, WS_VISIBLE | WS_TABSTOP - END - -END diff --git a/src/sysdep.h b/sysdep.h similarity index 100% rename from src/sysdep.h rename to sysdep.h diff --git a/src/view.cpp b/view.cpp similarity index 100% rename from src/view.cpp rename to view.cpp