Skip to content

Commit

Permalink
Add option to allow only select subline from wrapped line.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Dec 2, 2018
1 parent a51d360 commit 84dd8de
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
12 changes: 12 additions & 0 deletions src/Dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,8 @@ extern int iWordWrapMode;
extern int iWordWrapIndent;
extern int iWordWrapSymbols;
extern BOOL bShowWordWrapSymbols;
extern BOOL bWordWrapSelectSubLine;
extern BOOL bHighlightCurrentSubLine;

static INT_PTR CALLBACK WordWrapSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) {
UNREFERENCED_PARAMETER(lParam);
Expand Down Expand Up @@ -1422,6 +1424,13 @@ static INT_PTR CALLBACK WordWrapSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wPa
SendDlgItemMessage(hwnd, IDC_WRAP_SYMBOL_AFTER, CB_SETCURSEL, bShowWordWrapSymbols ? (iWordWrapSymbols / 10) : 0, 0);
SendDlgItemMessage(hwnd, IDC_WRAP_MODE, CB_SETCURSEL, iWordWrapMode, 0);

if (bWordWrapSelectSubLine) {
CheckDlgButton(hwnd, IDC_WRAP_SELECT_SUBLINE, BST_CHECKED);
}
if (bHighlightCurrentSubLine) {
CheckDlgButton(hwnd, IDC_WRAP_HIGHLIGHT_SUBLINE, BST_CHECKED);
}

CenterDlgInParent(hwnd);
}
return TRUE;
Expand All @@ -1445,6 +1454,9 @@ static INT_PTR CALLBACK WordWrapSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wPa
fWordWrap = TRUE;
iWordWrapMode = iSel;
}

bWordWrapSelectSubLine = IsButtonChecked(hwnd, IDC_WRAP_SELECT_SUBLINE);
bHighlightCurrentSubLine = IsButtonChecked(hwnd, IDC_WRAP_HIGHLIGHT_SUBLINE);
EndDialog(hwnd, IDOK);
}
break;
Expand Down
17 changes: 10 additions & 7 deletions src/Notepad2.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ int iWordWrapMode;
int iWordWrapIndent;
int iWordWrapSymbols;
BOOL bShowWordWrapSymbols;
BOOL bWordWrapSelectSubLine;
static BOOL bShowUnicodeControlCharacter;
static BOOL bMatchBraces;
static BOOL bShowIndentGuides;
BOOL bHighlightCurrentLineSubLine;
BOOL bHighlightCurrentSubLine;
INT iHighlightCurrentLine;
BOOL bTabsAsSpaces;
BOOL bTabsAsSpacesG;
Expand Down Expand Up @@ -1608,7 +1609,7 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam, LPARAM lParam) {
SciCall_SetMarginMask(MARGIN_FOLD_INDEX, SC_MASK_FOLDERS);
SciCall_SetMarginSensitive(MARGIN_FOLD_INDEX, TRUE);
// only select sub line of wrapped line
//SendMessage(hwndEdit, SCI_SETMARGINOPTIONS, SC_MARGINOPTION_SUBLINESELECT, 0);
SendMessage(hwndEdit, SCI_SETMARGINOPTIONS, (bWordWrapSelectSubLine ? SC_MARGINOPTION_SUBLINESELECT : SC_MARGINOPTION_NONE), 0);
// Code folding, Box tree
SciCall_MarkerDefine(SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS);
SciCall_MarkerDefine(SC_MARKNUM_FOLDER, SC_MARK_BOXPLUS);
Expand Down Expand Up @@ -2385,7 +2386,7 @@ void MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) {

i = IDM_VIEW_HIGHLIGHTCURRENTLINE_NONE + iHighlightCurrentLine;
CheckMenuRadioItem(hmenu, IDM_VIEW_HIGHLIGHTCURRENTLINE_NONE, IDM_VIEW_HIGHLIGHTCURRENTLINE_FRAME, i, MF_BYCOMMAND);
CheckCmd(hmenu, IDM_VIEW_HIGHLIGHTCURRENTLINE_SUBLINE, bHighlightCurrentLineSubLine);
CheckCmd(hmenu, IDM_VIEW_HIGHLIGHTCURRENTLINE_SUBLINE, bHighlightCurrentSubLine);

CheckCmd(hmenu, IDM_VIEW_REUSEWINDOW, bReuseWindow);
CheckCmd(hmenu, IDM_VIEW_SINGLEFILEINSTANCE, bSingleFileInstance);
Expand Down Expand Up @@ -3765,6 +3766,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) {
case IDM_VIEW_WORDWRAPSETTINGS:
if (WordWrapSettingsDlg(hwnd, &iWordWrapIndent)) {
SendMessage(hwndEdit, SCI_SETWRAPMODE, (fWordWrap? iWordWrapMode : SC_WRAP_NONE), 0);
SendMessage(hwndEdit, SCI_SETMARGINOPTIONS, (bWordWrapSelectSubLine ? SC_MARGINOPTION_SUBLINESELECT : SC_MARGINOPTION_NONE), 0);
fWordWrapG = fWordWrap;
UpdateToolbar();
SetWrapIndentMode();
Expand Down Expand Up @@ -3980,8 +3982,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) {
break;

case IDM_VIEW_HIGHLIGHTCURRENTLINE_SUBLINE:
bHighlightCurrentLineSubLine = !bHighlightCurrentLineSubLine;
//SendMessage(hwndEdit, SCI_SETCARETLINEVISIBLEALWAYS, bHighlightCurrentLineSubLine, 0);
bHighlightCurrentSubLine = !bHighlightCurrentSubLine;
break;

case IDM_VIEW_ZOOMIN:
Expand Down Expand Up @@ -5244,12 +5245,13 @@ void LoadSettings(void) {
iWordWrapSymbols = clamp_i(iValue % 10, EditWrapSymbolBeforeNone, EditWrapSymbolBeforeMaxValue) + (iValue / 10) * 10;

bShowWordWrapSymbols = IniSectionGetBool(pIniSection, L"ShowWordWrapSymbols", 0);
bWordWrapSelectSubLine = IniSectionGetBool(pIniSection, L"WordWrapSelectSubLine", 0);
bShowUnicodeControlCharacter = IniSectionGetBool(pIniSection, L"ShowUnicodeControlCharacter", 0);

bMatchBraces = IniSectionGetBool(pIniSection, L"MatchBraces", 1);
iValue = IniSectionGetInt(pIniSection, L"HighlightCurrentLine", 12);
iValue = (iSettingsVersion < NP2SettingsVersion_V1) ? 12 : iValue;
bHighlightCurrentLineSubLine = iValue > 10;
bHighlightCurrentSubLine = iValue > 10;
iHighlightCurrentLine = clamp_i(iValue % 10, 0, 2);
bShowIndentGuides = IniSectionGetBool(pIniSection, L"ShowIndentGuides", 0);

Expand Down Expand Up @@ -5581,9 +5583,10 @@ void SaveSettings(BOOL bSaveSettingsNow) {
IniSectionSetIntEx(pIniSection, L"WordWrapIndent", iWordWrapIndent, EditWrapIndentNone);
IniSectionSetIntEx(pIniSection, L"WordWrapSymbols", iWordWrapSymbols, EditWrapSymbolDefaultValue);
IniSectionSetBoolEx(pIniSection, L"ShowWordWrapSymbols", bShowWordWrapSymbols, 0);
IniSectionSetBoolEx(pIniSection, L"WordWrapSelectSubLine", bWordWrapSelectSubLine, 0);
IniSectionSetBoolEx(pIniSection, L"ShowUnicodeControlCharacter", bShowUnicodeControlCharacter, 0);
IniSectionSetBoolEx(pIniSection, L"MatchBraces", bMatchBraces, 1);
IniSectionSetIntEx(pIniSection, L"HighlightCurrentLine", iHighlightCurrentLine + (bHighlightCurrentLineSubLine ? 10 : 0), 12);
IniSectionSetIntEx(pIniSection, L"HighlightCurrentLine", iHighlightCurrentLine + (bHighlightCurrentSubLine ? 10 : 0), 12);
IniSectionSetBoolEx(pIniSection, L"ShowIndentGuides", bShowIndentGuides, 0);

IniSectionSetBoolEx(pIniSection, L"AutoIndent", autoCompletionConfig.bIndentText, 1);
Expand Down
9 changes: 6 additions & 3 deletions src/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,127,24,50,14
END

IDD_WORDWRAP DIALOGEX 0, 0, 250, 100
IDD_WORDWRAP DIALOGEX 0, 0, 250, 139
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Word Wrap Settings"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
Expand All @@ -1173,12 +1173,15 @@ BEGIN
COMBOBOX IDC_WRAP_SYMBOL_BEFORE,7,24,236,196,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_WRAP_SYMBOL_AFTER,7,41,236,196,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_WRAP_MODE,7,58,236,196,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,137,79,50,14
PUSHBUTTON "Cancel",IDCANCEL,193,79,50,14
DEFPUSHBUTTON "OK",IDOK,137,118,50,14
PUSHBUTTON "Cancel",IDCANCEL,193,118,50,14
LTEXT "No wrap indent|Wrap indent by 1 character|Wrap indent by 2 characters|Wrap indent by 1 level|Wrap indent by 2 levels|Wrap indent same as first subline|Wrap indent 1 level more than first subline|Wrap indent 2 levels more than first subline",IDC_WRAP_INDENT_OPTIONS,0,0,615,8,NOT WS_VISIBLE
LTEXT "No visual indicators before wrap|Show visual indicators before wrap (near text)|Show visual indicators before wrap (near borders)",IDC_WRAP_SYMBOL_BEFORE_OPTIONS,0,0,418,8,NOT WS_VISIBLE
LTEXT "No visual indicators after wrap|Show visual indicators after wrap (near text)|Show visual indicators after wrap (near borders)|Show visual indicators after wrap (in line number margin)",IDC_WRAP_SYMBOL_AFTER_OPTIONS,0,0,402,8,NOT WS_VISIBLE
LTEXT "No wrap|Wrap text between words|Wrap text between any characters|Wrap text on whitespace",IDC_WRAP_MODE_OPTIONS,0,0,187,8,NOT WS_VISIBLE
GROUPBOX "For wrapped line",IDC_STATIC,7,74,235,38
CONTROL "Only select subline when selecting line from left margin",IDC_WRAP_SELECT_SUBLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,84,220,10
CONTROL "Only highligh subline when highlighting current line",IDC_WRAP_HIGHLIGHT_SUBLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,96,220,10
END

IDD_PAGESETUP DIALOGEX 5, 5, 356, 260
Expand Down
2 changes: 2 additions & 0 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@
#define IDC_WRAP_SYMBOL_BEFORE 101
#define IDC_WRAP_SYMBOL_AFTER 102
#define IDC_WRAP_MODE 103
#define IDC_WRAP_SELECT_SUBLINE 104
#define IDC_WRAP_HIGHLIGHT_SUBLINE 105
#define IDC_WRAP_INDENT_OPTIONS 200
#define IDC_WRAP_SYMBOL_BEFORE_OPTIONS 201
#define IDC_WRAP_SYMBOL_AFTER_OPTIONS 202
Expand Down

0 comments on commit 84dd8de

Please sign in to comment.