Add document snapshot feature (in progress)

This commit is contained in:
Don HO 2017-04-18 01:31:41 +02:00
parent f57a565b6b
commit 20e669ff01
23 changed files with 443 additions and 61 deletions

View File

@ -634,6 +634,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
_md5FromFilesDlg.init(_pPublicInterface->getHinst(), hwnd); _md5FromFilesDlg.init(_pPublicInterface->getHinst(), hwnd);
_md5FromTextDlg.init(_pPublicInterface->getHinst(), hwnd); _md5FromTextDlg.init(_pPublicInterface->getHinst(), hwnd);
_runMacroDlg.init(_pPublicInterface->getHinst(), hwnd); _runMacroDlg.init(_pPublicInterface->getHinst(), hwnd);
_documentSnapshot.init(_pPublicInterface->getHinst(), hwnd);
//--User Define Dialog Section--// //--User Define Dialog Section--//
int uddStatus = nppGUI._userDefineDlgStatus; int uddStatus = nppGUI._userDefineDlgStatus;

View File

@ -52,6 +52,7 @@
#include "lesDlgs.h" #include "lesDlgs.h"
#include "pluginsAdmin.h" #include "pluginsAdmin.h"
#include "localization.h" #include "localization.h"
#include "documentSnapshot.h"
#include "md5Dlgs.h" #include "md5Dlgs.h"
#include <vector> #include <vector>
#include <iso646.h> #include <iso646.h>
@ -282,6 +283,7 @@ private:
PreferenceDlg _preference; PreferenceDlg _preference;
FindCharsInRangeDlg _findCharsInRangeDlg; FindCharsInRangeDlg _findCharsInRangeDlg;
PluginsAdminDlg _pluginsAdminDlg; PluginsAdminDlg _pluginsAdminDlg;
DocumentSnapshot _documentSnapshot;
// a handle list of all the Notepad++ dialogs // a handle list of all the Notepad++ dialogs
std::vector<HWND> _hModelessDlgs; std::vector<HWND> _hModelessDlgs;

View File

@ -70,6 +70,7 @@ void Notepad_plus::command(int id)
case IDM_FILE_NEW: case IDM_FILE_NEW:
{ {
fileNew(); fileNew();
/* /*
bool isFirstTime = not _pluginsAdminDlg.isCreated(); bool isFirstTime = not _pluginsAdminDlg.isCreated();
_pluginsAdminDlg.setPluginsManager(&_pluginsManager); _pluginsAdminDlg.setPluginsManager(&_pluginsManager);
@ -2572,6 +2573,7 @@ void Notepad_plus::command(int id)
return; return;
} }
} }
if (doAboutDlg) if (doAboutDlg)
{ {
bool isFirstTime = !_aboutDlg.isCreated(); bool isFirstTime = !_aboutDlg.isCreated();

View File

@ -1601,7 +1601,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode)
} }
buf->setPosition(session._mainViewFiles[i], &_mainEditView); buf->setPosition(session._mainViewFiles[i], &_mainEditView);
buf->setMapPosition(session._mainViewFiles[i]._mapPos._firstVisibleDocLine, session._mainViewFiles[i]._mapPos._lastVisibleDocLine, session._mainViewFiles[i]._mapPos._nbLine, session._mainViewFiles[i]._mapPos._higherPos); buf->setMapPosition(session._mainViewFiles[i]._mapPos);
buf->setLangType(typeToSet, pLn); buf->setLangType(typeToSet, pLn);
if (session._mainViewFiles[i]._encoding != -1) if (session._mainViewFiles[i]._encoding != -1)
buf->setEncoding(session._mainViewFiles[i]._encoding); buf->setEncoding(session._mainViewFiles[i]._encoding);
@ -1705,9 +1705,11 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode)
} }
buf->setPosition(session._subViewFiles[k], &_subEditView); buf->setPosition(session._subViewFiles[k], &_subEditView);
buf->setMapPosition(session._subViewFiles[k]._mapPos._firstVisibleDocLine, session._subViewFiles[k]._mapPos._lastVisibleDocLine, session._subViewFiles[k]._mapPos._nbLine, session._subViewFiles[k]._mapPos._higherPos); buf->setMapPosition(session._subViewFiles[k]._mapPos);
if (typeToSet == L_USER) { if (typeToSet == L_USER)
if (!lstrcmp(pLn, TEXT("User Defined"))) { {
if (!lstrcmp(pLn, TEXT("User Defined")))
{
pLn = TEXT(""); //default user defined pLn = TEXT(""); //default user defined
} }
} }

View File

@ -158,7 +158,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
DocTabView *pTabDocView = isFromPrimary ? &_mainDocTab : (isFromSecondary ? &_subDocTab : nullptr); DocTabView *pTabDocView = isFromPrimary ? &_mainDocTab : (isFromSecondary ? &_subDocTab : nullptr);
if (pTabDocView) if (pTabDocView)
{ {
BufferID id = pTabDocView->getBufferByIndex(tbHdr->tabOrigin); BufferID id = pTabDocView->getBufferByIndex(tbHdr->_tabOrigin);
Buffer *pBuf = MainFileManager->getBufferByID(id); Buffer *pBuf = MainFileManager->getBufferByID(id);
Buffer *currentBuf = getCurrentBuffer(); Buffer *currentBuf = getCurrentBuffer();
@ -177,12 +177,43 @@ BOOL Notepad_plus::notify(SCNotification *notification)
} }
} }
*/ */
/*
if (true)
{
TBHDR *tbHdr = reinterpret_cast<TBHDR *>(notification);
DocTabView *pTabDocView = isFromPrimary ? &_mainDocTab : (isFromSecondary ? &_subDocTab : nullptr);
if (pTabDocView)
{
BufferID id = pTabDocView->getBufferByIndex(tbHdr->_tabOrigin);
Buffer *pBuf = MainFileManager->getBufferByID(id);
Buffer *currentBuf = getCurrentBuffer();
RECT rect;
TabCtrl_GetItemRect(pTabDocView->getHSelf(), tbHdr->_tabOrigin, &rect);
POINT p;
p.x = rect.left;
p.y = rect.bottom;
::ClientToScreen(pTabDocView->getHSelf(), &p);
if (pBuf != currentBuf) // if hover on other tab
{
_documentSnapshot.doDialog(p, pBuf, *(const_cast<ScintillaEditView*>(pTabDocView->getScintillaEditView())));
}
else // if hover on current active tab
{
_documentSnapshot.display(false);
}
}
}
*/
break; break;
} }
case TCN_MOUSELEAVING: case TCN_MOUSELEAVING:
{ {
/* ///*
if (_pDocMap && (!_pDocMap->isClosed()) && _pDocMap->isVisible()) if (_pDocMap && (!_pDocMap->isClosed()) && _pDocMap->isVisible())
{ {
_pDocMap->reloadMap(); _pDocMap->reloadMap();
@ -190,7 +221,13 @@ BOOL Notepad_plus::notify(SCNotification *notification)
_pDocMap->setTemporarilyShowing(false); _pDocMap->setTemporarilyShowing(false);
} }
*/ //*/
if (true)
{
_documentSnapshot.display(false);
}
break; break;
} }
@ -287,7 +324,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
case TCN_TABDELETE: case TCN_TABDELETE:
{ {
int index = tabNotification->tabOrigin; int index = tabNotification->_tabOrigin;
BufferID bufferToClose = notifyDocTab->getBufferByIndex(index); BufferID bufferToClose = notifyDocTab->getBufferByIndex(index);
Buffer * buf = MainFileManager->getBufferByID(bufferToClose); Buffer * buf = MainFileManager->getBufferByID(bufferToClose);
int iView = isFromPrimary?MAIN_VIEW:SUB_VIEW; int iView = isFromPrimary?MAIN_VIEW:SUB_VIEW;
@ -316,6 +353,9 @@ BOOL Notepad_plus::notify(SCNotification *notification)
else else
break; break;
// save map position before switch to a new document
_documentSnapshot.saveCurrentSnapshot(*_pEditView);
switchEditViewTo(iView); switchEditViewTo(iView);
BufferID bufid = _pDocTab->getBufferByIndex(_pDocTab->getCurrentTabIndex()); BufferID bufid = _pDocTab->getBufferByIndex(_pDocTab->getCurrentTabIndex());
if (bufid != BUFFER_INVALID) if (bufid != BUFFER_INVALID)
@ -324,6 +364,12 @@ BOOL Notepad_plus::notify(SCNotification *notification)
activateBuffer(bufid, iView); activateBuffer(bufid, iView);
_isFolding = false; _isFolding = false;
} }
if (true)
{
_documentSnapshot.display(false);
}
break; break;
} }

View File

@ -2016,6 +2016,18 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p
mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapHigherPos"), &mapPosVal); mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapHigherPos"), &mapPosVal);
if (mapPosStr) if (mapPosStr)
mapPosition._higherPos = mapPosVal; mapPosition._higherPos = mapPosVal;
mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapWidth"), &mapPosVal);
if (mapPosStr)
mapPosition._width = mapPosVal;
mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapHeight"), &mapPosVal);
if (mapPosStr)
mapPosition._height = mapPosVal;
mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapWrapIndentMode"), &mapPosVal);
if (mapPosStr)
mapPosition._wrapIndentMode = mapPosVal;
const TCHAR *boolStr = (childNode->ToElement())->Attribute(TEXT("mapIsWrap"));
if (boolStr)
mapPosition._isWrap = (lstrcmp(TEXT("yes"), boolStr) == 0);
const TCHAR *langName; const TCHAR *langName;
langName = (childNode->ToElement())->Attribute(TEXT("lang")); langName = (childNode->ToElement())->Attribute(TEXT("lang"));
@ -2961,6 +2973,10 @@ void NppParameters::writeSession(const Session & session, const TCHAR *fileName)
(fileNameNode->ToElement())->SetAttribute(TEXT("mapLastVisibleDocLine"), viewSessionFiles[i]._mapPos._lastVisibleDocLine); (fileNameNode->ToElement())->SetAttribute(TEXT("mapLastVisibleDocLine"), viewSessionFiles[i]._mapPos._lastVisibleDocLine);
(fileNameNode->ToElement())->SetAttribute(TEXT("mapNbLine"), viewSessionFiles[i]._mapPos._nbLine); (fileNameNode->ToElement())->SetAttribute(TEXT("mapNbLine"), viewSessionFiles[i]._mapPos._nbLine);
(fileNameNode->ToElement())->SetAttribute(TEXT("mapHigherPos"), viewSessionFiles[i]._mapPos._higherPos); (fileNameNode->ToElement())->SetAttribute(TEXT("mapHigherPos"), viewSessionFiles[i]._mapPos._higherPos);
(fileNameNode->ToElement())->SetAttribute(TEXT("mapWidth"), viewSessionFiles[i]._mapPos._width);
(fileNameNode->ToElement())->SetAttribute(TEXT("mapHeight"), viewSessionFiles[i]._mapPos._height);
(fileNameNode->ToElement())->SetAttribute(TEXT("mapWrapIndentMode"), viewSessionFiles[i]._mapPos._wrapIndentMode);
fileNameNode->ToElement()->SetAttribute(TEXT("mapIsWrap"), viewSessionFiles[i]._mapPos._isWrap ? TEXT("yes") : TEXT("no"));
for (size_t j = 0, len = viewSessionFiles[i]._marks.size() ; j < len ; ++j) for (size_t j = 0, len = viewSessionFiles[i]._marks.size() ; j < len ; ++j)
{ {

View File

@ -144,6 +144,10 @@ struct MapPosition
int32_t _lastVisibleDocLine = -1; int32_t _lastVisibleDocLine = -1;
int32_t _nbLine = -1; int32_t _nbLine = -1;
int32_t _higherPos = -1; int32_t _higherPos = -1;
int32_t _width = -1;
int32_t _height = -1;
int32_t _wrapIndentMode = -1;
bool _isWrap = false;
bool isValid() { return _firstVisibleDocLine != -1; }; bool isValid() { return _firstVisibleDocLine != -1; };
}; };

View File

@ -46,14 +46,8 @@ static const int LF = 0x0A;
long Buffer::_recentTagCtr = 0; long Buffer::_recentTagCtr = 0;
namespace // anonymous namespace // anonymous
{ {
static EolType getEOLFormatForm(const char* const data, size_t length, EolType defvalue = EolType::osdefault) static EolType getEOLFormatForm(const char* const data, size_t length, EolType defvalue = EolType::osdefault)
{ {
assert(length == 0 or data != nullptr && "invalid buffer for getEOLFormatForm()"); assert(length == 0 or data != nullptr && "invalid buffer for getEOLFormatForm()");
@ -74,19 +68,12 @@ namespace // anonymous
return defvalue; // fallback unknown return defvalue; // fallback unknown
} }
} // anonymous namespace } // anonymous namespace
Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const TCHAR *fileName) Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const TCHAR *fileName)
// type must be either DOC_REGULAR or DOC_UNNAMED // type must be either DOC_REGULAR or DOC_UNNAMED
: _pManager(pManager) : _pManager(pManager) , _id(id), _doc(doc), _lang(L_TEXT)
, _id(id)
, _doc(doc)
, _lang(L_TEXT)
{ {
NppParameters* pNppParamInst = NppParameters::getInstance(); NppParameters* pNppParamInst = NppParameters::getInstance();
const NewDocDefaultSettings& ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings(); const NewDocDefaultSettings& ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings();
@ -468,14 +455,6 @@ void Buffer::setDeferredReload() // triggers a reload on the next Document acces
} }
void Buffer::setMapPosition(int32_t firstVisibleDocLine, int32_t lastVisibleDocLine, int32_t nbLine, int32_t higherPos)
{
_mapPosition._firstVisibleDocLine = firstVisibleDocLine;
_mapPosition._lastVisibleDocLine = lastVisibleDocLine;
_mapPosition._nbLine = nbLine;
_mapPosition._higherPos = higherPos;
}
//filemanager //filemanager
FileManager::~FileManager() FileManager::~FileManager()

View File

@ -348,15 +348,13 @@ public:
bool isMonitoringOn() const { return _isMonitoringOn; }; bool isMonitoringOn() const { return _isMonitoringOn; };
void updateTimeStamp(); void updateTimeStamp();
void reload(); void reload();
void setMapPosition(const MapPosition & mapPosition) { _mapPosition = mapPosition; };
void setMapPosition(int32_t firstVisibleDocLine, int32_t lastVisibleDocLine, int32_t nbLine, int32_t higherPos);
MapPosition getMapPosition() { return _mapPosition; }; MapPosition getMapPosition() { return _mapPosition; };
private: private:
int indexOfReference(const ScintillaEditView * identifier) const; int indexOfReference(const ScintillaEditView * identifier) const;
void setStatus(DocFileStatus status) void setStatus(DocFileStatus status) {
{
_currentStatus = status; _currentStatus = status;
doNotify(BufferChangeStatus); doNotify(BufferChangeStatus);
} }

View File

@ -229,3 +229,4 @@ void DocTabView::reSizeTo(RECT & rc)
_pView->reSizeTo(rc); _pView->reSizeTo(rc);
} }
} }

View File

@ -80,6 +80,10 @@ public :
virtual void reSizeTo(RECT & rc); virtual void reSizeTo(RECT & rc);
const ScintillaEditView* getScintillaEditView() const {
return _pView;
};
private : private :
ScintillaEditView *_pView; ScintillaEditView *_pView;
static bool _hideTabBarStatus; static bool _hideTabBarStatus;

View File

@ -25,14 +25,9 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#pragma once
#ifndef COLUMNEDITOR_H
#define COLUMNEDITOR_H
#ifndef COLUMNEDITOR_RC_H
#include "columnEditor_rc.h" #include "columnEditor_rc.h"
#endif //COLUMNEDITOR_RC_H
#include "StaticDialog.h" #include "StaticDialog.h"
class ScintillaEditView; class ScintillaEditView;
@ -74,4 +69,4 @@ private :
}; };
#endif// COLUMNEDITOR_H

View File

@ -257,9 +257,13 @@ void DocumentMap::scrollMap(ScintillaEditView *editView)
lowerY = nbLine * lineHeight + higherY; lowerY = nbLine * lineHeight + higherY;
} }
char toto[256];
sprintf(toto, "MAP : %d & %d\n\n", higherY, lowerY);
OutputDebugStringA(toto);
// set current map position in buffer // set current map position in buffer
Buffer *buffer = pEditView->getCurrentBuffer(); //Buffer *buffer = pEditView->getCurrentBuffer();
buffer->setMapPosition(static_cast<int32_t>(firstVisibleDocLine), static_cast<int32_t>(lastVisibleDocLine), static_cast<int32_t>(nbLine), static_cast<int32_t>(higherPos)); //buffer->setMapPosition(static_cast<int32_t>(firstVisibleDocLine), static_cast<int32_t>(lastVisibleDocLine), static_cast<int32_t>(nbLine), static_cast<int32_t>(higherPos));
// Update view zone in map // Update view zone in map
_vzDlg.drawZone(static_cast<long>(higherY), static_cast<long>(lowerY)); _vzDlg.drawZone(static_cast<long>(higherY), static_cast<long>(lowerY));
@ -272,6 +276,10 @@ void DocumentMap::scrollMapWith(const MapPosition & mapPos, ScintillaEditView &
{ {
// Visible document line for the map view // Visible document line for the map view
auto firstVisibleDisplayLineMap = _pScintillaEditView->execute(SCI_GETFIRSTVISIBLELINE); auto firstVisibleDisplayLineMap = _pScintillaEditView->execute(SCI_GETFIRSTVISIBLELINE);
//char toto[256];
//sprintf(toto, "MAP : highfirstVisibleDisplayLineerY: %d\n", firstVisibleDisplayLine);
//OutputDebugStringA(toto);
auto firstVisibleDocLineMap = _pScintillaEditView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap); auto firstVisibleDocLineMap = _pScintillaEditView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap);
auto nbLineMap = _pScintillaEditView->execute(SCI_LINESONSCREEN, firstVisibleDocLineMap); auto nbLineMap = _pScintillaEditView->execute(SCI_LINESONSCREEN, firstVisibleDocLineMap);
auto lastVisibleDocLineMap = editView.execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap + nbLineMap); auto lastVisibleDocLineMap = editView.execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap + nbLineMap);
@ -303,6 +311,8 @@ void DocumentMap::scrollMapWith(const MapPosition & mapPos, ScintillaEditView &
auto lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, mapPos._firstVisibleDocLine); auto lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, mapPos._firstVisibleDocLine);
lowerY = mapPos._nbLine * lineHeight + higherY; lowerY = mapPos._nbLine * lineHeight + higherY;
} }
//sprintf(toto, "MAP : %d & %d\n\n", higherY, lowerY);
//OutputDebugStringA(toto);
// Update view zone in map // Update view zone in map
_vzDlg.drawZone(static_cast<long>(higherY), static_cast<long>(lowerY)); _vzDlg.drawZone(static_cast<long>(higherY), static_cast<long>(lowerY));

View File

@ -57,8 +57,7 @@ public :
void doDialog(); void doDialog();
virtual void destroy() { virtual void destroy() {};
};
void drawZone(long hY, long lY) { void drawZone(long hY, long lY) {
_higherY = hY; _higherY = hY;

View File

@ -0,0 +1,183 @@
// This file is part of Notepad++ project
// Copyright (C)2003-2017 Don HO <don.h@free.fr>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the
// following:
// 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield.
// 3. Links to a library or executes a program that does any of the above.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "documentSnapshot.h"
#include "ScintillaEditView.h"
INT_PTR CALLBACK DocumentSnapshot::run_dlgProc(UINT message, WPARAM /*wParam*/, LPARAM /*lParam*/)
{
switch (message)
{
case WM_INITDIALOG :
{
HWND hwndScintilla = reinterpret_cast<HWND>(::SendMessage(_hParent, NPPM_CREATESCINTILLAHANDLE, 0, reinterpret_cast<LPARAM>(_hSelf)));
_pScintillaEditView = reinterpret_cast<ScintillaEditView *>(::SendMessage(_hParent, NPPM_INTERNAL_GETSCINTEDTVIEW, 0, reinterpret_cast<LPARAM>(hwndScintilla)));
_pScintillaEditView->execute(SCI_SETZOOM, static_cast<WPARAM>(-10), 0);
_pScintillaEditView->execute(SCI_SETVSCROLLBAR, FALSE, 0);
_pScintillaEditView->execute(SCI_SETHSCROLLBAR, FALSE, 0);
_pScintillaEditView->showIndentGuideLine(false);
::MoveWindow(_pScintillaEditView->getHSelf(), 0, 0, _rc.right - _rc.left, _rc.bottom - _rc.top, TRUE);
_pScintillaEditView->display();
}
break;
}
return FALSE;
}
void DocumentSnapshot::doDialog(POINT p, Buffer *pBuf, ScintillaEditView & scintSource)
{
if (!isCreated())
{
create(IDD_DOCUMENTSNAPSHOT);
}
syncDisplay(pBuf, scintSource);
// Adjust the position of DocumentSnapshot
goTo(p);
}
void DocumentSnapshot::goTo(POINT p)
{
::SetWindowPos(_hSelf, HWND_TOP, p.x, p.y + 10, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW);
}
void DocumentSnapshot::syncDisplay(Buffer *buf, ScintillaEditView & scintSource)
{
if (_pScintillaEditView)
{
_pScintillaEditView->execute(SCI_SETDOCPOINTER, 0, static_cast<LPARAM>(buf->getDocument()));
_pScintillaEditView->setCurrentBuffer(buf);
//
// folding
//
const std::vector<size_t> & lineStateVector = buf->getHeaderLineState(&scintSource);
_pScintillaEditView->syncFoldStateWith(lineStateVector);
//
// Wraping & scrolling
//
MapPosition mp = buf->getMapPosition();
if (mp.isValid())
scrollSnapshotWith(mp);
Buffer *buf = _pScintillaEditView->getCurrentBuffer();
_pScintillaEditView->defineDocType(buf->getLangType());
_pScintillaEditView->showMargin(ScintillaEditView::_SC_MARGE_FOLDER, false);
_pScintillaEditView->showMargin(0, false);
_pScintillaEditView->showMargin(1, false);
_pScintillaEditView->showMargin(2, false);
_pScintillaEditView->showMargin(3, false);
}
Window::display();
}
void DocumentSnapshot::scrollSnapshotWith(const MapPosition & mapPos)
{
if (_pScintillaEditView)
{
bool hasBeenChanged = false;
//
// if window size has been changed, resize windows
//
if (mapPos._height != -1 && _rc.bottom != _rc.top + mapPos._height)
{
_rc.bottom = _rc.top + mapPos._height;
hasBeenChanged = true;
}
if (mapPos._width != -1 && _rc.right != _rc.left + mapPos._width)
{
_rc.right = _rc.left + mapPos._width;
hasBeenChanged = true;
}
if (hasBeenChanged)
::MoveWindow(_pScintillaEditView->getHSelf(), 0, 0, _rc.right - _rc.left, _rc.bottom - _rc.top, TRUE);
//
// Wrapping
//
_pScintillaEditView->wrap(mapPos._isWrap);
_pScintillaEditView->execute(SCI_SETWRAPINDENTMODE, mapPos._wrapIndentMode);
//
// Reset to zero
//
_pScintillaEditView->execute(SCI_HOMEDISPLAY);
//
// Visible line for the code view
//
// Get the first visible display line from the first visible document line
auto firstVisibleDisplayLine = _pScintillaEditView->execute(SCI_VISIBLEFROMDOCLINE, mapPos._firstVisibleDocLine);
// scroll to the first visible display line
_pScintillaEditView->execute(SCI_LINESCROLL, 0, firstVisibleDisplayLine);
}
}
void DocumentSnapshot::saveCurrentSnapshot(ScintillaEditView & editView)
{
if (_pScintillaEditView)
{
MapPosition mapPos;
// First visible document line for scrolling to this line
auto firstVisibleDisplayLine = editView.execute(SCI_GETFIRSTVISIBLELINE);
mapPos._firstVisibleDocLine = static_cast<int32_t>(editView.execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine));
mapPos._nbLine = static_cast<int32_t>(editView.execute(SCI_LINESONSCREEN, firstVisibleDisplayLine));
mapPos._lastVisibleDocLine = static_cast<int32_t>(editView.execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine + mapPos._nbLine));
int32_t lineHeight = static_cast<int32_t>(_pScintillaEditView->execute(SCI_TEXTHEIGHT, mapPos._firstVisibleDocLine));
mapPos._height = mapPos._nbLine * lineHeight;
// Width
RECT editorRect;
editView.getClientRect(editorRect);
int marginWidths = 0;
for (int m = 0; m < 4; ++m)
{
marginWidths += static_cast<int32_t>(editView.execute(SCI_GETMARGINWIDTHN, m));
}
double editViewWidth = editorRect.right - editorRect.left - marginWidths;
double editViewHeight = editorRect.bottom - editorRect.top;
mapPos._width = static_cast<int32_t>((editViewWidth / editViewHeight) * static_cast<double>(mapPos._height));
mapPos._wrapIndentMode = static_cast<int32_t>(editView.execute(SCI_GETWRAPINDENTMODE));
mapPos._isWrap = static_cast<int32_t>(editView.isWrap());
// set current map position in buffer
Buffer *buffer = editView.getCurrentBuffer();
buffer->setMapPosition(mapPos);
}
}

View File

@ -0,0 +1,65 @@
// This file is part of Notepad++ project
// Copyright (C)2003-2017 Don HO <don.h@free.fr>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the
// following:
// 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield.
// 3. Links to a library or executes a program that does any of the above.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#pragma once
#include "documentSnapshot_rc.h"
#include "StaticDialog.h"
class ScintillaEditView;
class Buffer;
struct MapPosition;
class DocumentSnapshot : public StaticDialog {
public:
DocumentSnapshot(): StaticDialog() {};
void init(HINSTANCE hInst, HWND hPere) {
Window::init(hInst, hPere);
};
void doDialog(POINT p, Buffer *buf, ScintillaEditView & scintSource);
void syncDisplay(Buffer *buf, ScintillaEditView & scintSource);
void setParent(HWND parent2set){
_hParent = parent2set;
};
void scrollSnapshotWith(const MapPosition & mapPos);
void saveCurrentSnapshot(ScintillaEditView & editView);
protected:
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
void goTo(POINT p);
private:
ScintillaEditView *_pScintillaEditView = nullptr;
};

View File

@ -0,0 +1,37 @@
// This file is part of Notepad++ project
// Copyright (C)2003 Don HO <don.h@free.fr>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the
// following:
// 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield.
// 3. Links to a library or executes a program that does any of the above.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <windows.h>
#include "documentSnapshot_rc.h"
IDD_DOCUMENTSNAPSHOT DIALOGEX 26, 41, 140, 140
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_BORDER | WS_SYSMENU
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
END

View File

@ -0,0 +1,32 @@
// This file is part of Notepad++ project
// Copyright (C)2003 Don HO <don.h@free.fr>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the
// following:
// 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield.
// 3. Links to a library or executes a program that does any of the above.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#pragma once
#define IDD_DOCUMENTSNAPSHOT 3600

View File

@ -28,6 +28,7 @@
#include <stdio.h> #include <stdio.h>
#include <windows.h> #include <windows.h>
#include "StaticDialog.h" #include "StaticDialog.h"
#include "Common.h"
StaticDialog::~StaticDialog() StaticDialog::~StaticDialog()
{ {
@ -152,10 +153,9 @@ void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent)
if (!_hSelf) if (!_hSelf)
{ {
DWORD err = ::GetLastError(); generic_string errMsg = TEXT("CreateDialogParam() return NULL.\rGetLastError(): ");
char errMsg[256]; errMsg += GetLastErrorAsString();
sprintf(errMsg, "CreateDialogParam() return NULL.\rGetLastError() == %u", err); ::MessageBox(NULL, errMsg.c_str(), TEXT("In StaticDialog::create()"), MB_OK);
::MessageBoxA(NULL, errMsg, "In StaticDialog::create()", MB_OK);
return; return;
} }

View File

@ -155,10 +155,10 @@ void TabBar::activateAt(int index) const
::SendMessage(_hSelf, TCM_SETCURSEL, index, 0); ::SendMessage(_hSelf, TCM_SETCURSEL, index, 0);
TBHDR nmhdr; TBHDR nmhdr;
nmhdr.hdr.hwndFrom = _hSelf; nmhdr._hdr.hwndFrom = _hSelf;
nmhdr.hdr.code = TCN_SELCHANGE; nmhdr._hdr.code = TCN_SELCHANGE;
nmhdr.hdr.idFrom = reinterpret_cast<UINT_PTR>(this); nmhdr._hdr.idFrom = reinterpret_cast<UINT_PTR>(this);
nmhdr.tabOrigin = index; nmhdr._tabOrigin = index;
} }
@ -426,10 +426,10 @@ void TabBarPlus::doMultiLine()
void TabBarPlus::notify(int notifyCode, int tabIndex) void TabBarPlus::notify(int notifyCode, int tabIndex)
{ {
TBHDR nmhdr; TBHDR nmhdr;
nmhdr.hdr.hwndFrom = _hSelf; nmhdr._hdr.hwndFrom = _hSelf;
nmhdr.hdr.code = notifyCode; nmhdr._hdr.code = notifyCode;
nmhdr.hdr.idFrom = reinterpret_cast<UINT_PTR>(this); nmhdr._hdr.idFrom = reinterpret_cast<UINT_PTR>(this);
nmhdr.tabOrigin = tabIndex; nmhdr._tabOrigin = tabIndex;
::SendMessage(_hParent, WM_NOTIFY, 0, reinterpret_cast<LPARAM>(&nmhdr)); ::SendMessage(_hParent, WM_NOTIFY, 0, reinterpret_cast<LPARAM>(&nmhdr));
} }
@ -631,7 +631,6 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
return TRUE; return TRUE;
} }
//#define NPPM_INTERNAL_ISDRAGGING 40926
case WM_MOUSEMOVE : case WM_MOUSEMOVE :
{ {
if (_mightBeDragging && !_isDragging) if (_mightBeDragging && !_isDragging)

View File

@ -59,8 +59,8 @@ const TCHAR TABBAR_INACTIVETEXT[64] = TEXT("Inactive tabs");
struct TBHDR struct TBHDR
{ {
NMHDR hdr; NMHDR _hdr;
int tabOrigin; int _tabOrigin;
}; };

View File

@ -285,6 +285,7 @@ copy ..\src\contextMenu.xml ..\bin64\contextMenu.xml
<ClCompile Include="..\src\WinControls\DockingWnd\DockingSplitter.cpp" /> <ClCompile Include="..\src\WinControls\DockingWnd\DockingSplitter.cpp" />
<ClCompile Include="..\src\ScitillaComponent\DocTabView.cpp" /> <ClCompile Include="..\src\ScitillaComponent\DocTabView.cpp" />
<ClCompile Include="..\src\WinControls\DocumentMap\documentMap.cpp" /> <ClCompile Include="..\src\WinControls\DocumentMap\documentMap.cpp" />
<ClCompile Include="..\src\WinControls\DocumentMap\documentSnapshot.cpp" />
<ClCompile Include="..\src\EncodingMapper.cpp" /> <ClCompile Include="..\src\EncodingMapper.cpp" />
<ClCompile Include="..\src\WinControls\OpenSaveFileDialog\FileDialog.cpp" /> <ClCompile Include="..\src\WinControls\OpenSaveFileDialog\FileDialog.cpp" />
<ClCompile Include="..\src\WinControls\FindCharsInRange\FindCharsInRange.cpp" /> <ClCompile Include="..\src\WinControls\FindCharsInRange\FindCharsInRange.cpp" />
@ -494,6 +495,7 @@ copy ..\src\contextMenu.xml ..\bin64\contextMenu.xml
<ResourceCompile Include="..\src\ScitillaComponent\columnEditor.rc" /> <ResourceCompile Include="..\src\ScitillaComponent\columnEditor.rc" />
<ResourceCompile Include="..\src\WinControls\DockingWnd\DockingGUIWidget.rc" /> <ResourceCompile Include="..\src\WinControls\DockingWnd\DockingGUIWidget.rc" />
<ResourceCompile Include="..\src\WinControls\DocumentMap\documentMap.rc" /> <ResourceCompile Include="..\src\WinControls\DocumentMap\documentMap.rc" />
<ResourceCompile Include="..\src\WinControls\DocumentMap\documentSnapshot.rc" />
<ResourceCompile Include="..\src\WinControls\FileBrowser\fileBrowser.rc" /> <ResourceCompile Include="..\src\WinControls\FileBrowser\fileBrowser.rc" />
<ResourceCompile Include="..\src\WinControls\FindCharsInRange\findCharsInRange.rc" /> <ResourceCompile Include="..\src\WinControls\FindCharsInRange\findCharsInRange.rc" />
<ResourceCompile Include="..\src\ScitillaComponent\FindReplaceDlg.rc" /> <ResourceCompile Include="..\src\ScitillaComponent\FindReplaceDlg.rc" />
@ -556,6 +558,7 @@ copy ..\src\contextMenu.xml ..\bin64\contextMenu.xml
<ClInclude Include="..\src\WinControls\DockingWnd\DockingSplitter.h" /> <ClInclude Include="..\src\WinControls\DockingWnd\DockingSplitter.h" />
<ClInclude Include="..\src\ScitillaComponent\DocTabView.h" /> <ClInclude Include="..\src\ScitillaComponent\DocTabView.h" />
<ClInclude Include="..\src\WinControls\DocumentMap\documentMap.h" /> <ClInclude Include="..\src\WinControls\DocumentMap\documentMap.h" />
<ClInclude Include="..\src\WinControls\DocumentMap\documentSnapshot.h" />
<ClInclude Include="..\src\EncodingMapper.h" /> <ClInclude Include="..\src\EncodingMapper.h" />
<ClInclude Include="..\src\WinControls\OpenSaveFileDialog\FileDialog.h" /> <ClInclude Include="..\src\WinControls\OpenSaveFileDialog\FileDialog.h" />
<ClInclude Include="..\src\MISC\FileNameStringSplitter.h" /> <ClInclude Include="..\src\MISC\FileNameStringSplitter.h" />

View File

@ -274,6 +274,7 @@ copy ..\src\contextMenu.xml ..\bin64\contextMenu.xml
<ClCompile Include="..\src\WinControls\AnsiCharPanel\ansiCharPanel.cpp" /> <ClCompile Include="..\src\WinControls\AnsiCharPanel\ansiCharPanel.cpp" />
<ClCompile Include="..\src\ScitillaComponent\AutoCompletion.cpp" /> <ClCompile Include="..\src\ScitillaComponent\AutoCompletion.cpp" />
<ClCompile Include="..\src\WinControls\AnsiCharPanel\asciiListView.cpp" /> <ClCompile Include="..\src\WinControls\AnsiCharPanel\asciiListView.cpp" />
<ClCompile Include="..\src\WinControls\DocumentMap\documentSnapshot.cpp" />
<ClCompile Include="..\src\WinControls\Grid\BabyGrid.cpp" /> <ClCompile Include="..\src\WinControls\Grid\BabyGrid.cpp" />
<ClCompile Include="..\src\WinControls\Grid\BabyGridWrapper.cpp" /> <ClCompile Include="..\src\WinControls\Grid\BabyGridWrapper.cpp" />
<ClCompile Include="..\src\ScitillaComponent\Buffer.cpp" /> <ClCompile Include="..\src\ScitillaComponent\Buffer.cpp" />
@ -504,6 +505,7 @@ copy ..\src\contextMenu.xml ..\bin64\contextMenu.xml
<ResourceCompile Include="..\src\ScitillaComponent\columnEditor.rc" /> <ResourceCompile Include="..\src\ScitillaComponent\columnEditor.rc" />
<ResourceCompile Include="..\src\WinControls\DockingWnd\DockingGUIWidget.rc" /> <ResourceCompile Include="..\src\WinControls\DockingWnd\DockingGUIWidget.rc" />
<ResourceCompile Include="..\src\WinControls\DocumentMap\documentMap.rc" /> <ResourceCompile Include="..\src\WinControls\DocumentMap\documentMap.rc" />
<ResourceCompile Include="..\src\WinControls\DocumentMap\documentSnapshot.rc" />
<ResourceCompile Include="..\src\WinControls\FindCharsInRange\findCharsInRange.rc" /> <ResourceCompile Include="..\src\WinControls\FindCharsInRange\findCharsInRange.rc" />
<ResourceCompile Include="..\src\ScitillaComponent\FindReplaceDlg.rc" /> <ResourceCompile Include="..\src\ScitillaComponent\FindReplaceDlg.rc" />
<ResourceCompile Include="..\src\WinControls\FunctionList\functionListPanel.rc" /> <ResourceCompile Include="..\src\WinControls\FunctionList\functionListPanel.rc" />
@ -539,6 +541,8 @@ copy ..\src\contextMenu.xml ..\bin64\contextMenu.xml
<ClInclude Include="..\src\WinControls\AnsiCharPanel\ansiCharPanel.h" /> <ClInclude Include="..\src\WinControls\AnsiCharPanel\ansiCharPanel.h" />
<ClInclude Include="..\src\ScitillaComponent\AutoCompletion.h" /> <ClInclude Include="..\src\ScitillaComponent\AutoCompletion.h" />
<ClInclude Include="..\src\WinControls\AnsiCharPanel\asciiListView.h" /> <ClInclude Include="..\src\WinControls\AnsiCharPanel\asciiListView.h" />
<ClInclude Include="..\src\WinControls\DocumentMap\documentSnapshot.h" />
<ClInclude Include="..\src\WinControls\DocumentMap\documentSnapshot_rc.h" />
<ClInclude Include="..\src\WinControls\Grid\BabyGrid.h" /> <ClInclude Include="..\src\WinControls\Grid\BabyGrid.h" />
<ClInclude Include="..\src\WinControls\Grid\BabyGridWrapper.h" /> <ClInclude Include="..\src\WinControls\Grid\BabyGridWrapper.h" />
<ClInclude Include="..\src\ScitillaComponent\Buffer.h" /> <ClInclude Include="..\src\ScitillaComponent\Buffer.h" />