Skip to content

Commit

Permalink
Toggle Ruler GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
LiMinggang committed May 18, 2024
1 parent 3059dd5 commit 37c7ab4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ Packing for FreeBSD
.Fix ARM64 build
.Fix bug in FindTextAll macro recording, issue #331
.Use per monitor DPI awareness V2
.Add ruler by sln-1550(https://github.com/sln-1550)
.Update Astyle to 3.4.9
.Update hunspell to 1.7.2
.Update wxWidgets to 3.2.4
.Update wxWidgets to 3.2.5

Mod v0.4.20
1.Fix: JSON formatter convert Unicode chars to UTF8 chars #309
Expand Down
42 changes: 42 additions & 0 deletions src/MadEditFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,7 @@ MadEditFrame::wxCmdEvtHandlerMap_t MadEditFrame::m_menu_evt_map[] =
{ menuDisplayLineNumber, &MadEditFrame::OnViewDisplayLineNumber },
{ menuDisplayBookmark, &MadEditFrame::OnViewDisplayBookmark },
{ menuDisplayColHint, &MadEditFrame::OnViewDisplayColHint },
{ menuShowRuler, &MadEditFrame::OnViewShowRuler },
{ menuShowEndOfLine, &MadEditFrame::OnViewShowEndOfLine },
{ menuShowTabChar, &MadEditFrame::OnViewShowTabChar },
{ menuShowSpaceChar, &MadEditFrame::OnViewShowSpaceChar },
Expand Down Expand Up @@ -2140,6 +2141,7 @@ MadEditFrame::wxUIUpdateEvtHandlerMap_t MadEditFrame::m_menu_ui_updater_map[] =
{ menuDisplayLineNumber, &MadEditFrame::OnUpdateUI_MenuViewDisplayLineNumber },
{ menuDisplayBookmark, &MadEditFrame::OnUpdateUI_MenuViewDisplayBookmark },
{ menuDisplayColHint, &MadEditFrame::OnUpdateUI_MenuViewDisplayColHint },
{ menuShowRuler, &MadEditFrame::OnUpdateUI_MenuViewShowRuler },
{ menuShowEndOfLine, &MadEditFrame::OnUpdateUI_MenuViewShowEndOfLine },
{ menuShowTabChar, &MadEditFrame::OnUpdateUI_MenuViewShowTabChar },
{ menuShowSpaceChar, &MadEditFrame::OnUpdateUI_MenuViewShowSpaceChar },
Expand Down Expand Up @@ -2537,6 +2539,7 @@ CommandData CommandTable[] =
{ 0, 1, menuDisplayLineNumber, wxT("menuDisplayLineNumber"), _("&Display Line Number"), wxT("Ctrl-Alt-D"), wxITEM_CHECK, -1, 0, _("Display the Line Numbers"), 0, 0, 0, false},
{ 0, 1, menuDisplayBookmark, wxT("menuDisplayBookmark"), _("Display &Bookmark"), wxT("Ctrl-Alt-B"), wxITEM_CHECK, -1, 0, _("Display the Bookmark sign"), 0, 0, 0, false},
{ 0, 1, menuDisplayColHint, wxT("menuDisplayColHint"), _("Display 80th Cols &Hint"), wxT(""), wxITEM_CHECK, -1, 0, _("Display the 80th columns hint"), 0, 0, 0, false},
{ 0, 1, menuShowRuler, wxT("menuShowRuler"), _("Show &Ruler"), wxT(""), wxITEM_CHECK, -1, 0, _("Display the Ruler"), 0, 0, 0, false},
{ 0, 1, menuShowEndOfLine, wxT("menuShowEndOfLine"), _("Show End Of Line"), wxT("Ctrl-Alt-L"), wxITEM_CHECK, -1, 0, _("Show the sign of EndOfLine"), 0, 0, 0, false},
{ 0, 1, menuShowTabChar, wxT("menuShowTabChar"), _("Show Tab Char"), wxT("Ctrl-Alt-T"), wxITEM_CHECK, -1, 0, _("Show the sign of Tab char"), 0, 0, 0, false},
{ 0, 1, menuShowSpaceChar, wxT("menuShowSpaceChar"), _("Show Space Char"), wxT("Ctrl-Alt-S"), wxITEM_CHECK, -1, 0, _("Show the sign of Space char"), 0, 0, 0, false},
Expand Down Expand Up @@ -5525,6 +5528,11 @@ void MadEditFrame::OnUpdateUI_MenuViewDisplayColHint(wxUpdateUIEvent& event)
event.Enable(g_ActiveMadEdit && !g_ActiveMadEdit->IsHexMode() && g_ActiveMadEdit->GetFixedWidthMode());
event.Check(g_ActiveMadEdit && g_ActiveMadEdit->GetDisplayColHint());
}
void MadEditFrame::OnUpdateUI_MenuViewShowRuler(wxUpdateUIEvent& event)
{
event.Enable(g_ActiveMadEdit && !g_ActiveMadEdit->IsHexMode());
event.Check(g_ActiveMadEdit && g_ActiveMadEdit->GetRulerStatus());
}
void MadEditFrame::OnUpdateUI_MenuViewShowEndOfLine(wxUpdateUIEvent& event)
{
event.Enable(g_ActiveMadEdit && !g_ActiveMadEdit->IsHexMode());
Expand Down Expand Up @@ -7900,9 +7908,14 @@ void MadEditFrame::OnViewFixedWidthMode(wxCommandEvent& event)
{
if (g_ActiveMadEdit)
{
if (g_ActiveMadEdit->GetRulerStatus()
&& wxNO == MadMessageBox(wxString::Format(_("Ruler may not be accurate in non-fixed width mode. Continue?")), _("Warning"), wxICON_WARNING | wxYES_NO))
return;
g_ActiveMadEdit->SetFixedWidthMode(event.IsChecked());
if (!event.IsChecked())
{
g_ActiveMadEdit->SetDisplayColHint(false);
}

if (IsMacroRecording())
{
Expand Down Expand Up @@ -8123,6 +8136,35 @@ void MadEditFrame::OnViewDisplayColHint(wxCommandEvent& event)
}
}

void MadEditFrame::OnViewShowRuler(wxCommandEvent& event)
{
if (g_ActiveMadEdit)
{
if (event.IsChecked()) {
if (!g_ActiveMadEdit->GetFixedWidthMode() &&
wxNO == MadMessageBox(wxString::Format(_("Ruler may not be accurate in non-fixed width mode. Continue?")), _("Warning"), wxICON_WARNING | wxYES_NO))
return;
g_ActiveMadEdit->ShowRuler();
}
else
{
g_ActiveMadEdit->HideRuler();
}

if (IsMacroRecording())
{
if (event.IsChecked())
{
RecordAsMadMacro(g_ActiveMadEdit, wxString(wxT("ShowRuler()")));
}
else
{
RecordAsMadMacro(g_ActiveMadEdit, wxString(wxT("HideRuler()")));
}
}
}
}

void MadEditFrame::OnViewShowEndOfLine(wxCommandEvent& event)
{
if (g_ActiveMadEdit)
Expand Down
3 changes: 3 additions & 0 deletions src/MadEditFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ enum // menu id
menuDisplayLineNumber,
menuDisplayBookmark,
menuDisplayColHint,
menuShowRuler,
menuShowEndOfLine,
menuShowTabChar,
menuShowSpaceChar,
Expand Down Expand Up @@ -499,6 +500,7 @@ class MadEditFrame : public wxFrame
void OnUpdateUI_MenuViewDisplayLineNumber(wxUpdateUIEvent& event);
void OnUpdateUI_MenuViewDisplayBookmark(wxUpdateUIEvent& event);
void OnUpdateUI_MenuViewDisplayColHint(wxUpdateUIEvent& event);
void OnUpdateUI_MenuViewShowRuler(wxUpdateUIEvent& event);
void OnUpdateUI_MenuViewShowEndOfLine(wxUpdateUIEvent& event);
void OnUpdateUI_MenuViewShowTabChar(wxUpdateUIEvent& event);
void OnUpdateUI_MenuViewShowSpaceChar(wxUpdateUIEvent& event);
Expand Down Expand Up @@ -665,6 +667,7 @@ class MadEditFrame : public wxFrame
void OnViewDisplayLineNumber(wxCommandEvent& WXUNUSED(event));
void OnViewDisplayBookmark(wxCommandEvent& WXUNUSED(event));
void OnViewDisplayColHint(wxCommandEvent& WXUNUSED(event));
void OnViewShowRuler(wxCommandEvent& WXUNUSED(event));
void OnViewShowEndOfLine(wxCommandEvent& WXUNUSED(event));
void OnViewShowTabChar(wxCommandEvent& WXUNUSED(event));
void OnViewShowSpaceChar(wxCommandEvent& WXUNUSED(event));
Expand Down

0 comments on commit 37c7ab4

Please sign in to comment.