Inline EscapeSequenceUrlExtractor::appendUrlText

wilder
Waqar Ahmed 4 years ago committed by Tomaz Canabrava
parent e76442a55c
commit 27ef2148e8
  1. 12
      src/EscapeSequenceUrlExtractor.cpp
  2. 17
      src/EscapeSequenceUrlExtractor.h

@ -6,6 +6,7 @@
*/ */
#include "EscapeSequenceUrlExtractor.h" #include "EscapeSequenceUrlExtractor.h"
#include "Screen.h"
#include <QUrl> #include <QUrl>
@ -19,22 +20,13 @@ void Konsole::EscapeSequenceUrlExtractor::setScreen(Konsole::Screen *screen)
clear(); clear();
} }
bool EscapeSequenceUrlExtractor::reading() const
{
return _reading;
}
void EscapeSequenceUrlExtractor::beginUrlInput() void EscapeSequenceUrlExtractor::beginUrlInput()
{ {
_reading = true; _reading = true;
} }
void EscapeSequenceUrlExtractor::appendUrlText(QChar c) void EscapeSequenceUrlExtractor::appendUrlText_impl(QChar c)
{ {
if (!reading()) {
return;
}
if (_currentUrl.text.isEmpty()) { if (_currentUrl.text.isEmpty()) {
// We need to on getCursorX because we want the position of the // We need to on getCursorX because we want the position of the
// last printed character, not the cursor. // last printed character, not the cursor.

@ -8,12 +8,12 @@
SPDX-License-Identifier: GPL-2.0-or-later SPDX-License-Identifier: GPL-2.0-or-later
*/ */
#include "Screen.h"
#include <QObject> #include <QObject>
#include <QPointer> #include <QPointer>
namespace Konsole namespace Konsole
{ {
class Screen;
/* Like QPoint, but with Row / Col /* Like QPoint, but with Row / Col
* easier to read than x / y * easier to read than x / y
*/ */
@ -64,6 +64,8 @@ private:
/* Pointer to the Screen, that actually holds the text data. */ /* Pointer to the Screen, that actually holds the text data. */
Screen *_screen; Screen *_screen;
void appendUrlText_impl(QChar c);
public: public:
/* This needs to have access to the Session /* This needs to have access to the Session
* calculate the row / col of the current URL. * calculate the row / col of the current URL.
@ -78,7 +80,10 @@ public:
void setScreen(Screen *screen); void setScreen(Screen *screen);
/* If we are parsing a URL */ /* If we are parsing a URL */
bool reading() const; bool reading() const
{
return _reading;
}
/* We found an URL, starting to parse */ /* We found an URL, starting to parse */
void beginUrlInput(); void beginUrlInput();
@ -91,7 +96,13 @@ public:
/* The URL is parsed at once, but not the text. We received /* The URL is parsed at once, but not the text. We received
* one character per time until we hit the end byte. */ * one character per time until we hit the end byte. */
void appendUrlText(QChar c); void appendUrlText(QChar c)
{
if (!reading()) {
return;
}
appendUrlText_impl(c);
}
/* The URL is parsed at once, store it at once. */ /* The URL is parsed at once, store it at once. */
void setUrl(const QString &url); void setUrl(const QString &url);

Loading…
Cancel
Save