Add document snapshot feature (in progress)
This commit is contained in:
parent
f57a565b6b
commit
20e669ff01
@ -634,6 +634,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
||||
_md5FromFilesDlg.init(_pPublicInterface->getHinst(), hwnd);
|
||||
_md5FromTextDlg.init(_pPublicInterface->getHinst(), hwnd);
|
||||
_runMacroDlg.init(_pPublicInterface->getHinst(), hwnd);
|
||||
_documentSnapshot.init(_pPublicInterface->getHinst(), hwnd);
|
||||
|
||||
//--User Define Dialog Section--//
|
||||
int uddStatus = nppGUI._userDefineDlgStatus;
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include "lesDlgs.h"
|
||||
#include "pluginsAdmin.h"
|
||||
#include "localization.h"
|
||||
#include "documentSnapshot.h"
|
||||
#include "md5Dlgs.h"
|
||||
#include <vector>
|
||||
#include <iso646.h>
|
||||
@ -282,6 +283,7 @@ private:
|
||||
PreferenceDlg _preference;
|
||||
FindCharsInRangeDlg _findCharsInRangeDlg;
|
||||
PluginsAdminDlg _pluginsAdminDlg;
|
||||
DocumentSnapshot _documentSnapshot;
|
||||
|
||||
// a handle list of all the Notepad++ dialogs
|
||||
std::vector<HWND> _hModelessDlgs;
|
||||
|
@ -70,6 +70,7 @@ void Notepad_plus::command(int id)
|
||||
case IDM_FILE_NEW:
|
||||
{
|
||||
fileNew();
|
||||
|
||||
/*
|
||||
bool isFirstTime = not _pluginsAdminDlg.isCreated();
|
||||
_pluginsAdminDlg.setPluginsManager(&_pluginsManager);
|
||||
@ -2572,6 +2573,7 @@ void Notepad_plus::command(int id)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (doAboutDlg)
|
||||
{
|
||||
bool isFirstTime = !_aboutDlg.isCreated();
|
||||
|
@ -1601,7 +1601,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode)
|
||||
}
|
||||
|
||||
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);
|
||||
if (session._mainViewFiles[i]._encoding != -1)
|
||||
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->setMapPosition(session._subViewFiles[k]._mapPos._firstVisibleDocLine, session._subViewFiles[k]._mapPos._lastVisibleDocLine, session._subViewFiles[k]._mapPos._nbLine, session._subViewFiles[k]._mapPos._higherPos);
|
||||
if (typeToSet == L_USER) {
|
||||
if (!lstrcmp(pLn, TEXT("User Defined"))) {
|
||||
buf->setMapPosition(session._subViewFiles[k]._mapPos);
|
||||
if (typeToSet == L_USER)
|
||||
{
|
||||
if (!lstrcmp(pLn, TEXT("User Defined")))
|
||||
{
|
||||
pLn = TEXT(""); //default user defined
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
DocTabView *pTabDocView = isFromPrimary ? &_mainDocTab : (isFromSecondary ? &_subDocTab : nullptr);
|
||||
if (pTabDocView)
|
||||
{
|
||||
BufferID id = pTabDocView->getBufferByIndex(tbHdr->tabOrigin);
|
||||
BufferID id = pTabDocView->getBufferByIndex(tbHdr->_tabOrigin);
|
||||
Buffer *pBuf = MainFileManager->getBufferByID(id);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
case TCN_MOUSELEAVING:
|
||||
{
|
||||
/*
|
||||
///*
|
||||
if (_pDocMap && (!_pDocMap->isClosed()) && _pDocMap->isVisible())
|
||||
{
|
||||
_pDocMap->reloadMap();
|
||||
@ -190,7 +221,13 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
|
||||
_pDocMap->setTemporarilyShowing(false);
|
||||
}
|
||||
*/
|
||||
//*/
|
||||
|
||||
|
||||
if (true)
|
||||
{
|
||||
_documentSnapshot.display(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -287,7 +324,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
|
||||
case TCN_TABDELETE:
|
||||
{
|
||||
int index = tabNotification->tabOrigin;
|
||||
int index = tabNotification->_tabOrigin;
|
||||
BufferID bufferToClose = notifyDocTab->getBufferByIndex(index);
|
||||
Buffer * buf = MainFileManager->getBufferByID(bufferToClose);
|
||||
int iView = isFromPrimary?MAIN_VIEW:SUB_VIEW;
|
||||
@ -316,6 +353,9 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
else
|
||||
break;
|
||||
|
||||
// save map position before switch to a new document
|
||||
_documentSnapshot.saveCurrentSnapshot(*_pEditView);
|
||||
|
||||
switchEditViewTo(iView);
|
||||
BufferID bufid = _pDocTab->getBufferByIndex(_pDocTab->getCurrentTabIndex());
|
||||
if (bufid != BUFFER_INVALID)
|
||||
@ -324,6 +364,12 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
activateBuffer(bufid, iView);
|
||||
_isFolding = false;
|
||||
}
|
||||
|
||||
if (true)
|
||||
{
|
||||
_documentSnapshot.display(false);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2016,6 +2016,18 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p
|
||||
mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapHigherPos"), &mapPosVal);
|
||||
if (mapPosStr)
|
||||
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;
|
||||
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("mapNbLine"), viewSessionFiles[i]._mapPos._nbLine);
|
||||
(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)
|
||||
{
|
||||
|
@ -144,6 +144,10 @@ struct MapPosition
|
||||
int32_t _lastVisibleDocLine = -1;
|
||||
int32_t _nbLine = -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; };
|
||||
};
|
||||
|
||||
|
@ -46,14 +46,8 @@ static const int LF = 0x0A;
|
||||
|
||||
long Buffer::_recentTagCtr = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace // anonymous
|
||||
{
|
||||
|
||||
static EolType getEOLFormatForm(const char* const data, size_t length, EolType defvalue = EolType::osdefault)
|
||||
{
|
||||
assert(length == 0 or data != nullptr && "invalid buffer for getEOLFormatForm()");
|
||||
@ -74,19 +68,12 @@ namespace // anonymous
|
||||
|
||||
return defvalue; // fallback unknown
|
||||
}
|
||||
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
|
||||
|
||||
Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const TCHAR *fileName)
|
||||
// type must be either DOC_REGULAR or DOC_UNNAMED
|
||||
: _pManager(pManager)
|
||||
, _id(id)
|
||||
, _doc(doc)
|
||||
, _lang(L_TEXT)
|
||||
: _pManager(pManager) , _id(id), _doc(doc), _lang(L_TEXT)
|
||||
{
|
||||
NppParameters* pNppParamInst = NppParameters::getInstance();
|
||||
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()
|
||||
|
@ -348,15 +348,13 @@ public:
|
||||
bool isMonitoringOn() const { return _isMonitoringOn; };
|
||||
void updateTimeStamp();
|
||||
void reload();
|
||||
|
||||
void setMapPosition(int32_t firstVisibleDocLine, int32_t lastVisibleDocLine, int32_t nbLine, int32_t higherPos);
|
||||
void setMapPosition(const MapPosition & mapPosition) { _mapPosition = mapPosition; };
|
||||
MapPosition getMapPosition() { return _mapPosition; };
|
||||
|
||||
private:
|
||||
int indexOfReference(const ScintillaEditView * identifier) const;
|
||||
|
||||
void setStatus(DocFileStatus status)
|
||||
{
|
||||
void setStatus(DocFileStatus status) {
|
||||
_currentStatus = status;
|
||||
doNotify(BufferChangeStatus);
|
||||
}
|
||||
|
@ -229,3 +229,4 @@ void DocTabView::reSizeTo(RECT & rc)
|
||||
_pView->reSizeTo(rc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,10 @@ public :
|
||||
|
||||
virtual void reSizeTo(RECT & rc);
|
||||
|
||||
const ScintillaEditView* getScintillaEditView() const {
|
||||
return _pView;
|
||||
};
|
||||
|
||||
private :
|
||||
ScintillaEditView *_pView;
|
||||
static bool _hideTabBarStatus;
|
||||
|
@ -25,14 +25,9 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// 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"
|
||||
#endif //COLUMNEDITOR_RC_H
|
||||
|
||||
#include "StaticDialog.h"
|
||||
|
||||
class ScintillaEditView;
|
||||
@ -74,4 +69,4 @@ private :
|
||||
|
||||
|
||||
};
|
||||
#endif// COLUMNEDITOR_H
|
||||
|
||||
|
@ -257,9 +257,13 @@ void DocumentMap::scrollMap(ScintillaEditView *editView)
|
||||
lowerY = nbLine * lineHeight + higherY;
|
||||
}
|
||||
|
||||
char toto[256];
|
||||
sprintf(toto, "MAP : %d & %d\n\n", higherY, lowerY);
|
||||
OutputDebugStringA(toto);
|
||||
|
||||
// set current map position in buffer
|
||||
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 *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));
|
||||
|
||||
// Update view zone in map
|
||||
_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
|
||||
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 nbLineMap = _pScintillaEditView->execute(SCI_LINESONSCREEN, firstVisibleDocLineMap);
|
||||
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);
|
||||
lowerY = mapPos._nbLine * lineHeight + higherY;
|
||||
}
|
||||
//sprintf(toto, "MAP : %d & %d\n\n", higherY, lowerY);
|
||||
//OutputDebugStringA(toto);
|
||||
|
||||
// Update view zone in map
|
||||
_vzDlg.drawZone(static_cast<long>(higherY), static_cast<long>(lowerY));
|
||||
|
@ -57,8 +57,7 @@ public :
|
||||
|
||||
void doDialog();
|
||||
|
||||
virtual void destroy() {
|
||||
};
|
||||
virtual void destroy() {};
|
||||
|
||||
void drawZone(long hY, long lY) {
|
||||
_higherY = hY;
|
||||
|
183
PowerEditor/src/WinControls/DocumentMap/documentSnapshot.cpp
Normal file
183
PowerEditor/src/WinControls/DocumentMap/documentSnapshot.cpp
Normal 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);
|
||||
}
|
||||
}
|
65
PowerEditor/src/WinControls/DocumentMap/documentSnapshot.h
Normal file
65
PowerEditor/src/WinControls/DocumentMap/documentSnapshot.h
Normal 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;
|
||||
};
|
37
PowerEditor/src/WinControls/DocumentMap/documentSnapshot.rc
Normal file
37
PowerEditor/src/WinControls/DocumentMap/documentSnapshot.rc
Normal 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
|
@ -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
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include "StaticDialog.h"
|
||||
#include "Common.h"
|
||||
|
||||
StaticDialog::~StaticDialog()
|
||||
{
|
||||
@ -152,10 +153,9 @@ void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent)
|
||||
|
||||
if (!_hSelf)
|
||||
{
|
||||
DWORD err = ::GetLastError();
|
||||
char errMsg[256];
|
||||
sprintf(errMsg, "CreateDialogParam() return NULL.\rGetLastError() == %u", err);
|
||||
::MessageBoxA(NULL, errMsg, "In StaticDialog::create()", MB_OK);
|
||||
generic_string errMsg = TEXT("CreateDialogParam() return NULL.\rGetLastError(): ");
|
||||
errMsg += GetLastErrorAsString();
|
||||
::MessageBox(NULL, errMsg.c_str(), TEXT("In StaticDialog::create()"), MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -155,10 +155,10 @@ void TabBar::activateAt(int index) const
|
||||
::SendMessage(_hSelf, TCM_SETCURSEL, index, 0);
|
||||
|
||||
TBHDR nmhdr;
|
||||
nmhdr.hdr.hwndFrom = _hSelf;
|
||||
nmhdr.hdr.code = TCN_SELCHANGE;
|
||||
nmhdr.hdr.idFrom = reinterpret_cast<UINT_PTR>(this);
|
||||
nmhdr.tabOrigin = index;
|
||||
nmhdr._hdr.hwndFrom = _hSelf;
|
||||
nmhdr._hdr.code = TCN_SELCHANGE;
|
||||
nmhdr._hdr.idFrom = reinterpret_cast<UINT_PTR>(this);
|
||||
nmhdr._tabOrigin = index;
|
||||
}
|
||||
|
||||
|
||||
@ -426,10 +426,10 @@ void TabBarPlus::doMultiLine()
|
||||
void TabBarPlus::notify(int notifyCode, int tabIndex)
|
||||
{
|
||||
TBHDR nmhdr;
|
||||
nmhdr.hdr.hwndFrom = _hSelf;
|
||||
nmhdr.hdr.code = notifyCode;
|
||||
nmhdr.hdr.idFrom = reinterpret_cast<UINT_PTR>(this);
|
||||
nmhdr.tabOrigin = tabIndex;
|
||||
nmhdr._hdr.hwndFrom = _hSelf;
|
||||
nmhdr._hdr.code = notifyCode;
|
||||
nmhdr._hdr.idFrom = reinterpret_cast<UINT_PTR>(this);
|
||||
nmhdr._tabOrigin = tabIndex;
|
||||
::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;
|
||||
}
|
||||
|
||||
//#define NPPM_INTERNAL_ISDRAGGING 40926
|
||||
case WM_MOUSEMOVE :
|
||||
{
|
||||
if (_mightBeDragging && !_isDragging)
|
||||
|
@ -59,8 +59,8 @@ const TCHAR TABBAR_INACTIVETEXT[64] = TEXT("Inactive tabs");
|
||||
|
||||
struct TBHDR
|
||||
{
|
||||
NMHDR hdr;
|
||||
int tabOrigin;
|
||||
NMHDR _hdr;
|
||||
int _tabOrigin;
|
||||
};
|
||||
|
||||
|
||||
|
@ -285,6 +285,7 @@ copy ..\src\contextMenu.xml ..\bin64\contextMenu.xml
|
||||
<ClCompile Include="..\src\WinControls\DockingWnd\DockingSplitter.cpp" />
|
||||
<ClCompile Include="..\src\ScitillaComponent\DocTabView.cpp" />
|
||||
<ClCompile Include="..\src\WinControls\DocumentMap\documentMap.cpp" />
|
||||
<ClCompile Include="..\src\WinControls\DocumentMap\documentSnapshot.cpp" />
|
||||
<ClCompile Include="..\src\EncodingMapper.cpp" />
|
||||
<ClCompile Include="..\src\WinControls\OpenSaveFileDialog\FileDialog.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\WinControls\DockingWnd\DockingGUIWidget.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\FindCharsInRange\findCharsInRange.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\ScitillaComponent\DocTabView.h" />
|
||||
<ClInclude Include="..\src\WinControls\DocumentMap\documentMap.h" />
|
||||
<ClInclude Include="..\src\WinControls\DocumentMap\documentSnapshot.h" />
|
||||
<ClInclude Include="..\src\EncodingMapper.h" />
|
||||
<ClInclude Include="..\src\WinControls\OpenSaveFileDialog\FileDialog.h" />
|
||||
<ClInclude Include="..\src\MISC\FileNameStringSplitter.h" />
|
||||
|
@ -274,6 +274,7 @@ copy ..\src\contextMenu.xml ..\bin64\contextMenu.xml
|
||||
<ClCompile Include="..\src\WinControls\AnsiCharPanel\ansiCharPanel.cpp" />
|
||||
<ClCompile Include="..\src\ScitillaComponent\AutoCompletion.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\BabyGridWrapper.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\WinControls\DockingWnd\DockingGUIWidget.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\ScitillaComponent\FindReplaceDlg.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\ScitillaComponent\AutoCompletion.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\BabyGridWrapper.h" />
|
||||
<ClInclude Include="..\src\ScitillaComponent\Buffer.h" />
|
||||
|
Loading…
Reference in New Issue
Block a user