[GB.QT4.EXT]
* NEW: Editor.ShowWord() is a new method that highlights a piece of text on a specific line. git-svn-id: svn://localhost/gambas/trunk@2028 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
32bf31484c
commit
c62f94adc3
@ -128,6 +128,9 @@ GEditor::GEditor(QWidget *parent)
|
||||
flashed = false;
|
||||
painting = false;
|
||||
_showStringIgnoreCase = false;
|
||||
_showRow = -1;
|
||||
_showCol = 0;
|
||||
_showLen = 0;
|
||||
|
||||
for (i = 0; i < GLine::NUM_STATE; i++)
|
||||
{
|
||||
@ -502,6 +505,13 @@ void GEditor::paintShowString(QPainter &p, GLine *l, int x, int y, int xmin, int
|
||||
p.fillRect(ps, 0, nx - ps, h, bg);
|
||||
pos += _showString.length();
|
||||
}
|
||||
|
||||
if (row == _showRow && _showLen > 0 && _showCol >= 0 && _showCol < (int)l->s.length())
|
||||
{
|
||||
ps = lineWidth(row, _showCol);
|
||||
nx = lineWidth(row, QMAX((int)l->s.length(), _showCol + _showLen));
|
||||
p.fillRect(ps, 0, nx - ps, h, bg);
|
||||
}
|
||||
}
|
||||
|
||||
static void make_blend(QPixmap &pix, QColor start, QColor end, int height) //, bool loop = false)
|
||||
@ -660,8 +670,8 @@ void GEditor::paintCell(QPainter * painter, int row, int)
|
||||
|
||||
p.translate(-ur.left(), 0);
|
||||
|
||||
// Search
|
||||
if (highlight && _showString.length())
|
||||
// Show string
|
||||
if (highlight && (_showRow == realRow || _showString.length()))
|
||||
paintShowString(p, l, margin, fm.ascent() + 1, xmin, lmax, cellHeight(), realRow);
|
||||
|
||||
// Selection background
|
||||
@ -2127,3 +2137,11 @@ void GEditor::showString(GString s, bool ignoreCase)
|
||||
_showStringIgnoreCase = ignoreCase;
|
||||
updateContents();
|
||||
}
|
||||
|
||||
void GEditor::showWord(int y, int x, int len)
|
||||
{
|
||||
_showRow = y;
|
||||
_showCol = x;
|
||||
_showLen = len;
|
||||
updateLine(y);
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ private:
|
||||
bool painting;
|
||||
GString _showString;
|
||||
bool _showStringIgnoreCase;
|
||||
int _showRow, _showCol, _showLen;
|
||||
|
||||
int lastx;
|
||||
bool left;
|
||||
@ -218,6 +219,7 @@ public:
|
||||
void checkMatching();
|
||||
void flash();
|
||||
void showString(GString s, bool ignoreCase);
|
||||
void showWord(int y, int x, int len);
|
||||
|
||||
void foldClear() { fold.clear(); }
|
||||
void foldLine(int row, bool no_refresh = false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user