/* * Copyright 2022 Olaf Wintermann * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #include #include #include #include #include #include #include "window.h" #include "main.h" #include "settings.h" #include #include static XtAppContext app; static Display *display; static String fallback[] = { "*renderTable: rt", "*rt*fontType: FONT_IS_XFT", "*rt*fontName: Sans", "*rt*fontSize: 9", "*pbbutton.shadowThickness: 1", "*pbbutton.highlightThickness: 1", "*XmText.baseTranslations: #override\\n" \ "Ctrl~Alt~Metav: paste-clipboard()\\n" \ "Ctrl~Alt~Metac: copy-clipboard()\\n" \ "Ctrl~Alt~Metax: cut-clipboard()\\n" \ "Ctrl~Alt~Metau: delete-to-start-of-line()\\n", "*XmTextField.baseTranslations: #override\\n" \ "Ctrl~Alt~Metav: paste-clipboard()\\n" \ "Ctrl~Alt~Metac: copy-clipboard()\\n" \ "Ctrl~Alt~Metax: cut-clipboard()\\n" \ "Ctrl~Alt~Metau: delete-to-start-of-line()\\n", NULL }; static String langProc(Display *dp, String xnl, XtPointer closure) { setlocale(LC_ALL, xnl); setlocale(LC_NUMERIC, "C"); return setlocale(LC_ALL, NULL); } int main(int argc, char** argv) { // disable stdout buffering, because the netbeans's internal terminal // has a bug on freebsd and doesn't flush the output after a newline setvbuf(stdout, NULL, _IONBF, 0); // initialize toolkit XtToolkitInitialize(); XtSetLanguageProc(NULL, langProc, NULL); app = XtCreateApplicationContext(); XtAppSetFallbackResources(app, fallback); display = XtOpenDisplay(app, NULL, APP_NAME, APP_CLASS, NULL, 0, &argc, argv); // load settings if(load_settings()) { return 1; } MainWindow *window = WindowCreate(display); // random numbers only used for creating tmp dirs srand(time(NULL)); WindowShow(window); XtAppMainLoop(app); return 0; } XtAppContext* GetAppContext(void) { return &app; } void ApplicationExit(void) { XtAppSetExitFlag(app); } void AppAddTimeOut(unsigned long interval, XtTimerCallbackProc proc, XtPointer data) { XtAppAddTimeOut(app, interval, proc, data); }