Add an option for displying constant line number width
1. Add an option for displying constant line number width in Preferences dialog. This option set the line number constant width according the total line number in the document (minimun 4 digits). It ensures no unexpected visual effect while scrolling content vertically. If the document content is modified and the total number of lines is increased or decreased, more digits will be added or removed according the number of digits in total number of lines. 2. Add new plugin messages NPPM_GETLINENUMBERWIDTHMODE & NPPM_SETLINENUMBERWIDTHMODE for getting or setting LINENUMWIDTH_DYNAMIC / LINENUMWIDTH_CONSTANT. So plugins may send NPPM_SETLINENUMBERWIDTHMODE message with LINENUMWIDTH_CONSTANT to Notepad++ for avoiding some unexpected visual effect (while scrolling). Fix #5670
This commit is contained in:
parent
fefdbc9cad
commit
c9c2d1e376
@ -838,7 +838,10 @@ The comments are here for explanation, it's not necessary to translate them.
|
|||||||
<Item id="6204" name="Circle tree"/>
|
<Item id="6204" name="Circle tree"/>
|
||||||
<Item id="6205" name="Box tree"/>
|
<Item id="6205" name="Box tree"/>
|
||||||
<Item id="6226" name="None"/>
|
<Item id="6226" name="None"/>
|
||||||
<Item id="6206" name="Display line number"/>
|
<Item id="6291" name="Line Number"/>
|
||||||
|
<Item id="6206" name="Display"/>
|
||||||
|
<Item id="6292" name="Dynamic width"/>
|
||||||
|
<Item id="6293" name="Constant width"/>
|
||||||
<Item id="6207" name="Display bookmark"/>
|
<Item id="6207" name="Display bookmark"/>
|
||||||
<Item id="6211" name="Vertical Edge Settings"/>
|
<Item id="6211" name="Vertical Edge Settings"/>
|
||||||
<Item id="6213" name="Background mode"/>
|
<Item id="6213" name="Background mode"/>
|
||||||
|
@ -835,7 +835,10 @@
|
|||||||
<Item id="6204" name="Circle tree"/>
|
<Item id="6204" name="Circle tree"/>
|
||||||
<Item id="6205" name="Box tree"/>
|
<Item id="6205" name="Box tree"/>
|
||||||
<Item id="6226" name="None"/>
|
<Item id="6226" name="None"/>
|
||||||
<Item id="6206" name="Display line number"/>
|
<Item id="6291" name="Line Number"/>
|
||||||
|
<Item id="6206" name="Display"/>
|
||||||
|
<Item id="6292" name="Dynamic width"/>
|
||||||
|
<Item id="6293" name="Constant width"/>
|
||||||
<Item id="6207" name="Display bookmark"/>
|
<Item id="6207" name="Display bookmark"/>
|
||||||
<Item id="6211" name="Vertical Edge Settings"/>
|
<Item id="6211" name="Vertical Edge Settings"/>
|
||||||
<Item id="6213" name="Background mode"/>
|
<Item id="6213" name="Background mode"/>
|
||||||
|
@ -800,20 +800,23 @@
|
|||||||
</Scintillas>
|
</Scintillas>
|
||||||
|
|
||||||
<MarginsBorderEdge title="Marges et Bordure">
|
<MarginsBorderEdge title="Marges et Bordure">
|
||||||
<Item id="6206" name="Afficher la numérotation des lignes"/>
|
|
||||||
<Item id="6207" name="Afficher la marge de signet"/>
|
|
||||||
<Item id="6211" name="Marqueur de colonne"/>
|
|
||||||
<Item id="6213" name="Colorer l’arrière-plan"/>
|
|
||||||
<Item id="6237" name="Ajoutez votre marqueur de colonne en indiquant sa position avec un nombre entier.
|
|
||||||
Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour séparer les différents nombres."/>
|
|
||||||
<Item id="6201" name="Contrôle de repli de bloc"/>
|
<Item id="6201" name="Contrôle de repli de bloc"/>
|
||||||
<Item id="6202" name="Simple"/>
|
<Item id="6202" name="Simple"/>
|
||||||
<Item id="6203" name="Flèche"/>
|
<Item id="6203" name="Flèche"/>
|
||||||
<Item id="6204" name="Cercle"/>
|
<Item id="6204" name="Cercle"/>
|
||||||
<Item id="6205" name="Carré"/>
|
<Item id="6205" name="Carré"/>
|
||||||
<Item id="6226" name="Aucun"/>
|
<Item id="6226" name="Aucun"/>
|
||||||
|
<Item id="6211" name="Marqueur de colonne"/>
|
||||||
|
<Item id="6213" name="Colorer l’arrière-plan"/>
|
||||||
|
<Item id="6237" name="Ajoutez votre marqueur de colonne en indiquant sa position avec un nombre entier.
|
||||||
|
Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour séparer les différents nombres."/>
|
||||||
<Item id="6231" name="Largeur de la bordure"/>
|
<Item id="6231" name="Largeur de la bordure"/>
|
||||||
<Item id="6235" name="Pas de bordure"/>
|
<Item id="6235" name="Pas de bordure"/>
|
||||||
|
<Item id="6291" name="Numérotation des lignes"/>
|
||||||
|
<Item id="6206" name="Afficher"/>
|
||||||
|
<Item id="6292" name="Largeur dynamique"/>
|
||||||
|
<Item id="6293" name="Largeur constante"/>
|
||||||
|
<Item id="6207" name="Afficher la marge de signet"/>
|
||||||
</MarginsBorderEdge>
|
</MarginsBorderEdge>
|
||||||
|
|
||||||
<NewDoc title="Nouveau document">
|
<NewDoc title="Nouveau document">
|
||||||
|
@ -813,7 +813,10 @@
|
|||||||
<Item id="6204" name="圓形"/>
|
<Item id="6204" name="圓形"/>
|
||||||
<Item id="6205" name="方形"/>
|
<Item id="6205" name="方形"/>
|
||||||
<Item id="6226" name="無"/>
|
<Item id="6226" name="無"/>
|
||||||
<Item id="6206" name="顯示行號"/>
|
<Item id="6291" name="行號"/>
|
||||||
|
<Item id="6206" name="顯示"/>
|
||||||
|
<Item id="6292" name="動態寬度"/>
|
||||||
|
<Item id="6293" name="恆定寬度"/>
|
||||||
<Item id="6207" name="顯示標記"/>
|
<Item id="6207" name="顯示標記"/>
|
||||||
<Item id="6211" name="行界線設定"/>
|
<Item id="6211" name="行界線設定"/>
|
||||||
<Item id="6213" name="背景色模式"/>
|
<Item id="6213" name="背景色模式"/>
|
||||||
|
@ -1340,4 +1340,27 @@ void trim(generic_string& str)
|
|||||||
if (pos != generic_string::npos) str.erase(0, pos);
|
if (pos != generic_string::npos) str.erase(0, pos);
|
||||||
}
|
}
|
||||||
else str.erase(str.begin(), str.end());
|
else str.erase(str.begin(), str.end());
|
||||||
};
|
}
|
||||||
|
|
||||||
|
int nbDigitsFromNbLines(size_t nbLines)
|
||||||
|
{
|
||||||
|
int nbDigits = 0; // minimum number of digit should be 4
|
||||||
|
if (nbLines < 10) nbDigits = 1;
|
||||||
|
else if (nbLines < 100) nbDigits = 2;
|
||||||
|
else if (nbLines < 1000) nbDigits = 3;
|
||||||
|
else if (nbLines < 10000) nbDigits = 4;
|
||||||
|
else if (nbLines < 100000) nbDigits = 5;
|
||||||
|
else if (nbLines < 1000000) nbDigits = 6;
|
||||||
|
else // rare case
|
||||||
|
{
|
||||||
|
nbDigits = 7;
|
||||||
|
nbLines /= 1000000;
|
||||||
|
|
||||||
|
while (nbLines)
|
||||||
|
{
|
||||||
|
nbLines /= 10;
|
||||||
|
++nbDigits;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nbDigits;
|
||||||
|
}
|
||||||
|
@ -235,3 +235,5 @@ template<typename T> size_t vecRemoveDuplicates(std::vector<T>& vec, bool isSort
|
|||||||
}
|
}
|
||||||
|
|
||||||
void trim(generic_string& str);
|
void trim(generic_string& str);
|
||||||
|
|
||||||
|
int nbDigitsFromNbLines(size_t nbLines);
|
||||||
|
@ -436,6 +436,19 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64 };
|
|||||||
// Users should call it with settingsCloudPath be NULL to get the required number of TCHAR (not including the terminating nul character),
|
// Users should call it with settingsCloudPath be NULL to get the required number of TCHAR (not including the terminating nul character),
|
||||||
// allocate settingsCloudPath buffer with the return value + 1, then call it again to get the path.
|
// allocate settingsCloudPath buffer with the return value + 1, then call it again to get the path.
|
||||||
|
|
||||||
|
#define NPPM_SETLINENUMBERWIDTHMODE (NPPMSG + 99)
|
||||||
|
#define LINENUMWIDTH_DYNAMIC 0
|
||||||
|
#define LINENUMWIDTH_CONSTANT 1
|
||||||
|
// BOOL NPPM_SETLINENUMBERWIDTHMODE(0, INT widthMode)
|
||||||
|
// Set line number margin width in dynamic width mode (LINENUMWIDTH_DYNAMIC) or constant width mode (LINENUMWIDTH_CONSTANT)
|
||||||
|
// It may help some plugins to disable non-dynamic line number margins width to have a smoothly visual effect while vertical scrolling the content in Notepad++
|
||||||
|
// If calling is successful return TRUE, otherwise return FALSE.
|
||||||
|
|
||||||
|
#define NPPM_GETLINENUMBERWIDTHMODE (NPPMSG + 100)
|
||||||
|
// INT NPPM_GETLINENUMBERWIDTHMODE(0, 0)
|
||||||
|
// Get line number margin width in dynamic width mode (LINENUMWIDTH_DYNAMIC) or constant width mode (LINENUMWIDTH_CONSTANT)
|
||||||
|
|
||||||
|
|
||||||
#define VAR_NOT_RECOGNIZED 0
|
#define VAR_NOT_RECOGNIZED 0
|
||||||
#define FULL_CURRENT_PATH 1
|
#define FULL_CURRENT_PATH 1
|
||||||
#define CURRENT_DIRECTORY 2
|
#define CURRENT_DIRECTORY 2
|
||||||
|
@ -2639,7 +2639,7 @@ bool isUrlSchemeSupported(INTERNET_SCHEME s, TCHAR *url)
|
|||||||
case INTERNET_SCHEME_FILE:
|
case INTERNET_SCHEME_FILE:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
generic_string const mySchemes = (NppParameters::getInstance()).getNppGUI()._uriShemes + TEXT(" ");
|
generic_string const mySchemes = (NppParameters::getInstance()).getNppGUI()._uriSchemes + TEXT(" ");
|
||||||
TCHAR *p = (TCHAR *)mySchemes.c_str();
|
TCHAR *p = (TCHAR *)mySchemes.c_str();
|
||||||
while (*p)
|
while (*p)
|
||||||
{
|
{
|
||||||
|
@ -1429,7 +1429,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||||||
|
|
||||||
case NPPM_INTERNAL_SCROLLBEYONDLASTLINE:
|
case NPPM_INTERNAL_SCROLLBEYONDLASTLINE:
|
||||||
{
|
{
|
||||||
const bool endAtLastLine = not (nppParam.getSVP())._scrollBeyondLastLine;
|
const bool endAtLastLine = !(nppParam.getSVP())._scrollBeyondLastLine;
|
||||||
_mainEditView.execute(SCI_SETENDATLASTLINE, endAtLastLine);
|
_mainEditView.execute(SCI_SETENDATLASTLINE, endAtLastLine);
|
||||||
_subEditView.execute(SCI_SETENDATLASTLINE, endAtLastLine);
|
_subEditView.execute(SCI_SETENDATLASTLINE, endAtLastLine);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -2124,6 +2124,24 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||||||
return settingsOnCloudPath.length();
|
return settingsOnCloudPath.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case NPPM_SETLINENUMBERWIDTHMODE:
|
||||||
|
{
|
||||||
|
if (lParam != LINENUMWIDTH_DYNAMIC || lParam != LINENUMWIDTH_CONSTANT)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
ScintillaViewParams &svp = const_cast<ScintillaViewParams &>(nppParam.getSVP());
|
||||||
|
svp._lineNumberMarginDynamicWidth = lParam == LINENUMWIDTH_DYNAMIC;
|
||||||
|
::SendMessage(hwnd, WM_COMMAND, IDM_VIEW_LINENUMBER, 0);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
case NPPM_GETLINENUMBERWIDTHMODE:
|
||||||
|
{
|
||||||
|
const ScintillaViewParams &svp = nppParam.getSVP();
|
||||||
|
return svp._lineNumberMarginDynamicWidth ? LINENUMWIDTH_DYNAMIC : LINENUMWIDTH_CONSTANT;
|
||||||
|
}
|
||||||
|
|
||||||
case NPPM_MSGTOPLUGIN :
|
case NPPM_MSGTOPLUGIN :
|
||||||
{
|
{
|
||||||
return _pluginsManager.relayPluginMessages(message, wParam, lParam);
|
return _pluginsManager.relayPluginMessages(message, wParam, lParam);
|
||||||
@ -2387,7 +2405,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||||||
_mainEditView.execute(SCI_MULTIEDGECLEARALL);
|
_mainEditView.execute(SCI_MULTIEDGECLEARALL);
|
||||||
_subEditView.execute(SCI_MULTIEDGECLEARALL);
|
_subEditView.execute(SCI_MULTIEDGECLEARALL);
|
||||||
|
|
||||||
ScintillaViewParams & svp = (ScintillaViewParams &)nppParam.getSVP();
|
ScintillaViewParams &svp = const_cast<ScintillaViewParams &>(nppParam.getSVP());
|
||||||
|
|
||||||
StyleArray & stylers = NppParameters::getInstance().getMiscStylerArray();
|
StyleArray & stylers = NppParameters::getInstance().getMiscStylerArray();
|
||||||
COLORREF multiEdgeColor = liteGrey;
|
COLORREF multiEdgeColor = liteGrey;
|
||||||
|
@ -1012,7 +1012,9 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
_subEditView.restoreCurrentPosPreStep();
|
_subEditView.restoreCurrentPosPreStep();
|
||||||
_subEditView.setWrapRestoreNeeded(false);
|
_subEditView.setWrapRestoreNeeded(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyView->updateLineNumberWidth();
|
notifyView->updateLineNumberWidth();
|
||||||
|
|
||||||
if (_syncInfo.doSync())
|
if (_syncInfo.doSync())
|
||||||
doSynScorll(HWND(notification->nmhdr.hwndFrom));
|
doSynScorll(HWND(notification->nmhdr.hwndFrom));
|
||||||
|
|
||||||
|
@ -4449,7 +4449,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
|
|||||||
{
|
{
|
||||||
const TCHAR* val = n->Value();
|
const TCHAR* val = n->Value();
|
||||||
if (val)
|
if (val)
|
||||||
_nppGUI._uriShemes = val;
|
_nppGUI._uriSchemes = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5270,6 +5270,16 @@ void NppParameters::feedScintillaParam(TiXmlNode *node)
|
|||||||
_svp._lineNumberMarginShow = false;
|
_svp._lineNumberMarginShow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Line Number Margin dynamic width
|
||||||
|
nm = element->Attribute(TEXT("lineNumberDynamicWidth"));
|
||||||
|
if (nm)
|
||||||
|
{
|
||||||
|
if (!lstrcmp(nm, TEXT("yes")))
|
||||||
|
_svp._lineNumberMarginDynamicWidth = true;
|
||||||
|
else if (!lstrcmp(nm, TEXT("no")))
|
||||||
|
_svp._lineNumberMarginDynamicWidth = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Bookmark Margin
|
// Bookmark Margin
|
||||||
nm = element->Attribute(TEXT("bookMarkMargin"));
|
nm = element->Attribute(TEXT("bookMarkMargin"));
|
||||||
if (nm)
|
if (nm)
|
||||||
@ -5671,6 +5681,7 @@ bool NppParameters::writeScintillaParams()
|
|||||||
}
|
}
|
||||||
|
|
||||||
(scintNode->ToElement())->SetAttribute(TEXT("lineNumberMargin"), _svp._lineNumberMarginShow?TEXT("show"):TEXT("hide"));
|
(scintNode->ToElement())->SetAttribute(TEXT("lineNumberMargin"), _svp._lineNumberMarginShow?TEXT("show"):TEXT("hide"));
|
||||||
|
(scintNode->ToElement())->SetAttribute(TEXT("lineNumberDynamicWidth"), _svp._lineNumberMarginDynamicWidth ?TEXT("yes"):TEXT("no"));
|
||||||
(scintNode->ToElement())->SetAttribute(TEXT("bookMarkMargin"), _svp._bookMarkMarginShow?TEXT("show"):TEXT("hide"));
|
(scintNode->ToElement())->SetAttribute(TEXT("bookMarkMargin"), _svp._bookMarkMarginShow?TEXT("show"):TEXT("hide"));
|
||||||
(scintNode->ToElement())->SetAttribute(TEXT("indentGuideLine"), _svp._indentGuideLineShow?TEXT("show"):TEXT("hide"));
|
(scintNode->ToElement())->SetAttribute(TEXT("indentGuideLine"), _svp._indentGuideLineShow?TEXT("show"):TEXT("hide"));
|
||||||
const TCHAR *pFolderStyleStr = (_svp._folderStyle == FOLDER_STYLE_SIMPLE)?TEXT("simple"):
|
const TCHAR *pFolderStyleStr = (_svp._folderStyle == FOLDER_STYLE_SIMPLE)?TEXT("simple"):
|
||||||
@ -6013,7 +6024,7 @@ void NppParameters::createXmlTreeFromGUIParams()
|
|||||||
{
|
{
|
||||||
TiXmlElement *GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
|
TiXmlElement *GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
|
||||||
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("uriCustomizedSchemes"));
|
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("uriCustomizedSchemes"));
|
||||||
GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._uriShemes.c_str()));
|
GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._uriSchemes.c_str()));
|
||||||
}
|
}
|
||||||
// <GUIConfig name = "globalOverride" fg = "no" bg = "no" font = "no" fontSize = "no" bold = "no" italic = "no" underline = "no" / >
|
// <GUIConfig name = "globalOverride" fg = "no" bg = "no" font = "no" fontSize = "no" bold = "no" italic = "no" underline = "no" / >
|
||||||
{
|
{
|
||||||
|
@ -849,7 +849,7 @@ struct NppGUI final
|
|||||||
bool _isWordCharDefault = true;
|
bool _isWordCharDefault = true;
|
||||||
std::string _customWordChars;
|
std::string _customWordChars;
|
||||||
urlMode _styleURL = urlUnderLineFg;
|
urlMode _styleURL = urlUnderLineFg;
|
||||||
generic_string _uriShemes = TEXT("svn:// cvs:// git:// imap:// irc:// irc6:// ircs:// ldap:// ldaps:// news: telnet:// gopher:// ssh:// sftp:// smb:// skype: snmp:// spotify: steam:// sms: slack:// chrome:// bitcoin:");
|
generic_string _uriSchemes = TEXT("svn:// cvs:// git:// imap:// irc:// irc6:// ircs:// ldap:// ldaps:// news: telnet:// gopher:// ssh:// sftp:// smb:// skype: snmp:// spotify: steam:// sms: slack:// chrome:// bitcoin:");
|
||||||
NewDocDefaultSettings _newDocDefaultSettings;
|
NewDocDefaultSettings _newDocDefaultSettings;
|
||||||
|
|
||||||
|
|
||||||
@ -919,6 +919,7 @@ struct NppGUI final
|
|||||||
struct ScintillaViewParams
|
struct ScintillaViewParams
|
||||||
{
|
{
|
||||||
bool _lineNumberMarginShow = true;
|
bool _lineNumberMarginShow = true;
|
||||||
|
bool _lineNumberMarginDynamicWidth = true;
|
||||||
bool _bookMarkMarginShow = true;
|
bool _bookMarkMarginShow = true;
|
||||||
folderStyle _folderStyle = FOLDER_STYLE_BOX; //"simple", "arrow", "circle", "box" and "none"
|
folderStyle _folderStyle = FOLDER_STYLE_BOX; //"simple", "arrow", "circle", "box" and "none"
|
||||||
lineWrapMethod _lineWrapMethod = LINEWRAP_ALIGNED;
|
lineWrapMethod _lineWrapMethod = LINEWRAP_ALIGNED;
|
||||||
@ -935,7 +936,7 @@ struct ScintillaViewParams
|
|||||||
bool _whiteSpaceShow = false;
|
bool _whiteSpaceShow = false;
|
||||||
bool _eolShow = false;
|
bool _eolShow = false;
|
||||||
int _borderWidth = 2;
|
int _borderWidth = 2;
|
||||||
bool _scrollBeyondLastLine = false;
|
bool _scrollBeyondLastLine = true;
|
||||||
bool _rightClickKeepsSelection = false;
|
bool _rightClickKeepsSelection = false;
|
||||||
bool _disableAdvancedScrolling = false;
|
bool _disableAdvancedScrolling = false;
|
||||||
bool _doSmoothFont = false;
|
bool _doSmoothFont = false;
|
||||||
|
@ -2731,38 +2731,37 @@ void ScintillaEditView::setLineIndent(int line, int indent) const
|
|||||||
|
|
||||||
void ScintillaEditView::updateLineNumberWidth()
|
void ScintillaEditView::updateLineNumberWidth()
|
||||||
{
|
{
|
||||||
if (_lineNumbersShown)
|
const ScintillaViewParams& svp = NppParameters::getInstance().getSVP();
|
||||||
|
if (svp._lineNumberMarginShow)
|
||||||
{
|
{
|
||||||
auto linesVisible = execute(SCI_LINESONSCREEN);
|
auto linesVisible = execute(SCI_LINESONSCREEN);
|
||||||
if (linesVisible)
|
if (linesVisible)
|
||||||
|
{
|
||||||
|
int nbDigits = 0;
|
||||||
|
|
||||||
|
if (svp._lineNumberMarginDynamicWidth)
|
||||||
{
|
{
|
||||||
auto firstVisibleLineVis = execute(SCI_GETFIRSTVISIBLELINE);
|
auto firstVisibleLineVis = execute(SCI_GETFIRSTVISIBLELINE);
|
||||||
auto lastVisibleLineVis = linesVisible + firstVisibleLineVis + 1;
|
auto lastVisibleLineVis = linesVisible + firstVisibleLineVis + 1;
|
||||||
|
|
||||||
auto lastVisibleLineDoc = execute(SCI_DOCLINEFROMVISIBLE, lastVisibleLineVis);
|
auto lastVisibleLineDoc = execute(SCI_DOCLINEFROMVISIBLE, lastVisibleLineVis);
|
||||||
|
|
||||||
int nbDigits = 3; // minimum number of digit should be 3
|
nbDigits = nbDigitsFromNbLines(lastVisibleLineDoc);
|
||||||
if (lastVisibleLineDoc < 1000) {} //nbDigits = 3;
|
nbDigits = nbDigits < 3 ? 3 : nbDigits;
|
||||||
else if (lastVisibleLineDoc < 10000) nbDigits = 4;
|
}
|
||||||
else if (lastVisibleLineDoc < 100000) nbDigits = 5;
|
else
|
||||||
else if (lastVisibleLineDoc < 1000000) nbDigits = 6;
|
|
||||||
else // rare case
|
|
||||||
{
|
{
|
||||||
nbDigits = 7;
|
auto nbLines = execute(SCI_GETLINECOUNT);
|
||||||
lastVisibleLineDoc /= 1000000;
|
nbDigits = nbDigitsFromNbLines(nbLines);
|
||||||
|
nbDigits = nbDigits < 4 ? 4 : nbDigits;
|
||||||
|
}
|
||||||
|
|
||||||
while (lastVisibleLineDoc)
|
|
||||||
{
|
|
||||||
lastVisibleLineDoc /= 10;
|
|
||||||
++nbDigits;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
auto pixelWidth = 8 + nbDigits * execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, reinterpret_cast<LPARAM>("8"));
|
auto pixelWidth = 8 + nbDigits * execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, reinterpret_cast<LPARAM>("8"));
|
||||||
execute(SCI_SETMARGINWIDTHN, _SC_MARGE_LINENUMBER, pixelWidth);
|
execute(SCI_SETMARGINWIDTHN, _SC_MARGE_LINENUMBER, pixelWidth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * ScintillaEditView::getCompleteKeywordList(std::basic_string<char> & kwl, LangType langType, int keywordIndex)
|
const char * ScintillaEditView::getCompleteKeywordList(std::basic_string<char> & kwl, LangType langType, int keywordIndex)
|
||||||
{
|
{
|
||||||
kwl += " ";
|
kwl += " ";
|
||||||
|
@ -326,7 +326,7 @@ public:
|
|||||||
|
|
||||||
void showMargin(int whichMarge, bool willBeShowed = true) {
|
void showMargin(int whichMarge, bool willBeShowed = true) {
|
||||||
if (whichMarge == _SC_MARGE_LINENUMBER)
|
if (whichMarge == _SC_MARGE_LINENUMBER)
|
||||||
showLineNumbersMargin(willBeShowed);
|
updateLineNumbersMargin();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int width = 3;
|
int width = 3;
|
||||||
@ -473,11 +473,9 @@ public:
|
|||||||
|
|
||||||
void setLineIndent(int line, int indent) const;
|
void setLineIndent(int line, int indent) const;
|
||||||
|
|
||||||
void showLineNumbersMargin(bool show)
|
void updateLineNumbersMargin() {
|
||||||
{
|
const ScintillaViewParams& svp = NppParameters::getInstance().getSVP();
|
||||||
if (show == _lineNumbersShown) return;
|
if (svp._lineNumberMarginShow)
|
||||||
_lineNumbersShown = show;
|
|
||||||
if (show)
|
|
||||||
{
|
{
|
||||||
updateLineNumberWidth();
|
updateLineNumberWidth();
|
||||||
}
|
}
|
||||||
@ -489,6 +487,7 @@ public:
|
|||||||
|
|
||||||
void updateLineNumberWidth();
|
void updateLineNumberWidth();
|
||||||
|
|
||||||
|
|
||||||
void setCurrentLineHiLiting(bool isHiliting, COLORREF bgColor) const {
|
void setCurrentLineHiLiting(bool isHiliting, COLORREF bgColor) const {
|
||||||
execute(SCI_SETCARETLINEVISIBLE, isHiliting);
|
execute(SCI_SETCARETLINEVISIBLE, isHiliting);
|
||||||
if (!isHiliting)
|
if (!isHiliting)
|
||||||
@ -666,7 +665,6 @@ protected:
|
|||||||
Buffer * _currentBuffer = nullptr;
|
Buffer * _currentBuffer = nullptr;
|
||||||
|
|
||||||
int _codepage = CP_ACP;
|
int _codepage = CP_ACP;
|
||||||
bool _lineNumbersShown = false;
|
|
||||||
bool _wrapRestoreNeeded = false;
|
bool _wrapRestoreNeeded = false;
|
||||||
bool _positionRestoreNeeded = false;
|
bool _positionRestoreNeeded = false;
|
||||||
uint32_t _restorePositionRetryCount = 0;
|
uint32_t _restorePositionRetryCount = 0;
|
||||||
|
@ -91,15 +91,16 @@ BEGIN
|
|||||||
CONTROL "Default",IDC_RADIO_LWDEF,"Button",BS_AUTORADIOBUTTON | WS_GROUP,275,21,59,10
|
CONTROL "Default",IDC_RADIO_LWDEF,"Button",BS_AUTORADIOBUTTON | WS_GROUP,275,21,59,10
|
||||||
CONTROL "Aligned",IDC_RADIO_LWALIGN,"Button",BS_AUTORADIOBUTTON,275,36,60,10
|
CONTROL "Aligned",IDC_RADIO_LWALIGN,"Button",BS_AUTORADIOBUTTON,275,36,60,10
|
||||||
CONTROL "Indent",IDC_RADIO_LWINDENT,"Button",BS_AUTORADIOBUTTON,275,51,62,10
|
CONTROL "Indent",IDC_RADIO_LWINDENT,"Button",BS_AUTORADIOBUTTON,275,51,62,10
|
||||||
CONTROL "Enable Multi-Editing (Ctrl+Mouse click/selection)",IDC_CHECK_MULTISELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,90,230,10
|
CONTROL "Enable Multi-Editing (Ctrl+Mouse click/selection)",IDC_CHECK_MULTISELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,90,270,10
|
||||||
CONTROL "Enable current line highlighting",IDC_CHECK_CURRENTLINEHILITE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,103,160,10
|
CONTROL "Enable current line highlighting",IDC_CHECK_CURRENTLINEHILITE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,103,270,10
|
||||||
CONTROL "Enable smooth font",IDC_CHECK_SMOOTHFONT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,116,130,10
|
CONTROL "Enable smooth font",IDC_CHECK_SMOOTHFONT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,116,250,10
|
||||||
CONTROL "Enable scrolling beyond last line",IDC_CHECK_SCROLLBEYONDLASTLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,129,160,10
|
CONTROL "Enable scrolling beyond last line",IDC_CHECK_SCROLLBEYONDLASTLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,129,270,10
|
||||||
CONTROL "Keep selection when right-click outside of selection",IDC_CHECK_RIGHTCLICKKEEPSSELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,142,230,10
|
CONTROL "Keep selection when right-click outside of selection",IDC_CHECK_RIGHTCLICKKEEPSSELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,142,270,10
|
||||||
CONTROL "Disable advanced scrolling feature due to touchpad issue",IDC_CHECK_DISABLEADVANCEDSCROLL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,155,270,10
|
CONTROL "Disable advanced scrolling feature due to touchpad issue",IDC_CHECK_DISABLEADVANCEDSCROLL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,155,270,10
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IDD_PREFERENCE_SUB_MARGING_BORDER_EDGE DIALOGEX 0, 0, 455, 185
|
IDD_PREFERENCE_SUB_MARGING_BORDER_EDGE DIALOGEX 0, 0, 455, 185
|
||||||
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
|
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
|
||||||
FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
||||||
@ -110,16 +111,19 @@ BEGIN
|
|||||||
CONTROL "Circle tree",IDC_RADIO_CIRCLE,"Button",BS_AUTORADIOBUTTON,31,63,62,10
|
CONTROL "Circle tree",IDC_RADIO_CIRCLE,"Button",BS_AUTORADIOBUTTON,31,63,62,10
|
||||||
CONTROL "None",IDC_RADIO_FOLDMARGENONE,"Button",BS_AUTORADIOBUTTON,31,92,61,10
|
CONTROL "None",IDC_RADIO_FOLDMARGENONE,"Button",BS_AUTORADIOBUTTON,31,92,61,10
|
||||||
CONTROL "Box tree",IDC_RADIO_BOX,"Button",BS_AUTORADIOBUTTON,31,77,61,10
|
CONTROL "Box tree",IDC_RADIO_BOX,"Button",BS_AUTORADIOBUTTON,31,77,61,10
|
||||||
GROUPBOX "Vertical Edge Settings",IDC_VES_GB_STATIC,118,21,148,135,BS_CENTER
|
GROUPBOX "Vertical Edge Settings",IDC_VES_GB_STATIC,116,21,148,135,BS_CENTER
|
||||||
CONTROL "Background mode",IDC_CHECK_EDGEBGMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,129,138,122,10
|
LTEXT "Add your column marker by indicating its position with a decimal number.\nYou can define several column markers by using white space to separate the different numbers.",IDC_STATIC_MULTILNMODE_TIP,124,36,134,55
|
||||||
LTEXT "Add your column marker by indicating its position with a decimal number.\nYou can define several column markers by using white space to separate the different numbers.",IDC_STATIC_MULTILNMODE_TIP,126,36,134,55
|
EDITTEXT IDC_COLUMNPOS_EDIT,126,93,125,36,ES_MULTILINE
|
||||||
EDITTEXT IDC_COLUMNPOS_EDIT,128,93,125,36,ES_MULTILINE
|
CONTROL "Background mode",IDC_CHECK_EDGEBGMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,127,138,122,10
|
||||||
GROUPBOX "Border Width",IDC_BORDERWIDTH_STATIC,21,112,85,45,BS_CENTER
|
GROUPBOX "Border Width",IDC_BORDERWIDTH_STATIC,21,112,85,45,BS_CENTER
|
||||||
CONTROL "",IDC_BORDERWIDTH_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,24,125,67,13
|
CONTROL "",IDC_BORDERWIDTH_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,24,125,67,13
|
||||||
LTEXT "0",IDC_BORDERWIDTHVAL_STATIC,92,125,12,8
|
LTEXT "0",IDC_BORDERWIDTHVAL_STATIC,92,125,12,8
|
||||||
CONTROL "No edge",IDC_CHECK_NOEDGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,142,60,10
|
CONTROL "No edge",IDC_CHECK_NOEDGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,142,60,10
|
||||||
CONTROL "Display line number",IDC_CHECK_LINENUMBERMARGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,283,27,141,10
|
GROUPBOX "Line Number",IDC_LINENUMBERMARGE_GB_STATIC,275,21,135,66,BS_CENTER
|
||||||
CONTROL "Display bookmark",IDC_CHECK_BOOKMARKMARGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,283,39,150,10
|
CONTROL "Display",IDC_CHECK_LINENUMBERMARGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,281,35,85,10
|
||||||
|
CONTROL "Dynamic width",IDC_RADIO_DYNAMIC,"Button",BS_AUTORADIOBUTTON | WS_GROUP,293,51,110,10
|
||||||
|
CONTROL "Constant width",IDC_RADIO_CONSTANT,"Button",BS_AUTORADIOBUTTON,293,65,108,10
|
||||||
|
CONTROL "Display bookmark",IDC_CHECK_BOOKMARKMARGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,281,97,150,10
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
|
@ -786,6 +786,11 @@ void MarginsBorderEdgeSubDlg::initScintParam()
|
|||||||
::SendDlgItemMessage(_hSelf, id, BM_SETCHECK, TRUE, 0);
|
::SendDlgItemMessage(_hSelf, id, BM_SETCHECK, TRUE, 0);
|
||||||
|
|
||||||
::SendDlgItemMessage(_hSelf, IDC_CHECK_LINENUMBERMARGE, BM_SETCHECK, svp._lineNumberMarginShow, 0);
|
::SendDlgItemMessage(_hSelf, IDC_CHECK_LINENUMBERMARGE, BM_SETCHECK, svp._lineNumberMarginShow, 0);
|
||||||
|
::SendDlgItemMessage(_hSelf, IDC_RADIO_DYNAMIC, BM_SETCHECK, svp._lineNumberMarginDynamicWidth, 0);
|
||||||
|
::SendDlgItemMessage(_hSelf, IDC_RADIO_CONSTANT, BM_SETCHECK, !svp._lineNumberMarginDynamicWidth, 0);
|
||||||
|
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DYNAMIC), svp._lineNumberMarginShow);
|
||||||
|
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_CONSTANT), svp._lineNumberMarginShow);
|
||||||
|
|
||||||
::SendDlgItemMessage(_hSelf, IDC_CHECK_BOOKMARKMARGE, BM_SETCHECK, svp._bookMarkMarginShow, 0);
|
::SendDlgItemMessage(_hSelf, IDC_CHECK_BOOKMARKMARGE, BM_SETCHECK, svp._bookMarkMarginShow, 0);
|
||||||
|
|
||||||
::SendDlgItemMessage(_hSelf, IDC_CHECK_NOEDGE, BM_SETCHECK, !svp._showBorderEdge, 0);
|
::SendDlgItemMessage(_hSelf, IDC_CHECK_NOEDGE, BM_SETCHECK, !svp._showBorderEdge, 0);
|
||||||
@ -857,6 +862,16 @@ INT_PTR CALLBACK MarginsBorderEdgeSubDlg::run_dlgProc(UINT message, WPARAM wPara
|
|||||||
{
|
{
|
||||||
case IDC_CHECK_LINENUMBERMARGE:
|
case IDC_CHECK_LINENUMBERMARGE:
|
||||||
svp._lineNumberMarginShow = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_LINENUMBERMARGE, BM_GETCHECK, 0, 0));
|
svp._lineNumberMarginShow = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_LINENUMBERMARGE, BM_GETCHECK, 0, 0));
|
||||||
|
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DYNAMIC), svp._lineNumberMarginShow);
|
||||||
|
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_CONSTANT), svp._lineNumberMarginShow);
|
||||||
|
::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_LINENUMBER, 0);
|
||||||
|
return TRUE;
|
||||||
|
case IDC_RADIO_DYNAMIC:
|
||||||
|
svp._lineNumberMarginDynamicWidth = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_RADIO_DYNAMIC, BM_GETCHECK, 0, 0));
|
||||||
|
::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_LINENUMBER, 0);
|
||||||
|
return TRUE;
|
||||||
|
case IDC_RADIO_CONSTANT:
|
||||||
|
svp._lineNumberMarginDynamicWidth = !(BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_RADIO_CONSTANT, BM_GETCHECK, 0, 0));
|
||||||
::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_LINENUMBER, 0);
|
::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_LINENUMBER, 0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
@ -3346,7 +3361,7 @@ INT_PTR CALLBACK CloudAndLinkSubDlg::run_dlgProc(UINT message, WPARAM wParam, LP
|
|||||||
{
|
{
|
||||||
TCHAR uriScheme[uriSchemesMaxLength] = { '\0' };
|
TCHAR uriScheme[uriSchemesMaxLength] = { '\0' };
|
||||||
::SendDlgItemMessage(_hSelf, IDC_URISCHEMES_EDIT, WM_GETTEXT, uriSchemesMaxLength, reinterpret_cast<LPARAM>(uriScheme));
|
::SendDlgItemMessage(_hSelf, IDC_URISCHEMES_EDIT, WM_GETTEXT, uriSchemesMaxLength, reinterpret_cast<LPARAM>(uriScheme));
|
||||||
nppGUI._uriShemes = uriScheme;
|
nppGUI._uriSchemes = uriScheme;
|
||||||
HWND grandParent = ::GetParent(_hParent);
|
HWND grandParent = ::GetParent(_hParent);
|
||||||
::SendMessage(grandParent, NPPM_INTERNAL_UPDATECLICKABLELINKS, 0, 0);
|
::SendMessage(grandParent, NPPM_INTERNAL_UPDATECLICKABLELINKS, 0, 0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -3380,7 +3395,7 @@ INT_PTR CALLBACK CloudAndLinkSubDlg::run_dlgProc(UINT message, WPARAM wParam, LP
|
|||||||
BOOL dontUnderline = (nppGUI._styleURL == urlNoUnderLineFg) || (nppGUI._styleURL == urlNoUnderLineBg);
|
BOOL dontUnderline = (nppGUI._styleURL == urlNoUnderLineFg) || (nppGUI._styleURL == urlNoUnderLineBg);
|
||||||
BOOL roundBoxMode = (nppGUI._styleURL == urlNoUnderLineBg) || (nppGUI._styleURL == urlUnderLineBg);
|
BOOL roundBoxMode = (nppGUI._styleURL == urlNoUnderLineBg) || (nppGUI._styleURL == urlUnderLineBg);
|
||||||
::SendDlgItemMessage(_hSelf, IDC_URISCHEMES_EDIT, EM_SETLIMITTEXT, uriSchemesMaxLength, 0);
|
::SendDlgItemMessage(_hSelf, IDC_URISCHEMES_EDIT, EM_SETLIMITTEXT, uriSchemesMaxLength, 0);
|
||||||
::SetWindowText(::GetDlgItem(_hSelf, IDC_URISCHEMES_EDIT), nppGUI._uriShemes.c_str());
|
::SetWindowText(::GetDlgItem(_hSelf, IDC_URISCHEMES_EDIT), nppGUI._uriSchemes.c_str());
|
||||||
|
|
||||||
::SendDlgItemMessage(_hSelf, IDC_CHECK_CLICKABLELINK_ENABLE, BM_SETCHECK, linkEnable, 0);
|
::SendDlgItemMessage(_hSelf, IDC_CHECK_CLICKABLELINK_ENABLE, BM_SETCHECK, linkEnable, 0);
|
||||||
::SendDlgItemMessage(_hSelf, IDC_CHECK_CLICKABLELINK_NOUNDERLINE, BM_SETCHECK, dontUnderline, 0);
|
::SendDlgItemMessage(_hSelf, IDC_CHECK_CLICKABLELINK_NOUNDERLINE, BM_SETCHECK, dontUnderline, 0);
|
||||||
|
@ -161,6 +161,9 @@
|
|||||||
#define IDC_SEARCHENGINE_STACKOVERFLOW_RADIO (IDD_PREFERENCE_SUB_SEARCHENGINE + 9)
|
#define IDC_SEARCHENGINE_STACKOVERFLOW_RADIO (IDD_PREFERENCE_SUB_SEARCHENGINE + 9)
|
||||||
|
|
||||||
#define IDD_PREFERENCE_SUB_MARGING_BORDER_EDGE 6290 //(IDD_PREFERENCE_BOX + 290)
|
#define IDD_PREFERENCE_SUB_MARGING_BORDER_EDGE 6290 //(IDD_PREFERENCE_BOX + 290)
|
||||||
|
#define IDC_LINENUMBERMARGE_GB_STATIC (IDD_PREFERENCE_SUB_MARGING_BORDER_EDGE + 1)
|
||||||
|
#define IDC_RADIO_DYNAMIC (IDD_PREFERENCE_SUB_MARGING_BORDER_EDGE + 2)
|
||||||
|
#define IDC_RADIO_CONSTANT (IDD_PREFERENCE_SUB_MARGING_BORDER_EDGE + 3)
|
||||||
|
|
||||||
#define IDD_PREFERENCE_SUB_MISC 6300 //(IDD_PREFERENCE_BOX + 300)
|
#define IDD_PREFERENCE_SUB_MISC 6300 //(IDD_PREFERENCE_BOX + 300)
|
||||||
#define IDC_TABSETTING_GB_STATIC (IDD_PREFERENCE_SUB_MISC + 1)
|
#define IDC_TABSETTING_GB_STATIC (IDD_PREFERENCE_SUB_MISC + 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user