Browse Source

[BUG_FIXED] Fix the regression bug that x position doesn't be restored while switching back a document.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@200 f5eea248-9336-0410-98b8-ebc06183d4e3
pull/343/head^2
donho 17 years ago
parent
commit
7b7909ad80
  1. 4
      PowerEditor/bin/change.log
  2. 12
      PowerEditor/src/Notepad_plus.cpp
  3. 2
      PowerEditor/src/Notepad_plus.rc
  4. 7
      PowerEditor/src/Parameters.cpp
  5. 2
      PowerEditor/src/Parameters.h
  6. 1
      PowerEditor/src/ScitillaComponent/Buffer.h
  7. 58
      PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp
  8. 3
      PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp
  9. 2
      PowerEditor/src/menuCmdID.h
  10. 6
      PowerEditor/src/resource.h

4
PowerEditor/bin/change.log

@ -1,4 +1,4 @@
Notepad++ v4.9.1 fixed bugs and added features (from v4.8.5) :
Notepad++ v4.9.2 fixed bugs and added features (from v4.8.5) :
1. Add smart highlighting feature (double click a word to highlight all the same word in the document).
2. Enhance visual effect of Mark all feature.
@ -17,7 +17,7 @@ Notepad++ v4.9.1 fixed bugs and added features (from v4.8.5) :
15. Make search in hidden directory (for Find in files) optional.
16. Fix the replace bug while replacing nothing.
17. Fix the F3 searching direction bug.
18. Fix the regression bug that x position doesn't be restored while switching back a document.
Included plugins :

12
PowerEditor/src/Notepad_plus.cpp

@ -2140,7 +2140,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
{
_pEditView->marginClick(notification->position, notification->modifiers);
}
else if (notification->margin == ScintillaEditView::_SC_MARGE_SYBOLE)
else if ((notification->margin == ScintillaEditView::_SC_MARGE_SYBOLE) && !notification->modifiers)
{
int lineClick = int(_pEditView->execute(SCI_LINEFROMPOSITION, notification->position));
@ -2599,7 +2599,7 @@ void Notepad_plus::specialCmd(int id, int param)
{
ValueDlg nbColumnEdgeDlg;
ScintillaViewParams & svp = (ScintillaViewParams &)pNppParam->getSVP(param == 1?SCIV_PRIMARY:SCIV_SECOND);
nbColumnEdgeDlg.init(_hInst, _hSelf, svp._edgeNbColumn, "Nb of column:");
nbColumnEdgeDlg.init(_hInst, _preference.getHSelf(), svp._edgeNbColumn, "Nb of column:");
nbColumnEdgeDlg.setNBNumber(3);
POINT p;
@ -3642,7 +3642,7 @@ void Notepad_plus::command(int id)
{
ValueDlg tabSizeDlg;
NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI());
tabSizeDlg.init(_hInst, _hSelf, nppgui._tabSize, "Tab Size : ");
tabSizeDlg.init(_hInst, _preference.getHSelf(), nppgui._tabSize, "Tab Size : ");
POINT p;
::GetCursorPos(&p);
::ScreenToClient(_hParent, &p);
@ -3663,7 +3663,7 @@ void Notepad_plus::command(int id)
ValueDlg valDlg;
NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI());
valDlg.init(_hInst, _hSelf, nppGUI._autocFromLen, "Nb char : ");
valDlg.init(_hInst, _preference.getHSelf(), nppGUI._autocFromLen, "Nb char : ");
POINT p;
::GetCursorPos(&p);
::ScreenToClient(_hParent, &p);
@ -3685,7 +3685,7 @@ void Notepad_plus::command(int id)
{
ValueDlg nbHistoryDlg;
NppParameters *pNppParam = NppParameters::getInstance();
nbHistoryDlg.init(_hInst, _hSelf, pNppParam->getNbMaxFile(), "Max File : ");
nbHistoryDlg.init(_hInst, _preference.getHSelf(), pNppParam->getNbMaxFile(), "Max File : ");
POINT p;
::GetCursorPos(&p);
::ScreenToClient(_hParent, &p);
@ -6320,7 +6320,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
//Add recent files
HMENU hFileMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_FILE);
int nbLRFile = pNppParam->getNbLRFile();
int pos = 16;
int pos = 17;
_lastRecentFileList.initMenu(hFileMenu, IDM_FILEMENU_LASTONE + 1, pos);
for (int i = 0 ; i < nbLRFile ; i++)

2
PowerEditor/src/Notepad_plus.rc

@ -249,7 +249,7 @@ BEGIN
MENUITEM "Re&load from disk", IDM_FILE_RELOAD
MENUITEM "&Save", IDM_FILE_SAVE
MENUITEM "Save &As...", IDM_FILE_SAVEAS
MENUITEM "Save Copy As...", IDM_FILE_SAVECOPYAS
MENUITEM "Save a Copy As...", IDM_FILE_SAVECOPYAS
MENUITEM "Sav&e All", IDM_FILE_SAVEALL
MENUITEM "&Close", IDM_FILE_CLOSE
MENUITEM "Cl&ose All", IDM_FILE_CLOSEALL

7
PowerEditor/src/Parameters.cpp

@ -49,6 +49,7 @@ WinMenuKeyDefinition winKeyDefs[] = { //array of accelerator keys for all std me
{VK_NULL, IDM_FILE_RELOAD, false, false, false, NULL},
{VK_S, IDM_FILE_SAVE, true, false, false, NULL},
{VK_S, IDM_FILE_SAVEAS, true, true, false, NULL},
{VK_NULL, IDM_FILE_SAVECOPYAS, false, false, false, NULL},
{VK_S, IDM_FILE_SAVEALL, true, false, true, NULL},
{VK_W, IDM_FILE_CLOSE, true, false, false, NULL},
{VK_NULL, IDM_FILE_CLOSEALL, false, false, false, NULL},
@ -1106,6 +1107,7 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p
(childNode->ToElement())->Attribute("startPos", &position._startPos);
(childNode->ToElement())->Attribute("endPos", &position._endPos);
(childNode->ToElement())->Attribute("selMode", &position._selMode);
(childNode->ToElement())->Attribute("scrollWidth", &position._scrollWidth);
const char *langName;
langName = (childNode->ToElement())->Attribute( "lang" );
@ -1150,6 +1152,7 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p
(childNode->ToElement())->Attribute("startPos", &position._startPos);
(childNode->ToElement())->Attribute("endPos", &position._endPos);
(childNode->ToElement())->Attribute("selMode", &position._selMode);
(childNode->ToElement())->Attribute("scrollWidth", &position._scrollWidth);
const char *langName;
langName = (childNode->ToElement())->Attribute( "lang" );
@ -1603,9 +1606,10 @@ void NppParameters::writeSession(const Session & session, const char *fileName)
for (size_t i = 0 ; i < session._mainViewFiles.size() ; i++)
{
TiXmlNode *fileNameNode = mainViewNode->InsertEndChild(TiXmlElement("File"));
(fileNameNode->ToElement())->SetAttribute("firstVisibleLine", session._mainViewFiles[i]._firstVisibleLine);
(fileNameNode->ToElement())->SetAttribute("xOffset", session._mainViewFiles[i]._xOffset);
(fileNameNode->ToElement())->SetAttribute("scrollWidth", session._mainViewFiles[i]._scrollWidth);
(fileNameNode->ToElement())->SetAttribute("startPos", session._mainViewFiles[i]._startPos);
(fileNameNode->ToElement())->SetAttribute("endPos", session._mainViewFiles[i]._endPos);
(fileNameNode->ToElement())->SetAttribute("selMode", session._mainViewFiles[i]._selMode);
@ -1628,6 +1632,7 @@ void NppParameters::writeSession(const Session & session, const char *fileName)
(fileNameNode->ToElement())->SetAttribute("firstVisibleLine", session._subViewFiles[i]._firstVisibleLine);
(fileNameNode->ToElement())->SetAttribute("xOffset", session._subViewFiles[i]._xOffset);
(fileNameNode->ToElement())->SetAttribute("scrollWidth", session._subViewFiles[i]._scrollWidth);
(fileNameNode->ToElement())->SetAttribute("startPos", session._subViewFiles[i]._startPos);
(fileNameNode->ToElement())->SetAttribute("endPos", session._subViewFiles[i]._endPos);
(fileNameNode->ToElement())->SetAttribute("selMode", session._subViewFiles[i]._selMode);

2
PowerEditor/src/Parameters.h

@ -98,6 +98,8 @@ struct Position
int _endPos;
int _xOffset;
int _selMode;
int _scrollWidth;
Position() : _firstVisibleLine(0), _startPos(0), _endPos(0), _xOffset(0), _scrollWidth(1), _selMode(0) {};
};
struct sessionFileInfo : public Position {

1
PowerEditor/src/ScitillaComponent/Buffer.h

@ -100,6 +100,7 @@ public :
_pos._startPos = 0;
_pos._endPos = 0;
_pos._xOffset = 0;
_pos._scrollWidth = 1;
setFileName(fileName, ndds._lang);
//_userLangExt[0] = '\0';
};

58
PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp

@ -109,6 +109,7 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere)
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.preprocessor"), reinterpret_cast<LPARAM>("1"));
execute(SCI_SETFOLDFLAGS, 16);
execute(SCI_SETSCROLLWIDTHTRACKING, true);
execute(SCI_SETSCROLLWIDTH, 1); //default empty document: override default width of 2000
// smart hilighting
execute(SCI_INDICSETSTYLE, SCE_UNIVERSAL_FOUND_STYLE_2, INDIC_ROUNDBOX);
@ -938,6 +939,7 @@ void ScintillaEditView::saveCurrentPos()
buf._pos._endPos = static_cast<int>(execute(SCI_GETSELECTIONEND));
buf._pos._xOffset = static_cast<int>(execute(SCI_GETXOFFSET));
buf._pos._selMode = execute(SCI_GETSELECTIONMODE);
buf._pos._scrollWidth = execute(SCI_GETSCROLLWIDTH);
}
void ScintillaEditView::restoreCurrentPos()
@ -953,14 +955,20 @@ void ScintillaEditView::restoreCurrentPos()
}
execute(SCI_SETSELECTIONSTART, buf._pos._startPos);
execute(SCI_SETSELECTIONEND, buf._pos._endPos);
//int scrollWidth = execute(SCI_GETSCROLLWIDTH);
//execute(SCI_SETSCROLLWIDTH, scrollWidth);
execute(SCI_SETSCROLLWIDTH, buf._pos._scrollWidth);
execute(SCI_SETXOFFSET, buf._pos._xOffset);
// these 2 lines should be at the end so it works in wrap mode
// these 3 lines should be at the end so it works in wrap mode
int lineToShow = execute(SCI_VISIBLEFROMDOCLINE, buf._pos._firstVisibleLine);
scroll(0, lineToShow);
}
//! \brief this method activates the doc and the corresponding sub tab
//! \brief return the index of previeus current doc
char * ScintillaEditView::activateDocAt(int index)
@ -968,7 +976,7 @@ char * ScintillaEditView::activateDocAt(int index)
::SendMessage(_hParent, NPPM_INTERNAL_DOCSWITCHOFF, 0, (LPARAM)_hSelf);
// To minimize the scroll width on each doc switch
execute(SCI_SETSCROLLWIDTH, 1);
//execute(SCI_SETSCROLLWIDTH, 1);
// before activating another document, we get the current position
// from the Scintilla view then save it to the current document
@ -1008,6 +1016,10 @@ char * ScintillaEditView::activateDocAt(int index)
_currentIndex = index;
_buffers[_currentIndex].increaseRecentTag();
// Due to execute(SCI_CLEARDOCUMENTSTYLE); in defineDocType() function
// defineDocType() function should be called here, but not be after the fold info loop
defineDocType(_buffers[_currentIndex]._lang);
// restore the collapsed info
int nbLineState = _buffers[_currentIndex]._foldState.size();
@ -1023,17 +1035,11 @@ char * ScintillaEditView::activateDocAt(int index)
execute(SCI_TOGGLEFOLD, hls._headerLineNumber);
}
//if (isDocTypeDiff)
defineDocType(_buffers[_currentIndex]._lang);
restoreCurrentPos();
execute(SCI_SETEOLMODE, _buffers[_currentIndex]._format);
::SendMessage(_hParent, NPPM_INTERNAL_DOCSWITCHIN, 0, (LPARAM)_hSelf);
//recalcHorizontalScrollbar(); //Update scrollbar after switching file
//execute(SCI_SETSCROLLWIDTHTRACKING, false);
return _buffers[_currentIndex]._fullPathName;
}
@ -1748,43 +1754,7 @@ void ScintillaEditView::columnReplace(const ColumnModeInfo & cmi, const char ch)
execute(SCI_REPLACETARGET, -1, (LPARAM)str.c_str());
}
}
/*
//This method recalculates the horizontal scrollbar based
//on the current visible text and styler.
void ScintillaEditView::recalcHorizontalScrollbar()
{
int curOffset = execute(SCI_GETXOFFSET);
int maxPixel = 0, curLen;
int numLines = int(execute(SCI_GETLINECOUNT));
int startLine = execute(SCI_GETFIRSTVISIBLELINE);
int endLine = startLine + execute(SCI_LINESONSCREEN);
if ( endLine >= (execute(SCI_GETLINECOUNT) - 1) )
endLine--;
long beginPosition, endPosition;
int visibleLine = 0;
for( int i = startLine ; i <= endLine ; i++ )
{
//for all _visible_ lines
visibleLine = (int) execute(SCI_DOCLINEFROMVISIBLE, i); //get actual visible line, folding may offset lines
endPosition = execute(SCI_GETLINEENDPOSITION, visibleLine); //get character position from begin
beginPosition = execute(SCI_POSITIONFROMLINE, visibleLine); //and end of line
curLen = execute(SCI_POINTXFROMPOSITION, 0, endPosition) - //Then let Scintilla get pixel width with
execute(SCI_POINTXFROMPOSITION, 0, beginPosition); //current styler
if (maxPixel < curLen) { //If its the largest line yet
maxPixel = curLen; //Use that length
}
}
if (maxPixel == 0)
maxPixel++; //make sure maxPixel is valid
int currentLength = execute(SCI_GETSCROLLWIDTH); //Get current scrollbar size
if (currentLength != maxPixel) //And if it is not the same
execute(SCI_SETSCROLLWIDTH, maxPixel); //update it
}
*/
void ScintillaEditView::foldChanged(int line, int levelNow, int levelPrev)
{
if (levelNow & SC_FOLDLEVELHEADERFLAG)

3
PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp

@ -70,7 +70,8 @@ BOOL CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (wParam)
{
case IDOK : // Find Next
case IDCANCEL :
case IDOK :
display(false);
return TRUE;

2
PowerEditor/src/menuCmdID.h

@ -39,7 +39,7 @@
#define IDM_FILE_SAVECOPYAS (IDM_FILE + 15)
// A mettre à jour si on ajoute nouveau menu item dans le menu "File"
#define IDM_FILEMENU_LASTONE IDM_FILE_RELOAD
#define IDM_FILEMENU_LASTONE IDM_FILE_SAVECOPYAS
#define IDM_EDIT (IDM + 2000)
#define IDM_EDIT_CUT (IDM_EDIT + 1)

6
PowerEditor/src/resource.h

@ -18,9 +18,9 @@
#ifndef RESOURCE_H
#define RESOURCE_H
#define NOTEPAD_PLUS_VERSION "Notepad++ v4.9.1"
#define VERSION_VALUE "4.91\0" // should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71
#define VERSION_DIGITALVALUE 4, 9, 1, 0
#define NOTEPAD_PLUS_VERSION "Notepad++ v4.9.2"
#define VERSION_VALUE "4.92\0" // should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71
#define VERSION_DIGITALVALUE 4, 9, 2, 0
#ifndef IDC_STATIC
#define IDC_STATIC -1

Loading…
Cancel
Save