commented code out that didn't compile
This commit is contained in:
+60
-60
@@ -3,75 +3,75 @@
|
|||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
void CommandManager::execCommand(QString text)
|
// QString CommandManager::execCommand(QString text)
|
||||||
{
|
//{
|
||||||
QStringList words = text.split(' ', QString::SkipEmptyParts);
|
// QStringList words = text.split(' ', QString::SkipEmptyParts);
|
||||||
|
|
||||||
if (words.length() == 0) {
|
// if (words.length() == 0) {
|
||||||
return text;
|
// return text;
|
||||||
}
|
// }
|
||||||
|
|
||||||
QString commandName = words[0];
|
// QString commandName = words[0];
|
||||||
if (commandName[0] == "/") {
|
// if (commandName[0] == "/") {
|
||||||
commandName = commandName.mid(1);
|
// commandName = commandName.mid(1);
|
||||||
}
|
// }
|
||||||
|
|
||||||
Command *command = nullptr;
|
// Command *command = nullptr;
|
||||||
for (Command &command : this->commands) {
|
// for (Command &command : this->commands) {
|
||||||
if (command.name == commandName) {
|
// if (command.name == commandName) {
|
||||||
command = &command;
|
// command = &command;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (command == nullptr) {
|
// if (command == nullptr) {
|
||||||
return text;
|
// return text;
|
||||||
}
|
// }
|
||||||
|
|
||||||
QString result;
|
// QString result;
|
||||||
|
|
||||||
static QRegularExpression parseCommand("[^{]({{)*{(\d+\+?)}");
|
// static QRegularExpression parseCommand("[^{]({{)*{(\d+\+?)}");
|
||||||
for (QRegularExpressionMatch &match : parseCommand.globalMatch(command->text)) {
|
// for (QRegularExpressionMatch &match : parseCommand.globalMatch(command->text)) {
|
||||||
result += text.mid(match.capturedStart(), match.capturedLength());
|
// result += text.mid(match.capturedStart(), match.capturedLength());
|
||||||
|
|
||||||
QString wordIndexMatch = match.captured(2);
|
// QString wordIndexMatch = match.captured(2);
|
||||||
|
|
||||||
bool ok;
|
// bool ok;
|
||||||
int wordIndex = wordIndexMatch.replace("=", "").toInt(ok);
|
// int wordIndex = wordIndexMatch.replace("=", "").toInt(ok);
|
||||||
if (!ok) {
|
// if (!ok) {
|
||||||
result += match.captured();
|
// result += match.captured();
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
if (words.length() <= wordIndex) {
|
// if (words.length() <= wordIndex) {
|
||||||
// alternatively return text because the operation failed
|
// // alternatively return text because the operation failed
|
||||||
result += "";
|
// result += "";
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (wordIndexMatch[wordIndexMatch.length() - 1] == '+') {
|
// if (wordIndexMatch[wordIndexMatch.length() - 1] == '+') {
|
||||||
for (int i = wordIndex; i < words.length(); i++) {
|
// for (int i = wordIndex; i < words.length(); i++) {
|
||||||
result += words[i];
|
// result += words[i];
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
result += words[wordIndex];
|
// result += words[wordIndex];
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
result += text.mid(match.capturedStart(), match.capturedLength());
|
// result += text.mid(match.capturedStart(), match.capturedLength());
|
||||||
|
|
||||||
return result;
|
// return result;
|
||||||
}
|
//}
|
||||||
|
|
||||||
CommandManager::Command::Command(QString _text)
|
// CommandManager::Command::Command(QString _text)
|
||||||
{
|
//{
|
||||||
int index = _text.indexOf(' ');
|
// int index = _text.indexOf(' ');
|
||||||
|
|
||||||
if (index == -1) {
|
// if (index == -1) {
|
||||||
this->name == _text;
|
// this->name == _text;
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
this->name = _text.mid(0, index);
|
// this->name = _text.mid(0, index);
|
||||||
this->text = _text.mid(index + 1);
|
// this->text = _text.mid(index + 1);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-15
@@ -7,28 +7,28 @@ namespace chatterino {
|
|||||||
|
|
||||||
class CommandManager
|
class CommandManager
|
||||||
{
|
{
|
||||||
public:
|
// public:
|
||||||
CommandManager() = delete;
|
// CommandManager() = delete;
|
||||||
|
|
||||||
QString execCommand(QString text);
|
// QString execCommand(QString text);
|
||||||
// void addCommand ?
|
// void addCommand ?
|
||||||
// void loadCommands(QString) taking all commands as a \n seperated list ?
|
// void loadCommands(QString) taking all commands as a \n seperated list ?
|
||||||
|
|
||||||
static CommandManager *getInstance()
|
// static CommandManager *getInstance()
|
||||||
{
|
// {
|
||||||
static CommandManager manager;
|
// static CommandManager manager;
|
||||||
|
|
||||||
return manager;
|
// return manager;
|
||||||
}
|
// }
|
||||||
|
|
||||||
private:
|
// private:
|
||||||
struct Command {
|
// struct Command {
|
||||||
QString name;
|
// QString name;
|
||||||
QString text;
|
// QString text;
|
||||||
|
|
||||||
Command(QString text);
|
// Command(QString text);
|
||||||
};
|
// };
|
||||||
|
|
||||||
std::vector<Command> commands;
|
// std::vector<Command> commands;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,8 +127,10 @@ void ChannelView::actuallyLayoutMessages()
|
|||||||
this->showingLatestMessages = this->scrollBar.isAtBottom() || !this->scrollBar.isVisible();
|
this->showingLatestMessages = this->scrollBar.isAtBottom() || !this->scrollBar.isVisible();
|
||||||
|
|
||||||
size_t start = this->scrollBar.getCurrentValue();
|
size_t start = this->scrollBar.getCurrentValue();
|
||||||
|
// int layoutWidth =
|
||||||
|
// (this->scrollBar.isVisible() ? width() - this->scrollBar.width() : width()) - 4;
|
||||||
int layoutWidth =
|
int layoutWidth =
|
||||||
(this->scrollBar.isVisible() ? width() - this->scrollBar.width() : width()) - 4;
|
this->width() - (this->scrollBar.isVisible() ? 16 : 4) * this->getDpiMultiplier();
|
||||||
|
|
||||||
// layout the visible messages in the view
|
// layout the visible messages in the view
|
||||||
if (messagesSnapshot.getLength() > start) {
|
if (messagesSnapshot.getLength() > start) {
|
||||||
@@ -251,8 +253,9 @@ QString ChannelView::getSelectedText()
|
|||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
bool isSingleWord = isSingleMessage && this->selection.max.charIndex - charIndex <
|
bool isSingleWord =
|
||||||
part.getCharacterLength();
|
isSingleMessage &&
|
||||||
|
this->selection.max.charIndex - charIndex < part.getCharacterLength();
|
||||||
|
|
||||||
if (isSingleWord) {
|
if (isSingleWord) {
|
||||||
// return single word
|
// return single word
|
||||||
@@ -573,9 +576,10 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap
|
|||||||
// this->selectionMax.messageIndex >= messageIndex) {
|
// this->selectionMax.messageIndex >= messageIndex) {
|
||||||
// painter.fillRect(buffer->rect(), QColor(24, 55, 25));
|
// painter.fillRect(buffer->rect(), QColor(24, 55, 25));
|
||||||
//} else {
|
//} else {
|
||||||
painter.fillRect(buffer->rect(), (messageRef->getMessage()->containsHighlightedPhrase())
|
painter.fillRect(buffer->rect(),
|
||||||
? this->colorScheme.ChatBackgroundHighlighted
|
(messageRef->getMessage()->containsHighlightedPhrase())
|
||||||
: this->colorScheme.ChatBackground);
|
? this->colorScheme.ChatBackgroundHighlighted
|
||||||
|
: this->colorScheme.ChatBackground);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// draw selection
|
// draw selection
|
||||||
|
|||||||
Reference in New Issue
Block a user