[GB.QT4.EXT]

* BUG: Fix some little problems in block selection/insertion mode.


git-svn-id: svn://localhost/gambas/trunk@2926 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2010-04-29 18:48:43 +00:00
parent 9bc6316917
commit a4ec140d8a
5 changed files with 36 additions and 18 deletions

View File

@ -500,14 +500,14 @@ END_PROPERTY
BEGIN_PROPERTY(CEDITOR_selected)
GB.ReturnBoolean(DOC->hasSelection());
GB.ReturnBoolean(WIDGET->hasSelection());
END_PROPERTY
BEGIN_PROPERTY(CEDITOR_sel)
if (DOC->hasSelection())
DOC->getSelection(&_y1, &_x1, &_y2, &_x2);
if (WIDGET->hasSelection())
WIDGET->getSelection(&_y1, &_x1, &_y2, &_x2);
else
_x1 = _y1 = _x2 = _y2 = -1;
@ -517,7 +517,7 @@ END_PROPERTY
BEGIN_PROPERTY(CEDITOR_sel_text)
GB.ReturnNewZeroString(DOC->getSelectedText(WIDGET->getInsertMode()).utf8());
GB.ReturnNewZeroString(WIDGET->getSelectedText().utf8());
END_PROPERTY
@ -547,7 +547,7 @@ END_PROPERTY
BEGIN_METHOD_VOID(CEDITOR_sel_hide)
DOC->hideSelection();
WIDGET->hideSelection();
END_METHOD

View File

@ -263,7 +263,7 @@ GString GDocument::getSelectedText(bool insertMode) const
if (lines.count() && hasSelection())
{
getSelection(&y1, &x1, &y2, &x2);
getSelection(&y1, &x1, &y2, &x2, insertMode);
if (insertMode)
{
@ -663,7 +663,7 @@ void GDocument::updateViews(int row, int count)
}
void GDocument::getSelection(int *y1, int *x1, int *y2, int *x2) const
void GDocument::getSelection(int *y1, int *x1, int *y2, int *x2, bool insertMode) const
{
if (!selector)
return;
@ -682,6 +682,12 @@ void GDocument::getSelection(int *y1, int *x1, int *y2, int *x2) const
if (x1) *x1 = xs2;
if (x2) *x2 = xs;
}
if (!insertMode)
{
*x1 = QMIN(*x1, lineLength(*y1));
*x2 = QMIN(*x2, lineLength(*y2));
}
}
void GDocument::startSelection(GEditor *view, int y, int x)
@ -699,10 +705,10 @@ void GDocument::endSelection(int y, int x)
{
int y1a, y2a, y1b, y2b;
getSelection(&y1a, NULL, &y2a, NULL);
getSelection(&y1a, NULL, &y2a, NULL, true);
ys2 = y;
xs2 = x;
getSelection(&y1b, NULL, &y2b, NULL);
getSelection(&y1b, NULL, &y2b, NULL, true);
/*if (y1a == y1b)
updateViews(GMIN(y2a, y2b), GMAX(y2a, y2b) - GMIN(y2a, y2b) + 1);
@ -721,7 +727,7 @@ void GDocument::hideSelection()
if (!selector)
return;
getSelection(&y1, NULL, &y2, NULL);
getSelection(&y1, NULL, &y2, NULL, true);
selector = NULL;
updateViews(y1, y2 - y1 + 1);
}
@ -733,7 +739,7 @@ void GDocument::eraseSelection()
if (!selector)
return;
getSelection(&y1, &x1, &y2, &x2);
getSelection(&y1, &x1, &y2, &x2, false);
selector = NULL;
/*x2--;
if (x2 < 0)

View File

@ -182,7 +182,7 @@ public:
bool hasSelection() const { return selector != NULL; }
bool hasSelection(GEditor *view) const { return selector == view; }
void getSelection(int *y1, int *x1, int *y2, int *x2) const;
void getSelection(int *y1, int *x1, int *y2, int *x2, bool insertMode) const;
void startSelection(GEditor *view, int y, int x);
void endSelection(int y, int x);
void hideSelection();

View File

@ -710,7 +710,7 @@ void GEditor::paintCell(QPainter *painter, int row, int)
xs2 = 0;
if (doc->hasSelection())
{
doc->getSelection(&y1, &x1, &y2, &x2);
doc->getSelection(&y1, &x1, &y2, &x2, _insertMode);
if (realRow >= y1 && realRow <= y2 && !(realRow == y2 && x2 == 0))
{
@ -1002,8 +1002,13 @@ bool GEditor::cursorGoto(int ny, int nx, bool mark)
if (nx < 0)
nx = 0;
else if (!_insertMode && nx > lineLength(ny))
nx = lineLength(ny);
else
{
int xmax = _insertMode ? QMAX((_cellw / _charWidth) + 1, lineLength(largestLine)) : lineLength(ny);
if (nx > xmax)
nx = xmax;
}
if (ny != y)
{
@ -1236,7 +1241,7 @@ void GEditor::tab(bool back)
return;
}
doc->getSelection(&y1, &x1, &y2, &x2);
doc->getSelection(&y1, &x1, &y2, &x2, _insertMode);
doc->startSelection(this, y1, 0);
if (x2)
y2++;
@ -1498,7 +1503,7 @@ int GEditor::posToColumn(int y, int px)
_posOutside = true;
if (len == 0)
return px / _charWidth;
return (px - margin) / _charWidth;
px += contentsX();
@ -2459,7 +2464,9 @@ void GEditor::setInsertMode(bool mode)
if (doc->hasSelection())
{
doc->getSelection(&y1, &x1, &y2, &x2);
doc->getSelection(&y1, &x1, &y2, &x2, _insertMode);
x = x2; y = y2;
for (i = y1; i <= y2; i++)
updateLine(i);
}

View File

@ -249,6 +249,11 @@ public:
bool insideFolded(int row);
void foldRemove(int y1, int y2 = -1);
void foldInsert(int y, int n);
bool hasSelection() const { return doc->hasSelection(); }
void getSelection(int *y1, int *x1, int *y2, int *x2) const { return doc->getSelection(y1, x1, y2, x2, _insertMode); }
GString getSelectedText() const { return doc->getSelectedText(_insertMode); }
void hideSelection() { doc->hideSelection(); }
signals: