mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 05:45:00 +02:00
Fix selection issue after switching document.
Make getBufferByID inline. Fix selection reset after reload or saving session. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@256 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
f53fa31a70
commit
86e358a89a
@ -4259,6 +4259,7 @@ void Notepad_plus::setLanguage(int id, LangType langType) {
|
||||
if (bothActive()) {
|
||||
if (_mainEditView.getCurrentBufferID() == _subEditView.getCurrentBufferID()) {
|
||||
reset = true;
|
||||
_subEditView.saveCurrentPos();
|
||||
prev = _subEditView.execute(SCI_GETDOCPOINTER);
|
||||
_subEditView.execute(SCI_SETDOCPOINTER, 0, 0);
|
||||
}
|
||||
@ -4271,6 +4272,7 @@ void Notepad_plus::setLanguage(int id, LangType langType) {
|
||||
|
||||
if (reset) {
|
||||
_subEditView.execute(SCI_SETDOCPOINTER, 0, prev);
|
||||
_subEditView.restoreCurrentPos();
|
||||
}
|
||||
};
|
||||
|
||||
@ -7916,7 +7918,9 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session)
|
||||
//_mainEditView.activateBuffer(mainBuf->getID()); //restore buffer
|
||||
//_subEditView.activateBuffer(subBuf->getID()); //restore buffer
|
||||
_mainEditView.execute(SCI_SETDOCPOINTER, 0, mainBuf->getDocument());
|
||||
_mainEditView.restoreCurrentPos();
|
||||
_subEditView.execute(SCI_SETDOCPOINTER, 0, subBuf->getDocument());
|
||||
_subEditView.restoreCurrentPos();
|
||||
}
|
||||
|
||||
bool Notepad_plus::fileLoadSession(const char *fn)
|
||||
|
@ -356,10 +356,12 @@ Buffer * FileManager::getBufferByIndex(int index) {
|
||||
return _buffers.at(index);
|
||||
}
|
||||
|
||||
/*
|
||||
Buffer * FileManager::getBufferByID(BufferID id) {
|
||||
return (Buffer*)id;
|
||||
//return _buffers.at(getBufferIndexByID(id));
|
||||
}
|
||||
*/
|
||||
|
||||
void FileManager::beNotifiedOfBufferChange(Buffer * theBuf, int mask) {
|
||||
_pNotepadPlus->notifyBufferChanged(theBuf, mask);
|
||||
|
@ -57,6 +57,7 @@ struct HeaderLineState {
|
||||
const int userLangNameMax = 16;
|
||||
|
||||
//File manager class maintains all buffers
|
||||
class Buffer;
|
||||
class FileManager {
|
||||
public:
|
||||
void init(Notepad_plus * pNotepadPlus, ScintillaEditView * pscratchTilla);
|
||||
@ -67,7 +68,7 @@ public:
|
||||
int getNrBuffers() { return _nrBufs; };
|
||||
int getBufferIndexByID(BufferID id);
|
||||
Buffer * getBufferByIndex(int index); //generates exception if index is invalid
|
||||
Buffer * getBufferByID(BufferID id); //generates exception if id is invalid
|
||||
Buffer * getBufferByID(BufferID id) {return (Buffer*)id;}
|
||||
|
||||
void beNotifiedOfBufferChange(Buffer * theBuf, int mask);
|
||||
|
||||
|
@ -986,8 +986,8 @@ void ScintillaEditView::saveCurrentPos()
|
||||
Position pos;
|
||||
// the correct visible line number
|
||||
pos._firstVisibleLine = docLine;
|
||||
pos._startPos = static_cast<int>(execute(SCI_GETSELECTIONSTART));
|
||||
pos._endPos = static_cast<int>(execute(SCI_GETSELECTIONEND));
|
||||
pos._startPos = static_cast<int>(execute(SCI_GETANCHOR));
|
||||
pos._endPos = static_cast<int>(execute(SCI_GETCURRENTPOS));
|
||||
pos._xOffset = static_cast<int>(execute(SCI_GETXOFFSET));
|
||||
pos._selMode = execute(SCI_GETSELECTIONMODE);
|
||||
pos._scrollWidth = execute(SCI_GETSCROLLWIDTH);
|
||||
@ -1002,9 +1002,10 @@ void ScintillaEditView::restoreCurrentPos()
|
||||
|
||||
execute(SCI_GOTOPOS, 0); //make sure first line visible by setting caret there, will scroll to top of document
|
||||
|
||||
execute(SCI_SETSELECTIONMODE, pos._selMode);
|
||||
execute(SCI_SETSELECTIONSTART, pos._startPos);
|
||||
execute(SCI_SETSELECTIONEND, pos._endPos);
|
||||
execute(SCI_SETSELECTIONMODE, pos._selMode); //enable
|
||||
execute(SCI_SETANCHOR, pos._startPos);
|
||||
execute(SCI_SETCURRENTPOS, pos._endPos);
|
||||
execute(SCI_CANCEL); //disable
|
||||
if (!isWrap()) { //only offset if not wrapping, otherwise the offset isnt needed at all
|
||||
execute(SCI_SETSCROLLWIDTH, pos._scrollWidth);
|
||||
execute(SCI_SETXOFFSET, pos._xOffset);
|
||||
|
Loading…
x
Reference in New Issue
Block a user