--- nono/wx/wxapp.cpp 2026/04/29 17:04:28 1.1 +++ nono/wx/wxapp.cpp 2026/04/29 17:04:33 1.1.1.2 @@ -9,42 +9,17 @@ #include "wxmainview.h" #include "wxtextpanel.h" #include "mainapp.h" -#include // イベントタイプの定義 DEFINE_EVENT_TYPE(WXW_EVT_CREATE); DEFINE_EVENT_TYPE(WXW_EVT_MONITOR_UPDATE); -// コマンドラインオプションとか -bool console_log; - -// コマンドラインオプション -static const wxCmdLineEntryDesc cmddesc[] = -{ - { wxCMD_LINE_OPTION, "b", "b", "breakpoint", wxCMD_LINE_VAL_STRING }, - { wxCMD_LINE_OPTION, "c", "c", "vm directory", wxCMD_LINE_VAL_STRING }, - { wxCMD_LINE_SWITCH, "d", "d", "debugger prompt on startup", }, - { wxCMD_LINE_SWITCH, "C", "C", "console log" }, - { wxCMD_LINE_SWITCH, "f", "f", "fast mode" }, - { wxCMD_LINE_OPTION, "L", "L", "loglevel (-L help displays names)", - wxCMD_LINE_VAL_STRING }, - { wxCMD_LINE_OPTION, "M", "M", "monitors to display at startup", - wxCMD_LINE_VAL_STRING }, - { wxCMD_LINE_OPTION, "s", "s", "screen scale", wxCMD_LINE_VAL_STRING }, - { wxCMD_LINE_OPTION, "", "fontsize", "font size {12, 16, 24} (default:12)", - wxCMD_LINE_VAL_STRING }, - { wxCMD_LINE_SWITCH, "v", "v", "version" }, - - { wxCMD_LINE_NONE }, -}; - class WXApp : public wxApp { public: bool OnInit(); private: - bool Parse(); bool ParseMonitors(const wxString& str); int SearchMonitorName(const char *name); }; @@ -54,101 +29,49 @@ IMPLEMENT_APP(WXApp) bool WXApp::OnInit() { - debug_breakaddr = 0xffffffff; - WXMainView::screen_scale = 1.0; - WXTextPanel::global_fontsize = FONT_6x12; - vmdir = "."; - - if (!Parse()) { - return false; - } - - // -C オプションならコンソールにもログを出力 - if (!main_init(console_log)) { - return false; - } - - // メインウィンドウ - gMainFrame = new WXMainFrame(NULL); - gMainFrame->Show(true); - SetTopWindow(gMainFrame); - return true; -} - -bool -WXApp::Parse() -{ - u_long ulval; - - wxCmdLineParser cmd(argc, argv); - cmd.SetDesc(cmddesc); - if (cmd.Parse() != 0) { + if (!gMainApp.Init(false, argc, argv)) { return false; } - wxString arg; - - // -v - if (cmd.Found("v")) { - fprintf(stderr, "nono version %d.%d.%d\n", - NONO_MAJOR_VER, NONO_MINOR_VER, NONO_PATCH_VER); + // --fontsize テキスト系コントロールのフォントサイズ + // 紛らわしいが ::global_fontsize は 12, 16 とかいう値。 + // WXTextPanel::global_fontsize (fontsize_t) は enum 値。 + fontsize_t fontsize; + switch (gMainApp.fontsize) { + case 12: + fontsize = FONT_6x12; + break; + case 16: + fontsize = FONT_8x16; + break; + case 24: + fontsize = FONT_12x24; + break; + default: + warnx("invalid fontsize: %d", gMainApp.fontsize); return false; } - - // -b ブレイクポイント - if (cmd.Found("b", &arg)) { - arg.ToULong(&ulval, 16); - debug_breakaddr = ulval; - } - - // -c 設定ファイル - if (cmd.Found("c", &arg)) { - vmdir = std::string((const char *)arg.mb_str()); - } - - // -L ログレベル - if (cmd.Found("L", &arg)) { - strlcpy(logopt, (const char *)arg.mb_str(), sizeof(logopt)); - } + WXTextPanel::global_fontsize = fontsize; // -M 起動時に表示するモニタ - if (cmd.Found("M", &arg)) { - if (!ParseMonitors(arg)) { + if (!gMainApp.monitor_opt.empty()) { + if (!ParseMonitors(gMainApp.monitor_opt)) { return false; } } - // screen scale - if (cmd.Found("s", &arg)) { - if (!arg.ToDouble(&WXMainView::screen_scale)) { - return false; - } - } + // -s screen scale + WXMainView::screen_scale = gMainApp.screen_scale; - // テキスト系コントロールのフォントサイズ - if (cmd.Found("fontsize", &arg)) { - fontsize_t fontsize; - arg.ToULong(&ulval, 10); - switch (ulval) { - case 12: - fontsize = FONT_6x12; - break; - case 16: - fontsize = FONT_8x16; - break; - case 24: - fontsize = FONT_12x24; - break; - default: - return false; - } - WXTextPanel::global_fontsize = fontsize; + // 引数処理が終わったので VM 開始。 + if (!gMainApp.Start()) { + return false; } - console_log = cmd.Found("C"); - debug_on_start = cmd.Found("d"); - fast_mode = cmd.Found("f"); - + // メインウィンドウ + gMainFrame = new WXMainFrame(NULL); + gMainFrame->Show(true); + SetTopWindow(gMainFrame); return true; }