75 #include "X11workbench.h" 77 #include "gdb_helper.h" 79 #include "context_help.h" 80 #include "resource_edit.h" 84 #include "pixmap_helper.h" 88 #include "file_help.h" 93 #include "application_icon.xpm" 94 #include "icon_app.xpm" 95 #include "textfiledoc.xpm" 97 #include "clangdoc.xpm" 98 #include "makefiledoc.xpm" 109 #include "splash.xpm" 114 #ifdef X_HAVE_UTF8_STRING 118 #define UTF8_COPYRIGHT "\xc2""\xa9" 121 #endif // X_HAVE_UTF8_STRING 128 static int do_main(
int argc,
char *argv[],
char *envp[]);
129 static void SetSignalHandlers(
void);
130 static int MyWindowCallback(Window wID, XEvent *pEvent);
131 static int ApplicationPreferences(XClientMessageEvent *pEvent);
132 static int FileExitHandler(XClientMessageEvent *);
133 static int FileNewHandler(XClientMessageEvent *);
134 static int FileOpenHandler(XClientMessageEvent *);
135 static int FileSaveHandler(XClientMessageEvent *);
137 static int FileSaveAsHandler(XClientMessageEvent *);
139 static int FileSaveAllHandler(XClientMessageEvent *);
141 static int FileCloseHandler(XClientMessageEvent *);
143 static int HelpAboutHandler(XClientMessageEvent *);
144 static int HelpContentsHandler(XClientMessageEvent *);
145 static int HelpContextHandler(XClientMessageEvent *);
147 static int TabLeftHandler(XClientMessageEvent *);
148 static int TabRightHandler(XClientMessageEvent *);
149 static int TabMoveLeftHandler(XClientMessageEvent *);
150 static int TabMoveRightHandler(XClientMessageEvent *);
153 static int ToolBoxHandler(XClientMessageEvent *pEvent);
156 int DoFileOpen(
WBFrameWindow *pMainFrame,
const char *szFileName);
157 WBFILE_TYPE GetFileType(
const char *szFileName);
164 int WBMain(
int argc,
char *argv[],
char *envp[])
168 iRval = do_main(argc, argv, envp);
181 static Display *pX11Display = NULL;
183 static XColor clrGreen;
186 Window GetFrameWindowID()
193 return pMainFrame->
wID;
210 static char szAppMenu[]=
"1\n" 217 "_New File\tIDM_FILE_NEW\tNew File\tCtrl+N\n" 218 "_Open File\tIDM_FILE_OPEN\tOpen File\tCtrl+O\n" 220 "_Preferences\tIDM_PREFERENCES\tApplication Preferences\tCtrl+P\n" 222 "E_xit\tIDM_FILE_EXIT\tClose Application\tAlt+F4\n" 225 "_Contents\tIDM_HELP_CONTENTS\tHelp Contents\tAlt+F1\n" 226 "Conte_xt\tIDM_HELP_CONTEXT\tContext Help\tF1\n" 228 "_About X11workbench\tIDM_HELP_ABOUT\tAbout X11workbench\tAlt+F1\n" 231 "_Toolbox\tIDM_TOOLBOX\tDisplay (or hide) the Toolbox\n" 232 "_Options\tIDM_TOOLS_OPTIONS\tDisplay Options Editor\n" 238 static char szEditMenu[]=
"1\n" 243 "_Window\tpopup\t6\n" 256 "_Preferences\tIDM_PREFERENCES\tApplication Preferences\tCtrl+P\n" 258 "E_xit\tIDM_FILE_EXIT\tClose Application\tAlt+F4\n" 261 "_Contents\tIDM_HELP_CONTENTS\tHelp Contents\tAlt+F1\n" 262 "Conte_xt\tIDM_HELP_CONTEXT\tContext Help\tF1\n" 264 "_About X11workbench\tIDM_HELP_ABOUT\tAbout X11workbench\tAlt+F1\n" 278 "_Find\tIDM_EDIT_FIND\tFind within Document\tCtrl+F\n" 279 "Find Ne_xt\tIDM_EDIT_FIND_NEXT\tFind next occurence within Document\tCtrl+G\n" 280 "_Project Find\tIDM_EDIT_PROJ_FIND\tFind within entire project\tCtrl+Shift+F\n" 281 "Pro_ject Find Next\tIDM_EDIT_PROJ_FIND_NEXT\tFind next occurrence within entire project\tCtrl+Shift+G\n" 286 "_Toolbox\tIDM_TOOLBOX\tDisplay (or hide) the Toolbox\n" 287 "_Options\tIDM_TOOLS_OPTIONS\tDisplay Options Editor\n" 290 "Tab _Left\tIDM_TAB_LEFT\tScroll Tab Left\tCtrl+Alt+PgUp\n" 291 "Tab _Right\tIDM_TAB_RIGHT\tScroll Tab Right\tCtrl+Alt+PgDown\n" 293 "Re-order Le_ft\tIDM_TAB_MOVE_LEFT\tScroll Tab Left\tCtrl+Alt+Shift+PgUp\n" 294 "Re-order R_ight\tIDM_TAB_MOVE_RIGHT\tScroll Tab Right\tCtrl+Alt+Shift+PgDown\n" 370 fputs(
"X11workbench - Copyright (c) 2010-2019 by S.F.T. Inc. - all rights reserved\n\n" 371 "Usage: X11workbench [options] filename [filename [...]]\n" 372 " where 'filename' represents one or more files or workspaces to be opened on startup\n" 374 "Standard X11workbench Options\n" 375 "-h display this message\n" 377 "-d dump settings on startup\n" 380 "--nosplash Skip the 'splash' screen on startup\n" 387 static void get_min_window_height_width(
int *piMinHeight,
int *piMinWidth)
389 #if 0 // old code, consider removing this 400 unsigned long pad = 32 ;
401 unsigned long bw = 1;
403 *piMinHeight = fth + pad * 2 + bw * 2;
406 strlen(STRING)) + pad * 2 + bw * 2;
426 int do_main(
int argc,
char *argv[],
char *envp[])
432 char szGreen[]=
"#00FF00";
434 int i1, iMinHeight, iMinWidth;
436 int iDebugDumpConfig = 0;
449 if(argv[1][0] !=
'-' || !argv[1][1])
451 if(argv[1][0] ==
'-')
460 if(argv[1][1] ==
'-')
464 if(!strcmp(&(argv[1][2]),
"nosplash"))
470 fprintf(stderr,
"Unrecognized option \"%s\"\n", argv[1]);
476 for(i1=1; argv[1][i1]; i1++)
478 if(argv[1][i1] ==
'h' ||
485 else if(argv[1][i1] ==
'd')
487 iDebugDumpConfig = 1;
492 fprintf(stderr,
"Unrecognized option \"-%c\"\n", argv[1][i1]);
508 pX11Display =
WBInit(NULL);
546 XParseColor(pX11Display, colormap, szGreen, &clrGreen);
547 XAllocColor(pX11Display, colormap, &clrGreen);
555 #ifdef UTF8_COPYRIGHT
556 "Copyright " UTF8_COPYRIGHT
" 2010-2019 by Big Bad Bombastic Bob\nwww.mrp3.com" 558 "Copyright (c) 2010-2019 by Big Bad Bombastic Bob\nwww.mrp3.com" 562 if(pCopyright && nCPU > 0)
566 snprintf(tbuf,
sizeof(tbuf),
"%d **", nCPU);
577 pCopyright, WhitePixel(pX11Display, DefaultScreen(pX11Display)));
584 "Copyright (c) 2010-2019 by Big Bad Bombastic Bob\nwww.mrp3.com",
585 WhitePixel(pX11Display, DefaultScreen(pX11Display)));
590 get_min_window_height_width(&iMinHeight, &iMinWidth);
613 xsh.width, xsh.height,
621 WB_ERROR_PRINT(
"%s - Unable to create main frame window\n", __FUNCTION__);
650 DoFileOpen(pMainFrame, argv[1]);
702 "%s - Application about to exit\n", __FUNCTION__);
715 extern void TestFunc(Display *pDisplay,
WBGC gc, Window wID,
int iX,
int iY);
717 static int MyWindowCallback(Window wID, XEvent *pEvent)
719 XWindowAttributes xwa;
727 if(pEvent->type == DestroyNotify &&
728 pEvent->xdestroywindow.window == wID)
731 "%s - DestroyNotify\n", __FUNCTION__);
733 if(pMainFrame && pMainFrame->
wID == wID)
741 if(pEvent->type == ClientMessage &&
745 "%s - QUERY_CLOSE\n", __FUNCTION__);
747 if(pEvent->xclient.data.l[0])
749 if(pMainFrame && pMainFrame->
wID == wID)
758 if (pEvent->type == Expose && pEvent->xexpose.count == 0)
784 if(XGetWindowAttributes(pX11Display, wID, &xwa) == 0)
786 WB_ERROR_PRINT(
"%s - Cannot get correct attributes for window! Returning %d\n",
787 __FUNCTION__, iRval);
796 "%s.%d - WBBeginPaint returns 'None'\n",
797 __FUNCTION__, __LINE__);
804 #ifdef DISPLAY_HELLO_WORLD 807 int x, y, x0, y0, x1, y1;
809 pFont = WBGetWindowFontStruct(wID);
812 WB_ERROR_PRINT(
"%s - No font - returning %d\n", __FUNCTION__, iRval);
816 x0 = XTextWidth(pFont, STRING, strlen(STRING));
817 y0 = pFont->max_bounds.ascent
818 - pFont->max_bounds.descent;
820 x = (xwa.width - x0) / 2;
821 y = (xwa.height + pFont->max_bounds.ascent
822 - pFont->max_bounds.descent) / 2;
829 y1 = y + pFont->max_bounds.descent + 20;
838 XDrawString(pX11Display, wID, gc, x, y, STRING, strlen(STRING));
840 XSetForeground(pX11Display, gc, clrGreen.pixel);
844 XDrawRectangle(pX11Display, wID, gc, x0, y0, x1 - x0, y1 - y0);
847 #endif // DISPLAY_HELLO_WORLD 856 "%s - Expose returning %d\n", __FUNCTION__, iRval);
862 if(pEvent->type == ClientMessage && pEvent->xclient.message_type ==
aMENU_COMMAND)
866 WB_DEBUG_PRINT(DebugLevel_Light | DebugSubSystem_Window | DebugSubSystem_Menu | DebugSubSystem_Event,
867 "%s - detecting main window menu event %ld\n", __FUNCTION__,
868 pEvent->xclient.data.l[0]);
872 "%s - Returning %d\n", __FUNCTION__, iRval);
891 int DoFileOpen(
WBFrameWindow *pMainFrame,
const char *szFileName)
898 if(!pMainFrame || !szFileName || !*szFileName)
907 ft = GetFileType(szFileName);
909 if(ft == WBFILE_TYPE_PROJECT)
912 "File Open",
"'File _Open' project file not (yet) supported");
914 else if(ft == WBFILE_TYPE_RESOURCE)
917 "File Open",
"'File _Open' resource file not (yet) supported");
919 else if(ft == WBFILE_TYPE_PIXMAP)
922 "File Open",
"'File _Open' pixmap file not (yet) supported");
924 else if(ft == WBFILE_TYPE_DIALOG)
927 "File Open",
"'File _Open' dialog resource file not (yet) supported");
929 else if(ft == WBFILE_TYPE_MENU)
932 "File Open",
"'File _Open' menu resource file not (yet) supported");
934 else if(ft == WBFILE_TYPE_TOOLBAR)
937 "File Open",
"'File _Open' toolbar resource file not (yet) supported");
950 "File Open",
"'File _Open' unable to create edit window");
963 "File Open",
"'File _Open' unable to read file into edit window");
978 iLineEnd = GetDefaultLineEnding(ft);
979 iTab = GetDefaultTabSetting(ft);
984 if(ft == WBFILE_TYPE_MAKEFILE ||
985 ft == WBFILE_TYPE_AUTOCONF)
990 else if(ft == WBFILE_TYPE_CPROG || ft == WBFILE_TYPE_CPP ||
991 ft == WBFILE_TYPE_CHEADER || ft == WBFILE_TYPE_SHELL ||
992 ft == WBFILE_TYPE_PYTHON || ft == WBFILE_TYPE_PERL ||
993 ft == WBFILE_TYPE_ASM || ft == WBFILE_TYPE_JAVA ||
994 ft == WBFILE_TYPE_JS || ft == WBFILE_TYPE_PHP ||
995 ft == WBFILE_TYPE_ARDUINO)
1009 else if(ft == WBFILE_TYPE_HTML ||
1010 ft == WBFILE_TYPE_XML)
1043 const char *pDisplayName;
1046 pDisplayName = szFileName + strlen(szFileName);
1048 while(pDisplayName > szFileName && *(pDisplayName - 1) !=
'/')
1058 return pCF ? 0 : -1;
1062 WBFILE_TYPE GetFileType(
const char *szFileName)
1064 const char *pFN, *pExt;
1066 pFN = pExt = szFileName + strlen(szFileName);
1068 while(pFN > szFileName && *(pFN - 1) !=
'/')
1073 while(pExt > szFileName && *(pExt - 1) !=
'.')
1078 if(pExt <= szFileName)
1086 if(pExt && !strcasecmp(
"makefile", pExt))
1088 return WBFILE_TYPE_MAKEFILE;
1094 else if(!strcasecmp(
"mk", pExt))
1096 return WBFILE_TYPE_MAKEFILE;
1098 else if(!strcasecmp(
"h", pExt))
1100 return WBFILE_TYPE_MAKEFILE;
1102 else if(!strcasecmp(
"c", pExt))
1104 return WBFILE_TYPE_CPROG;
1106 else if(!strcasecmp(
"h", pExt))
1108 return WBFILE_TYPE_CHEADER;
1110 else if(!strcasecmp(
"cpp", pExt))
1112 return WBFILE_TYPE_CPP;
1114 else if(!strcmp(
"java", pExt))
1116 return WBFILE_TYPE_JAVA;
1118 else if(!strcmp(
"js", pExt))
1120 return WBFILE_TYPE_JS;
1122 else if(!strcmp(
"pl", pExt))
1124 return WBFILE_TYPE_PERL;
1126 else if(!strcasecmp(
"py", pExt))
1128 return WBFILE_TYPE_PYTHON;
1130 else if(!strcmp(
"xpm", pExt))
1132 return WBFILE_TYPE_PIXMAP;
1134 else if(!strcmp(
"ac", pExt) || !strcmp(
"am", pExt))
1136 return WBFILE_TYPE_AUTOCONF;
1138 else if(!strcasecmp(
"xwb", pExt))
1140 return WBFILE_TYPE_PROJECT;
1142 else if(!strcasecmp(
"xwbrc", pExt))
1144 return WBFILE_TYPE_RESOURCE;
1146 else if(!strcasecmp(
"xwbdlg", pExt))
1148 return WBFILE_TYPE_DIALOG;
1150 else if(!strcasecmp(
"xwbmenu", pExt))
1152 return WBFILE_TYPE_MENU;
1154 else if(!strcasecmp(
"xwbbar", pExt))
1156 return WBFILE_TYPE_TOOLBAR;
1158 else if(!strcmp(
"sh", pExt))
1160 return WBFILE_TYPE_SHELL;
1162 else if(!strcasecmp(
"php", pExt))
1164 return WBFILE_TYPE_PHP;
1166 else if(!strcasecmp(
"htm", pExt) || !strcasecmp(
"html", pExt))
1168 return WBFILE_TYPE_HTML;
1170 else if(!strcasecmp(
"xml", pExt))
1172 return WBFILE_TYPE_XML;
1174 else if(!strcasecmp(
"pde", pExt) || !strcasecmp(
"ino", pExt))
1176 return WBFILE_TYPE_ARDUINO;
1180 return WBFILE_TYPE_TEXT;
1184 int GetDefaultTabSetting(WBFILE_TYPE nFileType)
1186 if(nFileType == WBFILE_TYPE_MAKEFILE || nFileType == WBFILE_TYPE_AUTOCONF)
1204 int GetDefaultLineEnding(WBFILE_TYPE nFileType)
1206 if(nFileType == WBFILE_TYPE_HTML ||
1207 nFileType == WBFILE_TYPE_XML)
1211 else if(nFileType == WBFILE_TYPE_MAKEFILE || nFileType == WBFILE_TYPE_AUTOCONF)
1221 const char *GetFileTypeDesc(WBFILE_TYPE nFileType)
1223 static const char *
const aszDesc[] =
1228 "C++ Program Source",
1229 "C/C++ Header File",
1241 "Assembly Program Source",
1244 "Java Program Source",
1245 "JavaScript Program",
1251 if(WBFILE_TYPE_LAST >
sizeof(aszDesc)/
sizeof(aszDesc[0]))
1253 WB_WARN_PRINT(
"WARNING: %s 'aszDesc' array is too small\n", __FUNCTION__);
1256 if((
int)nFileType >=
sizeof(aszDesc)/
sizeof(aszDesc[0]) || (
int)nFileType < 0)
1261 return aszDesc[(int)nFileType];
1265 const char *GetFileTypeHighlightInfo(WBFILE_TYPE nFileType)
1267 if(nFileType == WBFILE_TYPE_CPROG ||
1268 nFileType == WBFILE_TYPE_CPP ||
1269 nFileType == WBFILE_TYPE_CHEADER ||
1270 nFileType == WBFILE_TYPE_ARDUINO)
1272 static const char szC[]=
1275 "CommentBlockBegin: /*\n" 1276 "CommentBlockEnd: */\n" 1290 "IgnoreEscapement:\n" 1292 "LineContinuation: \\\n" 1293 "MacroDefinition: #define\n" 1294 "Conditionals: #if #ifdef\n" 1295 "ElseCondition: #else\n" 1296 "ElseIfCondition: #elif\n" 1297 "EndIfCondition: #endif\n" 1298 "AlwaysTrue: \"#if 1\" \"#elif 1\" \"#if !0\" \"#elif !0\"\n" 1301 "AlwaysFalse: \"#if 0\" \"#elif 0\"\n" 1304 "Keywords: if else for while do goto break switch case default char short long int unsigned const volatile " 1305 "float double struct class union enum typedef auto register inline " 1306 "namespace template using try catch except throw\n" 1309 "AltKeywords: __attribute__ __inline __try __catch __except #pragma\n";
1314 else if(nFileType == WBFILE_TYPE_JAVA ||
1315 nFileType == WBFILE_TYPE_JS)
1317 static const char szJava[]=
1318 "Language: Java/JavaScript\n" 1320 "CommentBlockBegin: /*\n" 1321 "CommentBlockEnd: */\n" 1335 "IgnoreEscapement:\n" 1337 "LineContinuation: \\\n" 1338 "MacroDefinition:\n" 1341 "ElseIfCondition:\n" 1345 "Keywords: if else elif for each in while do break switch case default char short long int final variant " 1346 "float double struct class union enum typedef try catch throw except " 1347 "finally namespace template using\n" 1348 "AltKeywords: __attribute__ __inline #pragma\n";
1352 else if(nFileType == WBFILE_TYPE_SHELL)
1354 static const char szShell[]=
1357 "CommentBlockBegin:\n" 1358 "CommentBlockEnd:\n" 1371 "IgnoreEscapement: '\n" 1374 "LineContinuation: \\\n" 1375 "MacroDefinition:\n" 1378 "ElseIfCondition:\n" 1382 "Keywords: if fi else elif for in while do done break case local return exit echo\n" 1387 else if(nFileType == WBFILE_TYPE_MAKEFILE ||
1388 nFileType == WBFILE_TYPE_AUTOCONF)
1390 static const char szMakefile[]=
1393 "CommentBlockBegin:\n" 1394 "CommentBlockEnd:\n" 1407 "IgnoreEscapement: '\n" 1410 "LineContinuation: \\\n" 1411 "MacroDefinition:\n" 1414 "ElseIfCondition:\n" 1418 "Keywords: if fi else elif for in while do done break case local return exit echo\n" 1419 "AltKeywords: @if -if @for -for @while -while @echo -echo\n";
1423 else if(nFileType == WBFILE_TYPE_PERL)
1427 else if(nFileType == WBFILE_TYPE_PHP)
1431 else if(nFileType == WBFILE_TYPE_PYTHON)
1435 else if(nFileType == WBFILE_TYPE_HTML ||
1436 nFileType == WBFILE_TYPE_XML)
1457 static int ApplicationPreferences(XClientMessageEvent *pEvent)
1464 "Application Properties",
"'Properties' and no container window");
1468 clr.pixel = clrGreen.pixel;
1476 static int FileExitHandler(XClientMessageEvent *pEvent)
1485 static int FileNewHandler(XClientMessageEvent *pEvent)
1492 "File New",
"'File _New' and no container window");
1506 "File New",
"'File _New' unable to create edit window");
1513 static int FileOpenHandler(XClientMessageEvent *pEvent)
1515 Window wIDOwner = pMainFrame ? pMainFrame->
wID : None;
1520 ".txt\tText Files\n" 1521 ".c\tC language file\n" 1522 ".cpp\tC language file\n" 1523 ".h\tC language header\n" 1524 "Makefile\tMake Files\n" 1525 ".mk\tMake 'include' Files\n" 1526 ".am\tAutotools File\n" 1531 DoFileOpen(pMainFrame, pFile);
1539 static int FileSaveHandler(XClientMessageEvent *pEvent)
1541 Window wIDOwner = pMainFrame ? pMainFrame->
wID : None;
1545 "'File _Save' not currently implemented");
1555 static int FileSaveAsHandler(XClientMessageEvent *pEvent)
1557 Window wIDOwner = pMainFrame ? pMainFrame->
wID : None;
1561 "'File Save _As' not currently implemented");
1571 static int FileSaveAllHandler(XClientMessageEvent *pEvent)
1573 Window wIDOwner = pMainFrame ? pMainFrame->
wID : -1;
1577 "'File Save A_ll' not currently implemented");
1587 static int HelpAboutHandler(XClientMessageEvent *pEvent)
1589 Window wIDOwner = pMainFrame ? pMainFrame->
wID : None;
1593 "About X11workbench",
1594 "X11workbench - BBB's answer to a proper development environment for X11");
1599 static int FileCloseHandler(XClientMessageEvent *pEvent)
1622 static int TabLeftHandler(XClientMessageEvent *pEvent)
1633 WB_ERROR_PRINT(
"TEMPORARY: %s - move left %d\n", __FUNCTION__, iIndex);
1643 static int TabRightHandler(XClientMessageEvent *pEvent)
1654 WB_ERROR_PRINT(
"TEMPORARY: %s - move right %d\n", __FUNCTION__, iIndex);
1664 static int TabMoveLeftHandler(XClientMessageEvent *pEvent)
1683 static int TabMoveRightHandler(XClientMessageEvent *pEvent)
1712 static int ToolBoxHandler(XClientMessageEvent *pEvent)
1715 "ToolBox Handler not (yet) implemented");
1727 static int HelpContentsHandler(XClientMessageEvent *pEvent)
1729 Window wIDOwner = pMainFrame ? pMainFrame->
wID : None;
1731 char *pTemp =
DLGInputBox(wIDOwner,
"Help Contents",
"Enter a search term for the documentation",
"WBInit", -1, -1);
1735 DoContextSensitiveHelp(pTemp);
1748 static int HelpContextHandler(XClientMessageEvent *pEvent)
1750 Window wIDOwner = pMainFrame ? pMainFrame->
wID : None;
1753 "Context Help",
"TODO: implement the context-sensitive help");
1768 typedef struct _xsiginfo_
1770 const char *szSignal;
1774 #define SIGINFO_ENTRY(X) { #X, X } 1775 static const XSIGINFO aSigInfo[] =
1777 SIGINFO_ENTRY(SIGHUP),
1778 SIGINFO_ENTRY(SIGINT),
1779 SIGINFO_ENTRY(SIGQUIT),
1780 SIGINFO_ENTRY(SIGILL),
1781 SIGINFO_ENTRY(SIGTRAP),
1782 SIGINFO_ENTRY(SIGABRT),
1784 SIGINFO_ENTRY(SIGEMT),
1786 SIGINFO_ENTRY(SIGFPE),
1788 SIGINFO_ENTRY(SIGBUS),
1789 SIGINFO_ENTRY(SIGSEGV),
1790 SIGINFO_ENTRY(SIGSYS),
1791 SIGINFO_ENTRY(SIGPIPE),
1792 SIGINFO_ENTRY(SIGALRM),
1793 SIGINFO_ENTRY(SIGTERM),
1794 SIGINFO_ENTRY(SIGURG),
1798 SIGINFO_ENTRY(SIGCHLD),
1799 SIGINFO_ENTRY(SIGTTIN),
1800 SIGINFO_ENTRY(SIGTTOU),
1801 SIGINFO_ENTRY(SIGIO),
1802 SIGINFO_ENTRY(SIGXCPU),
1803 SIGINFO_ENTRY(SIGXFSZ),
1804 SIGINFO_ENTRY(SIGVTALRM),
1805 SIGINFO_ENTRY(SIGPROF),
1806 SIGINFO_ENTRY(SIGWINCH),
1808 SIGINFO_ENTRY(SIGINFO),
1810 SIGINFO_ENTRY(SIGUSR1),
1811 SIGINFO_ENTRY(SIGUSR2),
1816 static void signalproc(
int iSig)
1818 static int bCtrlCFlag = 0;
1827 "\n**********************************************" 1828 "\nSignal received: SIGTSTP (detaching via fork)" 1829 "\n The process has now gone into the background" 1830 "\n and is still running (i.e. not suspended)." 1831 "\n**********************************************\n");
1862 else if(iSig == SIGCONT)
1868 for(i1=0; i1 <
sizeof(aSigInfo)/
sizeof(aSigInfo[0]); i1++)
1870 if(!aSigInfo[i1].szSignal)
1875 if(aSigInfo[i1].nSignal == iSig)
1878 "\nX11workbench - Signal received: %s\n", aSigInfo[i1].szSignal);
1882 if(iSig == SIGHUP || iSig == SIGINT || iSig == SIGQUIT ||
1883 iSig == SIGILL || iSig == SIGTRAP || iSig == SIGABRT ||
1887 iSig == SIGSYS || iSig == SIGTERM || iSig == SIGSTOP ||
1888 iSig == SIGXCPU || iSig == SIGXFSZ || iSig == SIGFPE)
1890 if(
bQuitFlag && (iSig == SIGSTOP || iSig == SIGTERM || iSig == SIGINT))
1896 WB_ERROR_PRINT(
"\n----------------------------------------------------------------------------" 1897 "\n X11workbench CTRL+C signal handler" 1898 "\nINT/STOP/TERM, waiting for soft termination - signal again to terminate NOW!" 1899 "\n----------------------------------------------------------------------------\n");
1905 WB_ERROR_PRINT(
"\n----------------------------------------------------------------------------" 1906 "\n X11workbench CTRL+C signal handler" 1907 "\nINT/STOP/TERM, aborting waiting for soft termination - terminate RIGHT NOW!!" 1908 "\n----------------------------------------------------------------------------\n");
1920 if(iSig == SIGKILL || iSig == SIGSEGV)
1922 signal(iSig, SIG_DFL);
1926 WB_ERROR_PRINT(
"caught signal %d (SIGKILL), terminating now\n", iSig);
1931 WB_ERROR_PRINT(
"caught signal %d (SIGSEGV), terminating now\n", iSig);
1942 "SIGBUS received (this is usually caused by use of a data pointer instead of a function pointer)\n");
1951 "signal proc (%d) (%08xH)\n", iSig, iSig);
1957 static void SetSignalHandlers()
1960 for(i1=0; i1 <
sizeof(aSigInfo)/
sizeof(aSigInfo[0]); i1++)
1962 if(!aSigInfo[i1].szSignal)
1965 if(signal(aSigInfo[i1].nSignal, signalproc))
1967 WB_WARN_PRINT(
"%s - WARNING: Unable to assign signal proc for %s\n", __FUNCTION__, aSigInfo[i1].szSignal);
Icon - multiple question marks in red triangle.
Window wID
Window id for the frame window.
#define FW_EDIT_SELECT_ALL_ACCEL
int WBEditWindowLoadFile(WBEditWindow *pEditWindow, const char *pszFileName)
Open an existing file and read its contents into the Edit Window, storing the file name for later ref...
'window helper' main header file for the X11workbench Toolkit API
#define FW_FILE_SAVE_ACCEL
WBChildFrame childframe
elements common to a 'child frame' (derived object)
void FWRemoveContainedWindow(WBFrameWindow *pFW, WBChildFrame *pCont)
Removes a 'contained' window from a frame window. Does not destroy the 'contained' window.
int bQuitFlag
'Quit' Flag - you should check this periodically in your main (message) loop and exit whenever it is ...
void WBClearWindow(Window wID, WBGC gc)
'Paint' helper, erases background by painting the background color within the clipping region
#define WB_DEBUG_PRINT(L,...)
Preferred method of implementing conditional debug output.
static __inline__ Colormap WBDefaultColormap(Display *pDisplay)
returns the default colormap for the default screen of the specified display
#define FW_EDIT_UNDO_ACCEL
set this flag for application top-level window and whenever it is destroyed the application will exit
Utilities for copying and drawing text, determining text extents, and so on.
WBEditWindow * WBCreateEditWindow(WBFrameWindow *pOwner, WB_FONT pFont, const char *szFocusMenu, const WBFWMenuHandler *pHandlerArray, int fFlags)
Create an Edit Window.
void WBExit()
deletes any remaining global objects, frees the Display pointer, and terminates event processing
void WBWaitForEvent(Display *pDisplay)
Wait for an event, blocking indefinitely.
Display * WBInit(const char *szDisplayName)
initializes default objects for the specified Display (required)
int WBCheckGetEvent(Display *pDisplay, XEvent *pEvent)
Main message loop, high level API to check for and retrieve the next event.
void PXM_RegisterAppIcons(char *ppRegAppLarge[], char *ppRegAppSmall[])
Icon Registration for application 'large' and 'small' icons.
int FWGetChildFrameIndex(WBFrameWindow *pFW, WBChildFrame *pCont)
Sets the focus to a specific contained window using its tab order index.
#define FW_EDIT_DELETE_MENU
Edit Window API functions.
int DLGColorDialog(Window wIDOwner, XStandardColormap *pColorMap, XColor *pColor)
Display a modal Color Dialog window, returning the selected color in the XColor structure pointed to ...
Window wID
window identifier for the 'Child Frame' window. may contain 'None' while being destroyed
#define FW_EDIT_REDO_ACCEL
char * DLGInputBox(Window wIDOwner, const char *szTitle, const char *szPrompt, const char *szDefault, int iWidth, int iMaxChar)
Displays a special purpose dialog window that retrieves a character string as input.
#define FW_FILE_SAVE_ALL_MENU
#define FW_EDIT_SELECT_NONE_MENU
void(* set_filetype)(TEXT_OBJECT *pThis, int iLineFeed)
Set the current file type for the object.
#define FW_FILE_SAVE_MENU
void FWSetMenuHandlers(WBFrameWindow *pFW, const WBFWMenuHandler *pHandlerArray)
Function to assign the default menu handler to a frame window.
int WBMain(int argc, char *argv[], char *envp[])
Startup function, equivalent to 'main()' - provided for convenience.
internal wrapper struct for X11 'geometry' definition
'configuration helper' main header file for the X11 Work Bench Toolkit API
set this to make window immediately visible
void(* set_tab)(TEXT_OBJECT *pThis, int iTab)
Set the current tab type for the object.
#define FW_EDIT_CUT_ACCEL
#define FW_EDIT_PROPERTIES_ACCEL
#define MOVE_CHILD_FRAME_TAB_INDEX_LEFT
pass as 'iIndex' for FWMoveChildFrameTabIndex() to move the tab index left
Structure that defines an Edit Window.
Icon - white 'middle finger' on red triangle.
#define FW_EDIT_PASTE_ACCEL
void WBToolkitUsage(void)
Displays 'usage' for toolkit options to stderr.
unsigned long WBGetWindowFGColor(Window wID)
Returns the currently assigned foreground color.
void FWSetFocusWindowIndex(WBFrameWindow *pFW, int iIndex)
Sets the focus to a specific contained window using its tab order index.
int FWGetNumContWindows(const WBFrameWindow *pFW)
Returns the total number of 'contained' windows.
void CHDumpConfig()
dump config information using debug output functions
XCharStruct max_bounds
RESERVED - cached max bounds (all 0's if not valid). do not access this directly.
void DLGSplashScreen(char *aXPM[], const char *szCopyright, unsigned long clrText)
Display a splash screen for 5 seconds (with animation and copyright string), and then return.
#define WB_ERROR_PRINT(...)
Preferred method of implementing an 'error level' debug message for all subsystems.
void WBFree(void *pBuf)
High performance memory sub-allocator 'free'.
void WBDestroyWindow(Window wID)
Destroy a window.
void(* set_linefeed)(TEXT_OBJECT *pThis, int iLineFeed)
Set the current linefeed type for the object.
void FWSetChildFrameDisplayName(WBChildFrame *pChildFrame, const char *szDisplayName)
Assign the display name.
#define FW_EDIT_PROPERTIES_MENU
#define FW_FILE_SAVE_ALL_ACCEL
void FWDestroyChildFrame(WBChildFrame *pChildFrame)
Destroy an Child Frame.
const TEXT_OBJECT_VTABLE * vtable
method function pointers (similar to C++ virtual member functions)
#define FW_FILE_SAVE_AS_MENU
void WBUsage(void)
Optional startup function, sends 'usage' (help) info to stderr - application-defined function.
void WBDispatch(XEvent *pEvent)
Generic Event Dispatcher, using message type to dispatch.
void WBInitSizeHints(XSizeHints *pSH, Display *pDisplay, int iMinHeight, int iMinWidth)
initializes the XSizeHints structure with standard attributes
WBGC WBBeginPaint(Window wID, XExposeEvent *pEvent, WB_GEOM *pgBounds)
'Paint' helper, creates a WBGC for use in updating the window in an Expose event handler
main controlling structure for frame windows
no special handling, no source decorations
void WBBeginWaitCursor(Window wID)
increment 'wait cursor' count, set cursor to WB_WAIT_CURSOR
Atom aQUERY_CLOSE
query if it's ok to close (and optionally destroy yourself if ok) a window
#define FW_FILE_SAVE_AS_ACCEL
Type Flag - File Open Dialog.
TEXT_OBJECT xTextObject
the 'TEXT_OBJECT' member, that does MOST of the work
#define FW_EDIT_SELECT_ALL_MENU
#define FW_EDIT_SELECT_NONE_ACCEL
#define FW_FILE_CLOSE_MENU
Icon - application icon (from icon_app.xpm)
#define FW_FILE_OPEN_ACCEL
Icon - exclamation point on yellow triangle.
#define FW_EDIT_REDO_MENU
char * DLGFileDialog(int iType, Window wIDOwner, const char *szDefPath, const char *szDefName, const char *szExtAndDescList)
Display a modal File Dialog window, returning a WBAlloc'd pointer to a null-byte terminated string co...
#define FW_EDIT_COPY_ACCEL
void WBEndWaitCursor(Window wID)
decrement 'wait cursor' count, restore to default when zero
char * WBCopyString(const char *pSrc)
A simple utility that returns a WBAlloc() copy of a 0-byte terminated string.
Make Files with special handling (implies 'hard tab', always)
WBFrameWindow * FWCreateFrameWindow(const char *szTitle, int idIcon, const char *szMenuResource, int iX, int iY, int iWidth, int iHeight, WBWinEvent pUserCallback, int iFlags)
Create a frame window.
set this to enable a 'status bar' at the bottom
void WBEndPaint(Window wID, WBGC gc)
'Paint' helper, frees resources and marks the update region 'valid'
internal wrapper struct for GC with local cache
Structure that defines a Child Frame within a Frame Window.
#define FW_EDIT_PASTE_MENU
Frame Window API functions and definitions.
#define MOVE_CHILD_FRAME_TAB_INDEX_RIGHT
pass as 'iIndex' for FWMoveChildFrameTabIndex() to move the tab index right
void FWMoveChildFrameTabIndex(WBFrameWindow *pFW, WBChildFrame *pCont, int iIndex)
Sets the specific contained window to a particular index in the tab order.
hard tabs - implied by 'FileType_MAKEFILE', otherwise explicit
#define WB_WARN_PRINT(...)
Preferred method of implementing a 'warning level' debug message for all subsystems.
Icon - yellow circle with white exclamation point.
#define FW_FILE_OPEN_MENU
int DLGMessageBox(int iType, Window wIDOwner, const char *szTitle, const char *szMessage)
Display a modal 'message box' dialog window with a specific title, message, and button combination.
#define FW_EDIT_UNDO_MENU
#define FW_FILE_NEW_ACCEL
#define FW_EDIT_COPY_MENU
void WBCatString(char **ppDest, const char *pSrc)
A simple utility that concatenates a string onto the end of a 0-byte terminated WBAlloc() string.
WB_FONTC WBGetDefaultFont(void)
Returns a pointer to the default font WB_FONT for the default display. This is a shared resource; do ...