Add no editor border edge option

Close #707
Add no editor border edge option in preferences dialog.
Add new API NPPM_SETEDITORBORDEREDGE
This commit is contained in:
Don Ho 2015-12-04 19:01:28 +01:00
parent 32b45e16d8
commit 6c7ca02fea
11 changed files with 57 additions and 8 deletions

View File

@ -34,14 +34,16 @@
enum LangType {L_TEXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\
L_HTML, L_XML, L_MAKEFILE, L_PASCAL, L_BATCH, L_INI, L_ASCII, L_USER,\
L_ASP, L_SQL, L_VB, L_JS, L_CSS, L_PERL, L_PYTHON, L_LUA,\
L_ASP, L_SQL, L_VB, L_JS, L_CSS, L_PERL, L_PYTHON, L_LUA, \
L_TEX, L_FORTRAN, L_BASH, L_FLASH, L_NSIS, L_TCL, L_LISP, L_SCHEME,\
L_ASM, L_DIFF, L_PROPS, L_PS, L_RUBY, L_SMALLTALK, L_VHDL, L_KIX, L_AU3,\
L_CAML, L_ADA, L_VERILOG, L_MATLAB, L_HASKELL, L_INNO, L_SEARCHRESULT,\
L_CMAKE, L_YAML, L_COBOL, L_GUI4CLI, L_D, L_POWERSHELL, L_R, L_JSP,\
L_COFFEESCRIPT, L_JSON, L_JAVASCRIPT,\
// Don't use L_JS, use L_JAVASCRIPT instead
// The end of enumated language type, so it should be always at the end
L_EXTERNAL};
enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64, WV_VISTA, WV_WIN7, WV_WIN8, WV_WIN81};
@ -408,6 +410,8 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
#define NPPM_SETSMOOTHFONT (NPPMSG + 92)
// VOID NPPM_SETSMOOTHFONT(0, BOOL setSmoothFontOrNot)
#define NPPM_SETEDITORBORDEREDGE (NPPMSG + 93)
// VOID NPPM_SETEDITORBORDEREDGE(0, BOOL withEditorBorderEdgeOrNot)
#define RUNCOMMAND_USER (WM_USER + 3000)
#define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH)

View File

@ -276,6 +276,9 @@ LRESULT Notepad_plus::init(HWND hwnd)
_subEditView.execute(SCI_SETFONTQUALITY, SC_EFF_QUALITY_LCD_OPTIMIZED);
}
_mainEditView.setBorderEdge(svp1._showBorderEdge);
_subEditView.setBorderEdge(svp1._showBorderEdge);
_mainEditView.execute(SCI_SETCARETLINEVISIBLEALWAYS, true);
_subEditView.execute(SCI_SETCARETLINEVISIBLEALWAYS, true);

View File

@ -1229,6 +1229,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return TRUE;
}
case NPPM_SETEDITORBORDEREDGE:
{
bool withBorderEdge = (lParam == 1);
_mainEditView.setBorderEdge(withBorderEdge);
_subEditView.setBorderEdge(withBorderEdge);
return TRUE;
}
case NPPM_INTERNAL_SETMULTISELCTION:
{
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI();

View File

@ -4718,6 +4718,16 @@ void NppParameters::feedScintillaParam(TiXmlNode *node)
_svp._edgeMode = EDGE_NONE;
}
// Do Scintilla border edge
nm = element->Attribute(TEXT("borderEdge"));
if (nm)
{
if (!lstrcmp(nm, TEXT("yes")))
_svp._showBorderEdge = true;
else if (!lstrcmp(nm, TEXT("no")))
_svp._showBorderEdge = false;
}
int val;
nm = element->Attribute(TEXT("edgeNbColumn"), &val);
if (nm)
@ -4892,6 +4902,7 @@ bool NppParameters::writeScintillaParams(const ScintillaViewParams & svp)
(scintNode->ToElement())->SetAttribute(TEXT("disableAdvancedScrolling"), svp._disableAdvancedScrolling?TEXT("yes"):TEXT("no"));
(scintNode->ToElement())->SetAttribute(TEXT("wrapSymbolShow"), svp._wrapSymbolShow?TEXT("show"):TEXT("hide"));
(scintNode->ToElement())->SetAttribute(TEXT("Wrap"), svp._doWrap?TEXT("yes"):TEXT("no"));
(scintNode->ToElement())->SetAttribute(TEXT("borderEdge"), svp._showBorderEdge ? TEXT("yes") : TEXT("no"));
TCHAR *edgeStr = NULL;
if (svp._edgeMode == EDGE_NONE)

View File

@ -866,6 +866,7 @@ struct ScintillaViewParams
int _borderWidth = 2;
bool _disableAdvancedScrolling = false;
bool _doSmoothFont = false;
bool _showBorderEdge = true;
};
const int NB_LIST = 20;

View File

@ -3158,4 +3158,17 @@ generic_string ScintillaEditView::getEOLString()
{
return TEXT("\r");
}
}
}
void ScintillaEditView::setBorderEdge(bool doWithBorderEdge)
{
long exStyle = ::GetWindowLongPtr(_hSelf, GWL_EXSTYLE);
if (doWithBorderEdge)
exStyle |= WS_EX_CLIENTEDGE;
else
exStyle &= ~WS_EX_CLIENTEDGE;
::SetWindowLongPtr(_hSelf, GWL_EXSTYLE, exStyle);
::SetWindowPos(_hSelf, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
}

View File

@ -641,6 +641,7 @@ public:
};
void scrollPosToCenter(int pos);
generic_string getEOLString();
void setBorderEdge(bool doWithBorderEdge);
void sortLines(size_t fromLine, size_t toLine, ISorter *pSort);
void changeTextDirection(bool isRTL);
bool isTextDirectionRTL() const;

View File

@ -46,5 +46,5 @@ void BabyGridWrapper::init(HINSTANCE hInst, HWND parent, int id)
_hParent,\
(HMENU)id,\
_hInst,\
(LPVOID)/*this*/NULL);
(LPVOID)NULL);
}

View File

@ -107,8 +107,9 @@ BEGIN
CONTROL "Aligned",IDC_RADIO_LWALIGN,"Button",BS_AUTORADIOBUTTON,311,71,60,10
CONTROL "Indent",IDC_RADIO_LWINDENT,"Button",BS_AUTORADIOBUTTON,311,85,62,10
GROUPBOX "Border Width",IDC_BORDERWIDTH_STATIC,142,122,148,30,BS_CENTER
CONTROL "",IDC_BORDERWIDTH_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,156,135,67,13
LTEXT "0",IDC_BORDERWIDTHVAL_STATIC,225,135,12,8
CONTROL "",IDC_BORDERWIDTH_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,145,135,67,13
LTEXT "0",IDC_BORDERWIDTHVAL_STATIC,213,135,12,8
CONTROL "No edge",IDC_CHECK_NOEDGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,228,135,60,10
CONTROL "Display line number",IDC_CHECK_LINENUMBERMARGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,298,107,141,10
CONTROL "Display bookmark",IDC_CHECK_BOOKMARKMARGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,298,120,150,10
CONTROL "Enable current line highlighting",IDC_CHECK_CURRENTLINEHILITE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,298,133,129,10

View File

@ -572,7 +572,9 @@ void MarginsDlg::initScintParam()
::SendDlgItemMessage(_hSelf, IDC_CHECK_BOOKMARKMARGE, BM_SETCHECK, svp._bookMarkMarginShow, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_CURRENTLINEHILITE, BM_SETCHECK, svp._currentLineHilitingShow, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_DISABLEADVANCEDSCROLL, BM_SETCHECK, svp._disableAdvancedScrolling, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_NOEDGE, BM_SETCHECK, !svp._showBorderEdge, 0);
bool isEnable = !(svp._edgeMode == EDGE_NONE);
::SendDlgItemMessage(_hSelf, IDC_CHECK_SHOWVERTICALEDGE, BM_SETCHECK, isEnable, 0);
::SendDlgItemMessage(_hSelf, IDC_RADIO_LNMODE, BM_SETCHECK, (svp._edgeMode == EDGE_LINE), 0);
@ -651,11 +653,10 @@ INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
::SendMessage(::GetParent(_hParent), WM_SIZE, 0, 0);
}
return 0; //return zero when handled
}
case WM_COMMAND :
{
{
ScintillaViewParams & svp = (ScintillaViewParams &)pNppParam->getSVP();
switch (wParam)
{
@ -687,6 +688,11 @@ INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETMULTISELCTION, 0, 0);
return TRUE;
case IDC_CHECK_NOEDGE:
svp._showBorderEdge = !(BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_NOEDGE, BM_GETCHECK, 0, 0));
::SendMessage(::GetParent(_hParent), NPPM_SETEDITORBORDEREDGE, 0, svp._showBorderEdge ? TRUE : FALSE);
return TRUE;
case IDC_RADIO_SIMPLE:
svp._folderStyle = FOLDER_STYLE_SIMPLE;
::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_FOLDERMAGIN_SIMPLE, 0);

View File

@ -112,6 +112,7 @@
#define IDC_BORDERWIDTHVAL_STATIC (IDD_PREFERENCE_MARGEIN_BOX + 32)
#define IDC_BORDERWIDTH_SLIDER (IDD_PREFERENCE_MARGEIN_BOX + 33)
#define IDC_CHECK_DISABLEADVANCEDSCROLL (IDD_PREFERENCE_MARGEIN_BOX + 34)
#define IDC_CHECK_NOEDGE (IDD_PREFERENCE_MARGEIN_BOX + 35)
#define IDD_PREFERENCE_DELIMITERSETTINGS_BOX 6250 //(IDD_PREFERENCE_BOX + 250)
#define IDC_DELIMITERSETTINGS_GB_STATIC (IDD_PREFERENCE_DELIMITERSETTINGS_BOX + 1)