Skip to content

Commit 1d2e37d

Browse files
committed
add 'Go to line' feature
1 parent 5fd3a17 commit 1d2e37d

29 files changed

+343
-57
lines changed

CHANGELOG_es.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,3 +369,4 @@
369369
- Updated mcpp.exe to make UTF-16/UTF-32 buffer length unlimitted.
370370
- Renamed HISTORY*.txt as ChangeLog*.txt.
371371
- Renamed README-*.txt as README_*.txt.
372+
- Added the "Go to line" feature.

CHANGELOG_id.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,3 +369,4 @@
369369
- Updated mcpp.exe to make UTF-16/UTF-32 buffer length unlimited.
370370
- Renamed HISTORY*.txt as ChangeLog*.txt.
371371
- Renamed README-*.txt as README_*.txt.
372+
- Added the "Go to line" feature.

CHANGELOG_ja.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,3 +713,4 @@
713713
- UTF-16/UTF-32バッファ長を無制限にするために mcpp.exe を更新。
714714
- HISTORY*.txt を ChangeLog*.txt に改名。
715715
- README-*.txt を README_*.txt に改名。
716+
- 「指定行へ移動」機能を追加。

CHANGELOG_ko.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,4 @@
370370
- Updated mcpp.exe to make UTF-16/UTF-32 buffer length unlimited.
371371
- Renamed HISTORY*.txt as ChangeLog*.txt.
372372
- Renamed README-*.txt as README_*.txt.
373+
- Added the "Go to line" feature.

CHANGELOG_pt.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,3 +369,4 @@
369369
- Updated mcpp.exe to make UTF-16/UTF-32 buffer length unlimited.
370370
- Renamed HISTORY*.txt as ChangeLog*.txt.
371371
- Renamed README-*.txt as README_*.txt.
372+
- Added the "Go to line" feature.

ChangeLog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,3 +369,4 @@
369369
- Updated mcpp.exe to make UTF-16/UTF-32 buffer length unlimited.
370370
- Renamed HISTORY*.txt as ChangeLog*.txt.
371371
- Renamed README-*.txt as README_*.txt.
372+
- Added the "Go to line" feature.

ChangeLog_it.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,3 +369,4 @@
369369
- Aggiornato mcpp.exe per rendere illimitata la lunghezza del buffer UTF-16/UTF-32.
370370
- Rinominati HISTORY*.txt come ChangeLog*.txt.
371371
- Rinominati README-*.txt come README_*.txt.
372+
- Added the "Go to line" feature.

src/MGoToLineDlg.hpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// MGoToLineDlg.hpp --- "Go To Line" Dialog
2+
//////////////////////////////////////////////////////////////////////////////
3+
// RisohEditor --- Another free Win32 resource editor
4+
// Copyright (C) 2017-2018 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
5+
// License: GPL-3 or later
6+
7+
#pragma once
8+
9+
#include "resource.h"
10+
#include "MWindowBase.hpp"
11+
#include "Common.hpp"
12+
13+
//////////////////////////////////////////////////////////////////////////////
14+
15+
class MGoToLineDlg : public MDialogBase
16+
{
17+
public:
18+
INT m_line;
19+
20+
MGoToLineDlg()
21+
: MDialogBase(IDD_GOTOLINE)
22+
, m_line(0)
23+
{
24+
}
25+
26+
~MGoToLineDlg()
27+
{
28+
}
29+
30+
BOOL OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
31+
{
32+
return TRUE;
33+
}
34+
35+
void OnOK(HWND hwnd)
36+
{
37+
m_line = GetDlgItemInt(hwnd, edt1, NULL, FALSE);
38+
EndDialog(IDOK);
39+
}
40+
41+
void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
42+
{
43+
switch (id)
44+
{
45+
case IDOK:
46+
OnOK(hwnd);
47+
break;
48+
case IDCANCEL:
49+
EndDialog(IDCANCEL);
50+
break;
51+
}
52+
}
53+
54+
virtual INT_PTR CALLBACK
55+
DialogProcDx(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
56+
{
57+
switch (uMsg)
58+
{
59+
HANDLE_MSG(hwnd, WM_INITDIALOG, OnInitDialog);
60+
HANDLE_MSG(hwnd, WM_COMMAND, OnCommand);
61+
}
62+
return 0;
63+
}
64+
};

src/MMainWnd.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class MMainWnd : public MWindowBase
8181
MIdOrString m_type;
8282
MIdOrString m_name;
8383
WORD m_lang;
84+
BOOL m_bShowBinEdit;
8485

8586
// classes
8687
MRadWindow m_rad_window; // the RADical window
@@ -132,6 +133,7 @@ class MMainWnd : public MWindowBase
132133
m_bUpxCompressed = FALSE;
133134

134135
m_lang = BAD_LANG;
136+
m_bShowBinEdit = FALSE;
135137
m_pAutoComplete = NULL;
136138
}
137139

@@ -229,7 +231,8 @@ class MMainWnd : public MWindowBase
229231
SHOW_MOVIE, SHOW_CODEONLY, SHOW_CODEANDBMP
230232
};
231233
SHOW_MODE m_nShowMode;
232-
void SetShowMode(SHOW_MODE mode);
234+
void SetShowMode(SHOW_MODE mode, BOOL bShowBinary);
235+
void SetShowMode(SHOW_MODE mode) { SetShowMode(mode, m_bShowBinEdit); }
233236
void ShowStatusBar(BOOL bShow = TRUE);
234237
BOOL ShowLangArrow(BOOL bShow, HTREEITEM hItem = NULL);
235238
void UpdateLangArrow();
@@ -502,6 +505,7 @@ class MMainWnd : public MWindowBase
502505
std::wstring GetRisohEditorVersion() const;
503506
std::wstring ParseVersionFile(LPCWSTR pszFile, std::wstring& url) const;
504507
void OnInternalTest(HWND hwnd);
508+
void OnGoToLine(HWND hwnd);
505509
};
506510

507511
extern MMainWnd *s_pMainWnd;

src/RisohEditor.cpp

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define LINENUMEDIT_IMPL
1010
#include "LineNumEdit.hpp"
1111
#include "MChooseLangDlg.hpp"
12+
#include "MGoToLineDlg.hpp"
1213
#include "ToolbarRes.hpp"
1314
#include "Utils.h"
1415
#include <thread>
@@ -2192,26 +2193,17 @@ void MMainWnd::OnPlay(HWND hwnd)
21922193

21932194
void MMainWnd::OnSelChange(HWND hwnd, INT iSelected)
21942195
{
2195-
if (iSelected != m_tab.GetCurSel())
2196-
{
2197-
// update tab control selection
2198-
m_tab.SetCurSel(iSelected);
2199-
}
2200-
2201-
// update g_settings.bShowBinEdit
2196+
// update show
22022197
switch (iSelected)
22032198
{
22042199
case 0:
2205-
g_settings.bShowBinEdit = FALSE;
2200+
SetShowMode(m_nShowMode, FALSE);
22062201
break;
22072202
case 1:
2208-
g_settings.bShowBinEdit = TRUE;
2203+
SetShowMode(m_nShowMode, TRUE);
22092204
break;
22102205
}
22112206

2212-
// update show
2213-
SetShowMode(m_nShowMode);
2214-
22152207
// relayout
22162208
PostMessage(hwnd, WM_SIZE, 0, 0);
22172209
}
@@ -2803,11 +2795,14 @@ void MMainWnd::OnDebugTreeNode(HWND hwnd)
28032795
MsgBoxDx(sz, MB_ICONINFORMATION);
28042796
}
28052797

2806-
void MMainWnd::SetShowMode(SHOW_MODE mode)
2798+
void MMainWnd::SetShowMode(SHOW_MODE mode, BOOL bShowBinary)
28072799
{
2800+
m_bShowBinEdit = bShowBinary;
28082801
m_nShowMode = mode;
2809-
if (g_settings.bShowBinEdit)
2802+
if (m_bShowBinEdit)
28102803
{
2804+
if (m_tab.GetCurSel() != 1)
2805+
m_tab.SetCurSel(1);
28112806
ShowWindow(m_hCodeEditor, SW_HIDE);
28122807
ShowWindow(m_hBmpView, SW_HIDE);
28132808
ShowWindow(m_hHexViewer, SW_SHOWNOACTIVATE);
@@ -2816,6 +2811,8 @@ void MMainWnd::SetShowMode(SHOW_MODE mode)
28162811
}
28172812
else
28182813
{
2814+
if (m_tab.GetCurSel() != 0)
2815+
m_tab.SetCurSel(0);
28192816
switch (mode)
28202817
{
28212818
case SHOW_MOVIE:
@@ -3024,7 +3021,7 @@ void MMainWnd::OnInitMenu(HWND hwnd, HMENU hMenu)
30243021
else
30253022
CheckMenuItem(hMenu, ID_STATUSBAR, MF_UNCHECKED);
30263023

3027-
if (g_settings.bShowBinEdit)
3024+
if (m_bShowBinEdit)
30283025
CheckMenuItem(hMenu, ID_BINARYPANE, MF_CHECKED);
30293026
else
30303027
CheckMenuItem(hMenu, ID_BINARYPANE, MF_UNCHECKED);
@@ -3579,7 +3576,7 @@ void MMainWnd::SelectTV(EntryBase *entry, BOOL bDoubleClick, STV stv)
35793576
bEditable = FALSE;
35803577

35813578
// update show mode
3582-
SetShowMode(SHOW_CODEONLY);
3579+
SetShowMode(SHOW_CODEONLY, m_bShowBinEdit);
35833580
}
35843581

35853582
if (stv == STV_DONTRESET || stv == STV_RESETTEXT)
@@ -3621,7 +3618,7 @@ void MMainWnd::SelectTV(EntryBase *entry, BOOL bDoubleClick, STV stv)
36213618
}
36223619

36233620
// update show
3624-
SetShowMode(m_nShowMode);
3621+
SetShowMode(m_nShowMode, m_bShowBinEdit);
36253622

36263623
// recalculate the splitter
36273624
PostMessageDx(WM_SIZE);
@@ -8933,6 +8930,23 @@ void MMainWnd::OnRefreshAll(HWND hwnd)
89338930
PostUpdateLangArrow(hwnd);
89348931
}
89358932

8933+
// ID_GOTOLINE
8934+
void MMainWnd::OnGoToLine(HWND hwnd) {
8935+
MGoToLineDlg dialog;
8936+
if (dialog.DialogBoxDx(hwnd) == IDOK) {
8937+
SetShowMode(SHOW_CODEONLY, FALSE);
8938+
INT line = dialog.m_line;
8939+
INT ich = Edit_LineIndex(m_hCodeEditor, (line <= 0) ? 0 : (line - 1));
8940+
INT cch = Edit_GetTextLength(m_hCodeEditor);
8941+
if (ich == -1)
8942+
Edit_SetSel(m_hCodeEditor, cch, cch);
8943+
else
8944+
Edit_SetSel(m_hCodeEditor, ich, ich);
8945+
Edit_ScrollCaret(m_hCodeEditor);
8946+
SetFocus(m_hCodeEditor);
8947+
}
8948+
}
8949+
89368950
// WM_COMMAND
89378951
void MMainWnd::OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
89388952
{
@@ -9098,10 +9112,10 @@ void MMainWnd::OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
90989112
break;
90999113
case ID_BINARYPANE:
91009114
// toggle the flag
9101-
g_settings.bShowBinEdit = !g_settings.bShowBinEdit;
9115+
m_bShowBinEdit = !m_bShowBinEdit;
91029116
// show/hide the binary
9103-
m_tab.SetCurSel(!!g_settings.bShowBinEdit);
9104-
OnSelChange(hwnd, !!g_settings.bShowBinEdit);
9117+
m_tab.SetCurSel(!!m_bShowBinEdit);
9118+
OnSelChange(hwnd, !!m_bShowBinEdit);
91059119
break;
91069120
case ID_ALWAYSCONTROL:
91079121
{
@@ -9459,6 +9473,9 @@ void MMainWnd::OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
94599473
case ID_INTERNALTEST:
94609474
OnInternalTest(hwnd);
94619475
break;
9476+
case ID_GOTOLINE:
9477+
OnGoToLine(hwnd);
9478+
break;
94629479
default:
94639480
bUpdateStatus = FALSE;
94649481
break;

0 commit comments

Comments
 (0)