[NEW_FEATURE] Add hide lines feature (not yet finished).

Fix the Scintilla Transpose function bug (Ctrl+Shift+Down in npp).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@28 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2007-09-10 01:27:44 +00:00
parent 07ac344588
commit 1388b2282b
12 changed files with 143 additions and 52 deletions

View File

@ -17,13 +17,16 @@
; Define the application name
!define APPNAME "Notepad++"
!define APPNAMEANDVERSION "Notepad++ v4.2.2"
!define APPNAMEANDVERSION "Notepad++ v4.3"
!define VERSION_MAJOR 4
!define VERSION_MINOR 3
; Main Install settings
Name "${APPNAMEANDVERSION}"
InstallDir "$PROGRAMFILES\Notepad++"
InstallDirRegKey HKLM "Software\${APPNAME}" ""
OutFile "..\bin\npp.4.2.2.Installer.exe"
OutFile "..\bin\npp.4.3.Installer.exe"

View File

@ -60,7 +60,7 @@ bool PluginsManager::loadPlugins(const char *dir)
pi->_hLib = ::LoadLibrary(dllNames[i].c_str());
if (!pi->_hLib)
throw string("Load Library is failed");
throw string("Load Library is failed.\nMake \"Runtime Library\" setting of this project as \"Multi-threaded(/MT)\" may cure this problem.");
pi->_pFuncSetInfo = (PFUNCSETINFO)GetProcAddress(pi->_hLib, "setInfo");

View File

@ -1832,13 +1832,13 @@ BOOL Notepad_plus::notify(SCNotification *notification)
{
int lineClick = int(_pEditView->execute(SCI_LINEFROMPOSITION, notification->position));
if (!showLines(lineClick))
bookmarkToggle(lineClick);
}
break;
}
case SCN_CHARADDED:
charAdded(static_cast<char>(notification->ch));
break;
@ -2553,7 +2553,7 @@ void Notepad_plus::command(int id)
if (lt == L_TXT)
_pEditView->defineDocType(L_CPP);
_pEditView->defineDocType(lt);
_pEditView->execute(SCI_MARKERDELETEALL, MARK_SYMBOLE);
_pEditView->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
break;
}
@ -2693,11 +2693,6 @@ void Notepad_plus::command(int id)
case IDM_EDIT_DUP_LINE:
_pEditView->execute(SCI_LINEDUPLICATE);
break;
/*
case IDM_EDIT_TRANSPOSE_LINE:
_pEditView->execute(SCI_LINETRANSPOSE);
break;
*/
case IDM_EDIT_SPLIT_LINES:
_pEditView->execute(SCI_TARGETFROMSELECTION);
@ -3030,10 +3025,27 @@ void Notepad_plus::command(int id)
case IDM_VIEW_WRAP_SYMBOL:
{
_pEditView->showWrapSymbol(!_pEditView->isWrapSymbolVisible());
//_toolBar.setCheck(IDM_VIEW_WRAP, _pEditView->isWrap());
checkMenuItem(IDM_VIEW_WRAP_SYMBOL, _pEditView->isWrapSymbolVisible());
break;
}
case IDM_VIEW_HIDELINES:
{
CharacterRange range = _pEditView->getSelection();
int startLine = _pEditView->execute(SCI_LINEFROMPOSITION, range.cpMin);
int endLine = _pEditView->execute(SCI_LINEFROMPOSITION, range.cpMax);
if (startLine == 0)
startLine = 1;
if (endLine == _pEditView->getNbLine())
endLine -= 1;
_pEditView->execute(SCI_HIDELINES, startLine, endLine);
_pEditView->execute(SCI_MARKERADD, startLine-1, MARK_HIDELINESBEGIN);
_pEditView->execute(SCI_MARKERADD, endLine+1, MARK_HIDELINESEND);
break;
}
case IDM_VIEW_ZOOMIN:
{
_pEditView->execute(SCI_ZOOMIN);
@ -3906,8 +3918,6 @@ void Notepad_plus::checkModifiedDocument()
const NppGUI & nppGUI = pNppParam->getNppGUI();
bool autoUpdate = (nppGUI._fileAutoDetection == cdAutoUpdate);
for (int j = 0 ; j < NB_VIEW ; j++)
{
for (int i = (pScintillaArray[j]->getNbDoc()-1) ; i >= 0 ; i--)
@ -3923,10 +3933,8 @@ void Notepad_plus::checkModifiedDocument()
if (::IsIconic(_hSelf))
::ShowWindow(_hSelf, SW_SHOWNORMAL);
//int caretPos = int(_pEditView->execute(SCI_GETCURRENTPOS));
if (update || doReloadOrNot(docBuf.getFileName()) == IDYES)
{
pDocTabArray[j]->activate(i);
// if it's a non current view, make it as the current view
if (j == 1)
@ -4353,9 +4361,9 @@ void Notepad_plus::bookmarkNext(bool forwardScan)
lineRetry = int(_pEditView->execute(SCI_GETLINECOUNT)); //If not found, try from the end
sci_marker = SCI_MARKERPREVIOUS;
}
int nextLine = int(_pEditView->execute(sci_marker, lineStart, 1 << MARK_SYMBOLE));
int nextLine = int(_pEditView->execute(sci_marker, lineStart, 1 << MARK_BOOKMARK));
if (nextLine < 0)
nextLine = int(_pEditView->execute(sci_marker, lineRetry, 1 << MARK_SYMBOLE));
nextLine = int(_pEditView->execute(sci_marker, lineRetry, 1 << MARK_BOOKMARK));
if (nextLine < 0)
return;
@ -5419,17 +5427,31 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}
case WM_CREATE:
{
char * ac_xpm[] = {
"14 14 4 1", //0
" c #FFFFFF", //1
". c #000000", //2
"+ c #A400B7", //3
"@ c #DE25F4", //4
" .. ",
" .+. ",
" .@+. ",
" .@@+. ",
".......@@@+. ",
".+@@@@@@@@@+. ",
".+@@@@@@@@@@+.",
".+@@@@@@@@@@+.",
".++++++@@@@+. ",
".......@@@+. ",
" .@@+. ",
" .@+. ",
" .+. ",
" .. "};
pNppParam->setFontList(hwnd);
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI();
/*
OSVERSIONINFO vInfo;
vInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
::GetVersionEx(&vInfo);
if (vInfo.dwMajorVersion == 4)
nppGUI._doTaskList = false;
else if ((vInfo.dwMajorVersion == 5) && (vInfo.dwMinorVersion == 0))
nppGUI._doTaskList = false;
*/
// Menu
string pluginsTrans, windowTrans;
changeMenuLang(pluginsTrans, windowTrans);
@ -5456,6 +5478,9 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_mainEditView.display();
_mainEditView.execute(SCI_MARKERDEFINEPIXMAP, MARK_HIDELINESEND, (LPARAM)ac_xpm);
_subEditView.execute(SCI_MARKERDEFINEPIXMAP, MARK_HIDELINESEND, (LPARAM)ac_xpm);
_invisibleEditView.init(_hInst, hwnd);
_invisibleEditView.execute(SCI_SETUNDOCOLLECTION);
_invisibleEditView.execute(SCI_EMPTYUNDOBUFFER);
@ -7125,7 +7150,7 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session)
int maxLine = _mainEditView.execute(SCI_GETLINECOUNT);
for (int j = 0 ; j < maxLine ; j++)
{
if ((_mainEditView.execute(SCI_MARKERGET, j)&(1 << MARK_SYMBOLE)) != 0)
if ((_mainEditView.execute(SCI_MARKERGET, j)&(1 << MARK_BOOKMARK)) != 0)
{
sfi.marks.push_back(j);
}
@ -7148,7 +7173,7 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session)
int maxLine = _subEditView.execute(SCI_GETLINECOUNT);
for (int j = 0 ; j < maxLine ; j++)
{
if ((_subEditView.execute(SCI_MARKERGET, j)&(1 << MARK_SYMBOLE)) != 0)
if ((_subEditView.execute(SCI_MARKERGET, j)&(1 << MARK_BOOKMARK)) != 0)
{
sfi.marks.push_back(j);
}

View File

@ -739,19 +739,19 @@ private:
if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber();
if (!bookmarkPresent(lineno))
_pEditView->execute(SCI_MARKERADD, lineno, MARK_SYMBOLE);
_pEditView->execute(SCI_MARKERADD, lineno, MARK_BOOKMARK);
};
void bookmarkDelete(int lineno) const {
if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber();
if ( bookmarkPresent(lineno))
_pEditView->execute(SCI_MARKERDELETE, lineno, MARK_SYMBOLE);
_pEditView->execute(SCI_MARKERDELETE, lineno, MARK_BOOKMARK);
};
bool bookmarkPresent(int lineno) const {
if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber();
LRESULT state = _pEditView->execute(SCI_MARKERGET, lineno);
return ((state & (1 << MARK_SYMBOLE)) != 0);
return ((state & (1 << MARK_BOOKMARK)) != 0);
};
void bookmarkToggle(int lineno) const {
if (lineno == -1)
@ -764,7 +764,59 @@ private:
};
void bookmarkNext(bool forwardScan);
void bookmarkClearAll() const {
_pEditView->execute(SCI_MARKERDELETEALL, MARK_SYMBOLE);
_pEditView->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
};
int hideLinesMarkPresent(int lineno) const {
LRESULT state = _pEditView->execute(SCI_MARKERGET, lineno);
if ((state & (1 << MARK_HIDELINESBEGIN)) != 0)
return MARK_HIDELINESBEGIN;
else if ((state & (1 << MARK_HIDELINESEND)) != 0)
return MARK_HIDELINESEND;
return 0;
};
void hideLinesMarkDelete(int lineno, int which) const {
_pEditView->execute(SCI_MARKERDELETE, lineno, which);
};
bool showLines(int lineno) const {
if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber();
int hideLinesMark = hideLinesMarkPresent(lineno);
if (!hideLinesMark)
return false;
//
int start = 0;
int end = 0;
if (hideLinesMark == MARK_HIDELINESEND)
{
end = lineno;
int i = lineno - 1;
for ( ; i >= 0 ; i--)
{
if (_pEditView->execute(SCI_GETLINEVISIBLE, i))
break;
}
start = i;
}
else if (hideLinesMark == MARK_HIDELINESBEGIN)
{
long nbLine = _pEditView->getNbLine();
start = lineno;
int i = lineno + 1;
for ( ; i < nbLine ; i++)
{
if (_pEditView->execute(SCI_GETLINEVISIBLE, i))
break;
}
end = i;
}
_pEditView->execute(SCI_SHOWLINES, start+1, end-1);
hideLinesMarkDelete(start, MARK_HIDELINESBEGIN);
hideLinesMarkDelete(end, MARK_HIDELINESEND);
return true;
};
void findMatchingBracePos(int & braceAtCaret, int & braceOpposite);

View File

@ -375,6 +375,7 @@ BEGIN
MENUITEM "8\tAlt+Shift+8", IDM_VIEW_UNFOLD_8
END
MENUITEM "Unfold all\tAlt+Shift+0", IDM_VIEW_TOGGLE_UNFOLDALL
MENUITEM "Hide lines", IDM_VIEW_HIDELINES
MENUITEM SEPARATOR
MENUITEM "Go to another view", IDM_VIEW_GOTO_ANOTHER_VIEW
MENUITEM "Clone to another view", IDM_VIEW_CLONE_TO_ANOTHER_VIEW

View File

@ -232,7 +232,7 @@ bool Finder::notify(SCNotification *notification)
// now we clean the previous mark
if (markedLine != -1)
(*_ppEditView)->execute(SCI_MARKERDELETE, markedLine, MARK_SYMBOLE);
(*_ppEditView)->execute(SCI_MARKERDELETE, markedLine, MARK_BOOKMARK);
// After cleaning the previous mark, we can swich to another document
@ -244,7 +244,7 @@ bool Finder::notify(SCNotification *notification)
// we set the current mark here
int nb = (*_ppEditView)->getCurrentLineNumber();
setCurrentMarkedLine(nb);
(*_ppEditView)->execute(SCI_MARKERADD, nb, MARK_SYMBOLE);
(*_ppEditView)->execute(SCI_MARKERADD, nb, MARK_BOOKMARK);
// Then we colourise the double clicked line
setFinderStyle();
@ -487,7 +487,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
if (lt == L_TXT)
(*_ppEditView)->defineDocType(L_CPP);
(*_ppEditView)->defineDocType(lt);
(*_ppEditView)->execute(SCI_MARKERDELETEALL, MARK_SYMBOLE);
(*_ppEditView)->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
}
}
return TRUE;
@ -932,7 +932,7 @@ int FindReplaceDlg::processAll(int op, bool isEntire, const char *fileName, cons
}
if ((_doMarkLine) && (_doPurge))
{
(*_ppEditView)->execute(SCI_MARKERDELETEALL, MARK_SYMBOLE);
(*_ppEditView)->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
}
}
@ -994,8 +994,8 @@ int FindReplaceDlg::processAll(int op, bool isEntire, const char *fileName, cons
int lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, posFind);
int state = (*_ppEditView)->execute(SCI_MARKERGET, lineNumber);
if (!(state & (1 << MARK_SYMBOLE)))
(*_ppEditView)->execute(SCI_MARKERADD, lineNumber, MARK_SYMBOLE);
if (!(state & (1 << MARK_BOOKMARK)))
(*_ppEditView)->execute(SCI_MARKERADD, lineNumber, MARK_BOOKMARK);
}
startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen;
}

View File

@ -393,6 +393,11 @@ public:
return long(execute(SCI_LINEFROMPOSITION, execute(SCI_GETCURRENTPOS)));
};
long getNbLine() const {
int endPos = execute(SCI_GETLENGTH);
return execute(SCI_LINEFROMPOSITION, endPos);
};
long getCurrentXOffset()const{
return long(execute(SCI_GETXOFFSET));
};

View File

@ -1,6 +1,8 @@
#ifndef CONSTANT_H
#define CONSTANT_H
const int MARK_SYMBOLE = 1;
const int MARK_BOOKMARK = 1;
const int MARK_HIDELINESBEGIN = 2;
const int MARK_HIDELINESEND = 3;
#endif //CONSTANT_H

View File

@ -13,5 +13,7 @@
<Item id="0"/>
<Item id="42022"/>
<Item id="42023"/>
<Item id="0"/>
<Item id="44042"/>
</ScintillaContextMenu>
</NotepadPlus>

View File

@ -140,6 +140,7 @@
#define IDM_VIEW_DRAWTABBAR_DBCLK2CLOSE (IDM_VIEW + 39)
#define IDM_VIEW_REFRESHTABAR (IDM_VIEW + 40)
#define IDM_VIEW_WRAP_SYMBOL (IDM_VIEW + 41)
#define IDM_VIEW_HIDELINES (IDM_VIEW + 42)
#define IDM_VIEW_FOLD (IDM_VIEW + 50)
#define IDM_VIEW_FOLD_1 (IDM_VIEW_FOLD + 1)
@ -161,6 +162,7 @@
#define IDM_VIEW_UNFOLD_7 (IDM_VIEW_UNFOLD + 7)
#define IDM_VIEW_UNFOLD_8 (IDM_VIEW_UNFOLD + 8)
#define IDM_VIEW_GOTO_ANOTHER_VIEW 10001
#define IDM_VIEW_CLONE_TO_ANOTHER_VIEW 10002

View File

@ -4094,12 +4094,11 @@ void Editor::LineTranspose() {
int len1 = endPrev - startPrev;
char *line2 = CopyRange(start, end);
int len2 = end - start;
if (pdoc->DeleteChars(start, len2)) {
pdoc->DeleteChars(start, len2);
pdoc->DeleteChars(startPrev, len1);
pdoc->InsertString(startPrev, line2, len2);
pdoc->InsertString(start - len1 + len2, line1, len1);
MovePositionTo(start - len1 + len2);
}
delete []line1;
delete []line2;
pdoc->EndUndoAction();