--- nono/wx/wxlogmonitor.cpp 2026/04/29 17:04:28 1.1 +++ nono/wx/wxlogmonitor.cpp 2026/04/29 17:04:36 1.1.1.3 @@ -1,9 +1,9 @@ // // nono -// Copyright (C) 2018 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // -#include "wxheader.h" #include "wxlogmonitor.h" #include "logger.h" @@ -18,17 +18,22 @@ wxEND_EVENT_TABLE() // コンストラクタ WXLogMonitor::WXLogMonitor(wxWindow *parent, wxWindowID id) - : inherited(parent, id, "ログモニター") + : inherited(parent, id, _("Log")) { col = 80; row = 40; - logbuf = new uint8 [row * col]; - memset(logbuf, 0x20, row * col); + logbuf.reset(new uint8 [row * col]); + memset(&logbuf[0], 0x20, row * col); text.Init(col, row); + wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); + // テキストスクリーン screen = new WXTextScreen(this, col, row, text.GetBuf()); + topsizer->Add(screen, BorderFlags); + + SetSizer(topsizer); // 大きさを固定 Layout(); @@ -48,9 +53,6 @@ WXLogMonitor::WXLogMonitor(wxWindow *par // デストラクタ WXLogMonitor::~WXLogMonitor() { - if (logbuf) { - delete logbuf; - } } // タイマーイベント @@ -61,7 +63,7 @@ WXLogMonitor::OnTimer(wxTimerEvent& even bool updated = false; // キューから読めるだけ全部ログバッファに書き込む - while (gLogger->Read(buf, sizeof(buf))) { + while (gLogger.Read(buf, sizeof(buf))) { Append(buf); updated = true; } @@ -145,9 +147,9 @@ WXLogMonitor::Append(const char *utfbuf) } // コピー。残りは空白で埋める - memcpy(logbuf + target, sjis + spos, len); + memcpy(&logbuf[target], &sjis[spos], len); if (len < col) { - memset(logbuf + target + len, 0x20, col - len); + memset(&logbuf[target + len], 0x20, col - len); } spos += len;