Skip to content

Commit

Permalink
[NEW_FEDATURE] Implement VerticalFileSwitcher feature (in progress).
Browse files Browse the repository at this point in the history
- Notepad-plus svn trunk @ 774
  • Loading branch information
donho committed Jun 13, 2011
1 parent 9bd1690 commit 5d19105
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 243 deletions.
19 changes: 13 additions & 6 deletions PowerEditor/installer/nativeLang/finnish.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252" ?>
<!--
Suomenkielinen lokalisointi Notepad++ 5.8.7 / Finnish localization
Viimeisin muokkaaja: Teijo, 11.2.2011 ver II
Suomenkielinen lokalisointi Notepad++ 5.9 / Finnish localization
Viimeisin muokkaaja: Teijo, 31.3.2011
Lähetä käännösvirhehavaintosi ja korjausehdotuksesi osoitteeseen teijo(at)nettilinja.fi
Asennusohjeet => https://sourceforge.net/forum/message.php?msg_id=5691520
-->
Expand Down Expand Up @@ -34,13 +34,15 @@ Asennusohjeet => https://sourceforge.net/forum/message.php?msg_id=5691520
<Item posX="1" posY="14" name="Automaattiset täydennykset"/>
<Item posX="1" posY="15" name="Rivin loppumerkit (EOL)"/>
<Item posX="1" posY="16" name="Välilyöntien käsittely"/>
<Item posX="1" posY="17" name="Liitä erikoistekstiä"/>

<Item posX="2" posY="16" name="Samanlaisten korostaminen"/>
<Item posX="2" posY="17" name="Korostusten poistaminen"/>
<Item posX="2" posY="18" name="Eteenpäin korostustyyliin"/>
<Item posX="2" posY="19" name="Taaksepäin korostustyyliin"/>
<Item posX="2" posY="21" name="Kirjanmerkit"/>

<Item posX="3" posY="4" name="Erityismerkit"/>
<Item posX="3" posY="5" name="Suurennus"/>
<Item posX="3" posY="6" name="Näkymät ja istunnot"/>
<Item posX="3" posY="16" name="Sulje lohkot tasolle"/>
Expand Down Expand Up @@ -122,6 +124,9 @@ Asennusohjeet => https://sourceforge.net/forum/message.php?msg_id=5691520
<Item id="42034" name="&amp;Sarake-editori..."/>
<Item id="42035" name="Kommentoi (rivimoodi)"/>
<Item id="42036" name="Poista kommentointi (rivimoodi)"/>
<Item id="42037" name="Sarake-editointitila"/>
<Item id="42038" name="Liitä HTML-sisältö"/>
<Item id="42039" name="Liitä RTF-sisältö"/>
<Item id="42040" name="Avaa kaikki &amp;viimeisimmät tiedostot"/>
<Item id="42041" name="Ty&amp;hjennä viimeisimpien tiedostojen luettelo"/>
<Item id="42042" name="Poista välilyönnit rivien aluista"/>
Expand All @@ -130,7 +135,9 @@ Asennusohjeet => https://sourceforge.net/forum/message.php?msg_id=5691520
<Item id="42045" name="Poista tarpeettomat välilyönnit ja loppumerkit"/>
<Item id="42046" name="Korvaa tabuloinnit välilyönneillä"/>
<Item id="42047" name="Korvaa välilyönnit tabuloinneilla"/>

<Item id="42048" name="Kopioi binäärisisältö"/>
<Item id="42049" name="Leikkaa binäärisisältö"/>
<Item id="42050" name="Liitä binäärisisältö"/>
<Item id="43001" name="&amp;Etsi..."/>
<Item id="43002" name="Etsi &amp;seuraava"/>
<Item id="43003" name="Korvaa..."/>
Expand Down Expand Up @@ -177,9 +184,9 @@ Asennusohjeet => https://sourceforge.net/forum/message.php?msg_id=5691520
<Item id="43045" name="Aktivoi hakutulosikkuna"/>
<Item id="43046" name="Seuraava hakutulos"/>
<Item id="43047" name="Edellinen hakutulos"/>
<Item id ="43048" name = "Korosta ja etsi seuraava"/>
<Item id ="43049" name = "Korosta ja etsi edellinen"/>
<Item id ="43050" name = "Kaikkien kirjanmerkkien käänteistäminen"/>
<Item id ="43048" name="Korosta ja etsi seuraava"/>
<Item id ="43049" name="Korosta ja etsi edellinen"/>
<Item id ="43050" name="Kaikkien kirjanmerkkien käänteistäminen"/>

<Item id="44009" name="Ruudunkaappaustila"/>
<Item id="44010" name="Sulje kaikki lohkot"/>
Expand Down
150 changes: 87 additions & 63 deletions PowerEditor/installer/nativeLang/serbianCyrillic.xml

Large diffs are not rendered by default.

20 changes: 15 additions & 5 deletions PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2673,26 +2673,30 @@ void Notepad_plus::loadBufferIntoView(BufferID id, int whichOne, bool dontClose)
tabToOpen->setBuffer(0, id); //index 0 since only one open
activateBuffer(id, whichOne); //activate. DocTab already activated but not a problem
MainFileManager->closeBuffer(idToClose, viewToOpen); //delete the buffer
if (_pFileSwitcherPanel)
_pFileSwitcherPanel->closeItem((int)idToClose);
} else {
tabToOpen->addBuffer(id);
}
}

void Notepad_plus::removeBufferFromView(BufferID id, int whichOne) {
bool Notepad_plus::removeBufferFromView(BufferID id, int whichOne) {
DocTabView * tabToClose = (whichOne == MAIN_VIEW)?&_mainDocTab:&_subDocTab;
ScintillaEditView * viewToClose = (whichOne == MAIN_VIEW)?&_mainEditView:&_subEditView;

//check if buffer exists
int index = tabToClose->getIndexByBuffer(id);
if (index == -1) //doesn't exist, done
return;
return false;

Buffer * buf = MainFileManager->getBufferByID(id);

//Cannot close doc if last and clean
if (tabToClose->nbItem() == 1) {
if (!buf->isDirty() && buf->isUntitled()) {
return; //done
if (tabToClose->nbItem() == 1)
{
if (!buf->isDirty() && buf->isUntitled())
{
return false;
}
}

Expand All @@ -2719,6 +2723,7 @@ void Notepad_plus::removeBufferFromView(BufferID id, int whichOne) {
}

MainFileManager->closeBuffer(id, viewToClose);
return true;
}

int Notepad_plus::switchEditViewTo(int gid)
Expand Down Expand Up @@ -4225,6 +4230,11 @@ void Notepad_plus::notifyBufferActivated(BufferID bufid, int view)
scnN.nmhdr.idFrom = (uptr_t)bufid;
_pluginsManager.notify(&scnN);

if (_pFileSwitcherPanel)
{
_pFileSwitcherPanel->activateItem((int)bufid);
}

_linkTriggered = true;
}

Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/Notepad_plus.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ friend class Notepad_plus_Window;
void docOpenInNewInstance(FileTransferMode mode, int x = 0, int y = 0);

void loadBufferIntoView(BufferID id, int whichOne, bool dontClose = false); //Doesnt _activate_ the buffer
void removeBufferFromView(BufferID id, int whichOne); //Activates alternative of possible, or creates clean document if not clean already
bool removeBufferFromView(BufferID id, int whichOne); //Activates alternative of possible, or creates clean document if not clean already

bool activateBuffer(BufferID id, int whichOne); //activate buffer in that view if found
void notifyBufferActivated(BufferID bufid, int view);
Expand Down
7 changes: 5 additions & 2 deletions PowerEditor/src/NppCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "ShortcutMapper.h"
#include "TaskListDlg.h"
#include "clipboardFormats.h"

#include "VerticalFileSwitcher.h"

void Notepad_plus::macroPlayback(Macro macro)
{
Expand Down Expand Up @@ -847,6 +847,8 @@ void Notepad_plus::command(int id)
{
Buffer * buf = _pEditView->getCurrentBuffer();
buf->setUserReadOnly(!buf->getUserReadOnly());
if (_pFileSwitcherPanel)
_pFileSwitcherPanel->setItemIconStatus((int)buf);
}
break;

Expand All @@ -858,8 +860,9 @@ void Notepad_plus::command(int id)
dwFileAttribs ^= FILE_ATTRIBUTE_READONLY;

::SetFileAttributes(buf->getFullPathName(), dwFileAttribs);

buf->setFileReadOnly(false);
if (_pFileSwitcherPanel)
_pFileSwitcherPanel->setItemIconStatus((int)buf);
}
break;

Expand Down
18 changes: 11 additions & 7 deletions PowerEditor/src/NppIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encodi
scnN.nmhdr.code = NPPN_FILEOPENED;
_pluginsManager.notify(&scnN);
if (_pFileSwitcherPanel)
_pFileSwitcherPanel->newItem((int)buf, fileName);
_pFileSwitcherPanel->newItem((int)buf);
}
else
{
Expand Down Expand Up @@ -202,7 +202,7 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encodi
pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
isWow64Off = false;
}
return buffer;;
return buffer;
}

bool Notepad_plus::doReload(BufferID id, bool alert)
Expand Down Expand Up @@ -317,17 +317,20 @@ void Notepad_plus::doClose(BufferID id, int whichOne) {
int nrDocs = whichOne==MAIN_VIEW?(_mainDocTab.nbItem()):(_subDocTab.nbItem());

//Do all the works
removeBufferFromView(id, whichOne);
bool isBufRemoved = removeBufferFromView(id, whichOne);
if (nrDocs == 1 && canHideView(whichOne))
{ //close the view if both visible
hideView(whichOne);
}

// Notify plugins that current file is closed
scnN.nmhdr.code = NPPN_FILECLOSED;
_pluginsManager.notify(&scnN);
if (_pFileSwitcherPanel)
_pFileSwitcherPanel->closeItem((int)id);
if (isBufRemoved)
{
scnN.nmhdr.code = NPPN_FILECLOSED;
_pluginsManager.notify(&scnN);
if (_pFileSwitcherPanel)
_pFileSwitcherPanel->closeItem((int)id);
}
return;
}

Expand Down Expand Up @@ -881,6 +884,7 @@ void Notepad_plus::fileOpen()
void Notepad_plus::fileNew()
{
BufferID newBufID = MainFileManager->newEmptyDocument();

loadBufferIntoView(newBufID, currentView(), true); //true, because we want multiple new files if possible
activateBuffer(newBufID, currentView());
}
Expand Down
146 changes: 8 additions & 138 deletions PowerEditor/src/NppNotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "precompiledHeaders.h"
#include "Notepad_plus_Window.h"
#include "xmlMatchedTagsHighlighter.h"
#include "VerticalFileSwitcher.h"

BOOL Notepad_plus::notify(SCNotification *notification)
{
Expand Down Expand Up @@ -52,142 +53,6 @@ BOOL Notepad_plus::notify(SCNotification *notification)
{
prevWasEdit = false;
}
/*
if (!_isFileOpening && (isFromPrimary || isFromSecondary) && _pEditView->hasMarginShowed(ScintillaEditView::_SC_MARGE_MODIFMARKER))
{
bool isProcessed = false;
int fromLine = _pEditView->execute(SCI_LINEFROMPOSITION, notification->position);
pair<size_t, bool> undolevel = _pEditView->getLineUndoState(fromLine);
if ((notification->modificationType & (SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT)) &&
(notification->modificationType & SC_PERFORMED_USER))
{
//printStr(TEXT("user type"));
_pEditView->setLineUndoState(fromLine, undolevel.first+1);
_pEditView->execute(SCI_MARKERADD, fromLine, MARK_LINEMODIFIEDUNSAVED);
_pEditView->execute(undolevel.second?SCI_MARKERADD:SCI_MARKERDELETE, fromLine, MARK_LINEMODIFIEDSAVED);
if (notification->linesAdded > 0)
{
for (int i = 0 ; i < notification->linesAdded ; i++)
{
++fromLine;
_pEditView->execute(SCI_MARKERADD, fromLine, MARK_LINEMODIFIEDUNSAVED);
pair<size_t, bool> modifInfo = _pEditView->getLineUndoState(fromLine);
_pEditView->execute(modifInfo.second?SCI_MARKERADD:SCI_MARKERDELETE, fromLine, MARK_LINEMODIFIEDSAVED);
}
}
}
if ((notification->modificationType & (SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT)) &&
(notification->modificationType & SC_PERFORMED_REDO) &&
(notification->modificationType & SC_MULTISTEPUNDOREDO))
{
//printStr(TEXT("redo multiple"));
isProcessed = true;
_pEditView->setLineUndoState(fromLine, undolevel.first+1);
_pEditView->execute(SCI_MARKERADD, fromLine, MARK_LINEMODIFIEDUNSAVED);
if (notification->linesAdded > 0)
{
for (int i = 0 ; i < notification->linesAdded ; i++)
{
++fromLine;
_pEditView->execute(SCI_MARKERADD, fromLine, MARK_LINEMODIFIEDUNSAVED);
pair<size_t, bool> modifInfo = _pEditView->getLineUndoState(fromLine);
_pEditView->execute(modifInfo.second?SCI_MARKERADD:SCI_MARKERDELETE, fromLine, MARK_LINEMODIFIEDSAVED);
}
}
}
if ((notification->modificationType & (SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT)) &&
(notification->modificationType & SC_PERFORMED_UNDO) &&
(notification->modificationType & SC_MULTISTEPUNDOREDO))
{
//printStr(TEXT("undo multiple"));
isProcessed = true;
--undolevel.first;
if (undolevel.first == 0)
{
_pEditView->execute(SCI_MARKERDELETE, fromLine, MARK_LINEMODIFIEDUNSAVED);
}
else
{
_pEditView->execute(SCI_MARKERADD, fromLine, MARK_LINEMODIFIEDUNSAVED);
}
_pEditView->execute(undolevel.second?SCI_MARKERADD:SCI_MARKERDELETE, fromLine, MARK_LINEMODIFIEDSAVED);
_pEditView->setLineUndoState(fromLine, undolevel.first);
if (notification->linesAdded > 0)
{
for (int i = fromLine + 1 ; i < fromLine + notification->linesAdded ; i++)
{
pair<size_t, bool> level = _pEditView->getLineUndoState(i);
if (level.first > 0)
_pEditView->execute(SCI_MARKERADD, i, MARK_LINEMODIFIEDUNSAVED);
_pEditView->execute(level.second?SCI_MARKERADD:SCI_MARKERDELETE, fromLine, MARK_LINEMODIFIEDSAVED);
}
}
}
if ((notification->modificationType & (SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT)) &&
(notification->modificationType & SC_PERFORMED_REDO) &&
(notification->modificationType & SC_LASTSTEPINUNDOREDO) && !isProcessed)
{
//printStr(TEXT("redo LASTO"));
_pEditView->setLineUndoState(fromLine, undolevel.first+1);
_pEditView->execute(SCI_MARKERADD, fromLine, MARK_LINEMODIFIEDUNSAVED);
_pEditView->execute(undolevel.second?SCI_MARKERADD:SCI_MARKERDELETE, fromLine, MARK_LINEMODIFIEDSAVED);
if (notification->linesAdded > 0)
{
for (int i = 0 ; i < notification->linesAdded ; i++)
{
++fromLine;
_pEditView->execute(SCI_MARKERADD, fromLine, MARK_LINEMODIFIEDUNSAVED);
pair<size_t, bool> modifInfo = _pEditView->getLineUndoState(fromLine);
_pEditView->execute(modifInfo.second?SCI_MARKERADD:SCI_MARKERDELETE, fromLine, MARK_LINEMODIFIEDSAVED);
}
}
}
if ((notification->modificationType & (SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT)) &&
(notification->modificationType & SC_PERFORMED_UNDO) &&
(notification->modificationType & SC_LASTSTEPINUNDOREDO) && !isProcessed)
{
//printStr(TEXT("undo LASTO"));
--undolevel.first;
if (undolevel.first == 0)
{
_pEditView->execute(SCI_MARKERDELETE, fromLine, MARK_LINEMODIFIEDUNSAVED);
}
else
{
_pEditView->execute(SCI_MARKERADD, fromLine, MARK_LINEMODIFIEDUNSAVED);
}
_pEditView->execute(undolevel.second?SCI_MARKERADD:SCI_MARKERDELETE, fromLine, MARK_LINEMODIFIEDSAVED);
_pEditView->setLineUndoState(fromLine, undolevel.first);
if (notification->linesAdded > 0)
{
for (int i = fromLine + 1 ; i < fromLine + notification->linesAdded ; i++)
{
pair<size_t, bool> level = _pEditView->getLineUndoState(i);
if (level.first > 0)
_pEditView->execute(SCI_MARKERADD, i, MARK_LINEMODIFIEDUNSAVED);
_pEditView->execute(level.second?SCI_MARKERADD:SCI_MARKERDELETE, fromLine, MARK_LINEMODIFIEDSAVED);
}
}
}
}
*/
}
break;

Expand Down Expand Up @@ -215,8 +80,13 @@ BOOL Notepad_plus::notify(SCNotification *notification)
break;
}
}
buf->setDirty(notification->nmhdr.code == SCN_SAVEPOINTLEFT);
break; }
bool isDirty = notification->nmhdr.code == SCN_SAVEPOINTLEFT;
buf->setDirty(isDirty);
if (_pFileSwitcherPanel)
_pFileSwitcherPanel->setItemIconStatus((int)buf);

break;
}

case SCN_MODIFYATTEMPTRO :
// on fout rien
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,6 @@ void VerticalFileSwitcher::activateDoc(int i) const
int view2set = docPosInfo >> 30;
int index2Switch = (docPosInfo << 2) >> 2 ;

//int view2set = _fileListView.getViewInfoFromIndex(i);
//int index2Switch = _fileListView.getDocIndexInfoFromIndex(i);
::SendMessage(_hParent, NPPM_ACTIVATEDOC, view2set, index2Switch);
}

int VerticalFileSwitcher::newItem(int bufferID, const TCHAR *fn)
{
return _fileListView.newItem(bufferID, fn);
}

int VerticalFileSwitcher::closeItem(int bufferID)
{
return _fileListView.closeItem(bufferID);
}

0 comments on commit 5d19105

Please sign in to comment.