mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-10-06 00:30:10 -06:00
CtrlLib: LineEdit: Optimizing rectangular blocks
git-svn-id: svn://ultimatepp.org/upp/trunk@8037 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
a1db87ca82
commit
938b3457c6
1 changed files with 13 additions and 2 deletions
|
|
@ -99,11 +99,21 @@ bool LineEdit::GetRectSelection(const Rect& rect, int line, int& l, int &h)
|
|||
int LineEdit::RemoveRectSelection()
|
||||
{
|
||||
Rect rect = GetRectSelection();
|
||||
WString txt;
|
||||
for(int i = rect.top; i <= rect.bottom; i++) {
|
||||
int l, h;
|
||||
GetRectSelection(rect, i, l, h);
|
||||
Remove(l, h - l);
|
||||
WString s = GetWLine(i);
|
||||
s.Remove(l - GetPos(i), h - l);
|
||||
txt.Cat(s);
|
||||
txt.Cat('\n');
|
||||
}
|
||||
int l = GetPos(rect.top);
|
||||
int h = GetPos(rect.bottom);
|
||||
if(h < GetLength())
|
||||
h++;
|
||||
Remove(l, h - l);
|
||||
Insert(l, txt);
|
||||
return GetGPos(rect.bottom, rect.left);
|
||||
}
|
||||
|
||||
|
|
@ -113,8 +123,9 @@ WString LineEdit::CopyRectSelection()
|
|||
Rect rect = GetRectSelection();
|
||||
for(int i = rect.top; i <= rect.bottom; i++) {
|
||||
int l, h;
|
||||
int pos = GetPos(i);
|
||||
GetRectSelection(rect, i, l, h);
|
||||
txt.Cat(GetW(l, h - l));
|
||||
txt.Cat(GetWLine(i).Mid(l - pos, h - l));
|
||||
#ifdef PLATFORM_WIN32
|
||||
txt.Cat('\r');
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue