disasmwin_info::disasmwin_info(debugger_windows_interface &debugger) : disasmbasewin_info(debugger, false, "Disassembly", NULL), m_combownd(NULL) { if ((window() == NULL) || (m_views[0] == NULL)) return; // set up the view to track the initial expression set_edit_defstr("curpc"); set_editwnd_text("curpc"); editwnd_select_all(); // create a combo box m_combownd = m_views[0]->create_source_combobox(window(), (LONG_PTR)this); // set the caption update_caption(); // recompute the children once to get the maxwidth disasmwin_info::recompute_children(); // position the window and recompute children again SetWindowPos(window(), HWND_TOP, 100, 100, maxwidth(), 200, SWP_SHOWWINDOW); disasmwin_info::recompute_children(); // mark the edit box as the default focus and set it editwin_info::set_default_focus(); }
void consolewin_info::process_string(char const *string) { if (string[0] == 0) // an empty string is a single step machine().debugger().cpu().get_visible_cpu()->debug()->single_step(); else // otherwise, just process the command machine().debugger().console().execute_command(string, true); // clear the edit text box set_editwnd_text(""); }
void consolewin_info::process_string(char const *string) { if (string[0] == 0) // an empty string is a single step debug_cpu_get_visible_cpu(machine())->debug()->single_step(); else // otherwise, just process the command debug_console_execute_command(machine(), string, 1); // clear the edit text box set_editwnd_text(""); }
memorywin_info::memorywin_info(debugger_windows_interface &debugger) : editwin_info(debugger, false, "Memory", NULL), m_combownd(NULL) { if (!window()) return; m_views[0].reset(global_alloc(memoryview_info(debugger, *this, window()))); if ((m_views[0] == NULL) || !m_views[0]->is_valid()) { m_views[0].reset(); return; } // create the options menu HMENU const optionsmenu = CreatePopupMenu(); AppendMenu(optionsmenu, MF_ENABLED, ID_1_BYTE_CHUNKS, TEXT("1-byte chunks\tCtrl+1")); AppendMenu(optionsmenu, MF_ENABLED, ID_2_BYTE_CHUNKS, TEXT("2-byte chunks\tCtrl+2")); AppendMenu(optionsmenu, MF_ENABLED, ID_4_BYTE_CHUNKS, TEXT("4-byte chunks\tCtrl+4")); AppendMenu(optionsmenu, MF_ENABLED, ID_8_BYTE_CHUNKS, TEXT("8-byte chunks\tCtrl+8")); AppendMenu(optionsmenu, MF_DISABLED | MF_SEPARATOR, 0, TEXT("")); AppendMenu(optionsmenu, MF_ENABLED, ID_LOGICAL_ADDRESSES, TEXT("Logical Addresses\tCtrl+L")); AppendMenu(optionsmenu, MF_ENABLED, ID_PHYSICAL_ADDRESSES, TEXT("Physical Addresses\tCtrl+Y")); AppendMenu(optionsmenu, MF_DISABLED | MF_SEPARATOR, 0, TEXT("")); AppendMenu(optionsmenu, MF_ENABLED, ID_REVERSE_VIEW, TEXT("Reverse View\tCtrl+R")); AppendMenu(optionsmenu, MF_DISABLED | MF_SEPARATOR, 0, TEXT("")); AppendMenu(optionsmenu, MF_ENABLED, ID_INCREASE_MEM_WIDTH, TEXT("Increase bytes per line\tCtrl+P")); AppendMenu(optionsmenu, MF_ENABLED, ID_DECREASE_MEM_WIDTH, TEXT("Decrease bytes per line\tCtrl+O")); AppendMenu(GetMenu(window()), MF_ENABLED | MF_POPUP, (UINT_PTR)optionsmenu, TEXT("Options")); // set up the view to track the initial expression downcast<memoryview_info *>(m_views[0].get())->set_expression("0"); set_edit_defstr("0"); set_editwnd_text("0"); editwnd_select_all(); // create a combo box m_views[0]->set_source_for_visible_cpu(); m_combownd = m_views[0]->create_source_combobox(window(), (LONG_PTR)this); // set the caption update_caption(); // recompute the children once to get the maxwidth recompute_children(); // position the window and recompute children again SetWindowPos(window(), HWND_TOP, 100, 100, maxwidth(), 200, SWP_SHOWWINDOW); recompute_children(); // mark the edit box as the default focus and set it set_default_focus(); }
bool editwin_info::restore_field(HWND wnd) { if (wnd == m_editwnd) { set_editwnd_text(m_edit_defstr.c_str()); editwnd_select_all(); return true; } else { return false; } }
editwin_info::editwin_info(debugger_windows_interface &debugger, bool is_main_console, LPCSTR title, WNDPROC handler) : debugwin_info(debugger, is_main_console, title, handler), m_editwnd(nullptr), m_edit_defstr(), m_original_editproc(nullptr), m_history_count(0), m_last_history(0) { if (window() == nullptr) return; // create an edit box and override its key handling m_editwnd = CreateWindowEx(EDIT_BOX_STYLE_EX, TEXT("EDIT"), nullptr, EDIT_BOX_STYLE, 0, 0, 100, 100, window(), nullptr, GetModuleHandleUni(), nullptr); m_original_editproc = (WNDPROC)(FPTR)GetWindowLongPtr(m_editwnd, GWLP_WNDPROC); SetWindowLongPtr(m_editwnd, GWLP_USERDATA, (LONG_PTR)this); SetWindowLongPtr(m_editwnd, GWLP_WNDPROC, (LONG_PTR)&editwin_info::static_edit_proc); SendMessage(m_editwnd, WM_SETFONT, (WPARAM)metrics().debug_font(), (LPARAM)FALSE); SendMessage(m_editwnd, EM_LIMITTEXT, (WPARAM)MAX_EDIT_STRING, (LPARAM)0); set_editwnd_text(""); }
LRESULT editwin_info::edit_proc(UINT message, WPARAM wparam, LPARAM lparam) { TCHAR buffer[MAX_EDIT_STRING]; // handle a few messages switch (message) { // key down: handle navigation in the attached view case WM_SYSKEYDOWN: if (wparam != VK_F10) return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam); // (fall through) case WM_KEYDOWN: switch (wparam) { case VK_UP: if (m_last_history < (m_history_count - 1)) m_last_history++; else m_last_history = 0; SendMessage(m_editwnd, WM_SETTEXT, (WPARAM)0, (LPARAM)&m_history[m_last_history][0]); SendMessage(m_editwnd, EM_SETSEL, (WPARAM)MAX_EDIT_STRING, (LPARAM)MAX_EDIT_STRING); break; case VK_DOWN: if (m_last_history > 0) m_last_history--; else if (m_history_count > 0) m_last_history = m_history_count - 1; else m_last_history = 0; SendMessage(m_editwnd, WM_SETTEXT, (WPARAM)0, (LPARAM)&m_history[m_last_history][0]); SendMessage(m_editwnd, EM_SETSEL, (WPARAM)MAX_EDIT_STRING, (LPARAM)MAX_EDIT_STRING); break; case VK_PRIOR: if (m_views[0] != nullptr) m_views[0]->send_pageup(); break; case VK_NEXT: if (m_views[0] != nullptr) m_views[0]->send_pagedown(); break; case VK_TAB: if (GetAsyncKeyState(VK_SHIFT) & 0x8000) prev_view(nullptr); else next_view(nullptr); set_ignore_char_lparam(lparam); break; default: if (handle_key(wparam, lparam)) set_ignore_char_lparam(lparam); else return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam); break; } break; // char: handle the return key case WM_CHAR: // ignore chars associated with keys we've handled if (check_ignore_char_lparam(lparam)) { if (waiting_for_debugger() || !seq_pressed()) { switch (wparam) { case 13: { // fetch the text SendMessage(m_editwnd, WM_GETTEXT, (WPARAM)ARRAY_LENGTH(buffer), (LPARAM)buffer); // add to the history if it's not a repeat of the last one if (buffer[0] != 0 && _tcscmp(buffer, &m_history[0][0])) { memmove(&m_history[1][0], &m_history[0][0], (HISTORY_LENGTH - 1) * MAX_EDIT_STRING * sizeof(TCHAR)); _tcscpy(&m_history[0][0], buffer); if (m_history_count < HISTORY_LENGTH) m_history_count++; } m_last_history = m_history_count - 1; // process { auto utf8_buffer = osd::text::from_tstring(buffer); process_string(utf8_buffer.c_str()); } break; } case 27: { // fetch the text SendMessage(m_editwnd, WM_GETTEXT, (WPARAM)sizeof(buffer), (LPARAM)buffer); // if it's not empty, clear the text if (_tcslen(buffer) > 0) { set_ignore_char_lparam(lparam); set_editwnd_text(m_edit_defstr.c_str()); editwnd_select_all(); } break; } default: return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam); } } } break; // everything else: defaults default: return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam); } return 0; }
LRESULT editwin_info::edit_proc(UINT message, WPARAM wparam, LPARAM lparam) { // handle a few messages switch (message) { // key down: handle navigation in the attached view case WM_SYSKEYDOWN: if (wparam != VK_F10) return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam); // (fall through) case WM_KEYDOWN: switch (wparam) { case VK_UP: if (!m_history.empty()) { m_last_history++; if (m_last_history >= m_history.size()) m_last_history = 0; auto const &entry(m_history[m_last_history]); SendMessage(m_editwnd, WM_SETTEXT, WPARAM(0), LPARAM(entry.c_str())); SendMessage(m_editwnd, EM_SETSEL, WPARAM(entry.length()), LPARAM(entry.length())); } break; case VK_DOWN: if (!m_history.empty()) { if (m_last_history > 0) m_last_history--; else m_last_history = m_history.size() - 1; auto const &entry(m_history[m_last_history]); SendMessage(m_editwnd, WM_SETTEXT, WPARAM(0), LPARAM(entry.c_str())); SendMessage(m_editwnd, EM_SETSEL, WPARAM(entry.length()), LPARAM(entry.length())); } break; case VK_PRIOR: if (m_views[0] != nullptr) m_views[0]->send_pageup(); break; case VK_NEXT: if (m_views[0] != nullptr) m_views[0]->send_pagedown(); break; case VK_TAB: if (GetAsyncKeyState(VK_SHIFT) & 0x8000) prev_view(nullptr); else next_view(nullptr); set_ignore_char_lparam(lparam); break; default: if (handle_key(wparam, lparam)) set_ignore_char_lparam(lparam); else return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam); break; } break; // char: handle the return key case WM_CHAR: // ignore chars associated with keys we've handled if (check_ignore_char_lparam(lparam)) { if (waiting_for_debugger() || !seq_pressed()) { TCHAR buffer[MAX_EDIT_STRING]; switch (wparam) { case 13: // carriage return { // fetch the text SendMessage(m_editwnd, WM_GETTEXT, WPARAM(ARRAY_LENGTH(buffer)), LPARAM(buffer)); // add to the history if it's not a repeat of the last one if (buffer[0] && (m_history.empty() || _tcscmp(buffer, m_history[0].c_str()))) { while (m_history.size() >= HISTORY_LENGTH) m_history.pop_back(); m_history.emplace_front(buffer); } m_last_history = m_history.size() - 1; // process { auto utf8_buffer = osd::text::from_tstring(buffer); process_string(utf8_buffer.c_str()); } } break; case 27: // escape { // fetch the text SendMessage(m_editwnd, WM_GETTEXT, WPARAM(sizeof(buffer)), LPARAM(buffer)); // if it's not empty, clear the text if (_tcslen(buffer) > 0) { set_ignore_char_lparam(lparam); set_editwnd_text(m_edit_defstr.c_str()); editwnd_select_all(); } } break; default: return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam); } } } break; // everything else: defaults default: return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam); } return 0; }