diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h --- a/src/TerminalDisplay.h +++ b/src/TerminalDisplay.h @@ -915,6 +915,8 @@ // Boilerplate setup for MessageWidget KMessageWidget* createMessageWidget(const QString &text); + int loc(int x, int y) const; + // the window onto the terminal screen which this display // is currently showing. QPointer _screenWindow; diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -74,18 +74,23 @@ using namespace Konsole; -#ifndef loc -#define loc(X,Y) ((Y)*_columns+(X)) -#endif - #define REPCHAR "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ "abcdefgjijklmnopqrstuvwxyz" \ "0123456789./+@" // we use this to force QPainter to display text in LTR mode // more information can be found in: http://unicode.org/reports/tr9/ const QChar LTR_OVERRIDE_CHAR(0x202D); +inline int TerminalDisplay::loc(int x, int y) const { + Q_ASSERT(y >= 0 && y < _lines); + Q_ASSERT(x >= 0 && x < _columns); + x = qBound(0, x, _columns - 1); + y = qBound(0, y, _lines - 1); + + return y * _columns + x; +} + /* ------------------------------------------------------------------------- */ /* */ /* Colors */