mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-06-02 06:12:41 -06:00
ide, CodeEditor: Move line/selection up/down
git-svn-id: svn://ultimatepp.org/upp/trunk@15924 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
5a74890e14
commit
eb62fe233e
6 changed files with 57 additions and 15 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include "CodeEditor.h"
|
||||
#include "CodeEditor.h"
|
||||
|
||||
namespace Upp {
|
||||
|
||||
|
|
@ -558,6 +559,36 @@ bool CodeEditor::GetLineSelection(int& l, int& h) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void CodeEditor::SwapUpDown(bool up)
|
||||
{
|
||||
int l, h;
|
||||
if(GetSelection(l, h)) {
|
||||
l = GetLine(l);
|
||||
int hh = h;
|
||||
h = GetLinePos(hh);
|
||||
if(hh && h < GetLineCount()) h++;
|
||||
}
|
||||
else {
|
||||
l = GetLine(cursor);
|
||||
h = l + 1;
|
||||
}
|
||||
if(up) {
|
||||
if(l == 0)
|
||||
return;
|
||||
Insert(GetPos(h), GetWLine(l - 1) + "\n");
|
||||
Remove(GetPos(l - 1), GetLineLength(l - 1) + 1);
|
||||
SetSelection(GetPos(l - 1), GetPos(h - 1));
|
||||
}
|
||||
else {
|
||||
if(h >= GetLineCount() - 1)
|
||||
return;
|
||||
WString line = GetWLine(h) + "\n";
|
||||
Remove(GetPos(h), GetLineLength(h) + 1);
|
||||
Insert(GetPos(l), line);
|
||||
SetSelection(GetPos(l + 1), GetPos(h + 1));
|
||||
}
|
||||
}
|
||||
|
||||
void CodeEditor::TabRight() {
|
||||
if(IsReadOnly()) return;
|
||||
int l, h;
|
||||
|
|
@ -878,6 +909,12 @@ bool CodeEditor::Key(dword code, int count) {
|
|||
return true;
|
||||
}
|
||||
switch(code) {
|
||||
case K_SHIFT_CTRL_UP:
|
||||
SwapUpDown(true);
|
||||
return true;
|
||||
case K_SHIFT_CTRL_DOWN:
|
||||
SwapUpDown(false);
|
||||
return true;
|
||||
case K_CTRL_DELETE:
|
||||
DeleteWord();
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue