mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
commented code out that didn't compile
This commit is contained in:
parent
f676450d03
commit
4f3f9906f1
|
@ -3,75 +3,75 @@
|
|||
#include <QRegularExpression>
|
||||
|
||||
namespace chatterino {
|
||||
void CommandManager::execCommand(QString text)
|
||||
{
|
||||
QStringList words = text.split(' ', QString::SkipEmptyParts);
|
||||
// QString CommandManager::execCommand(QString text)
|
||||
//{
|
||||
// QStringList words = text.split(' ', QString::SkipEmptyParts);
|
||||
|
||||
if (words.length() == 0) {
|
||||
return text;
|
||||
}
|
||||
// if (words.length() == 0) {
|
||||
// return text;
|
||||
// }
|
||||
|
||||
QString commandName = words[0];
|
||||
if (commandName[0] == "/") {
|
||||
commandName = commandName.mid(1);
|
||||
}
|
||||
// QString commandName = words[0];
|
||||
// if (commandName[0] == "/") {
|
||||
// commandName = commandName.mid(1);
|
||||
// }
|
||||
|
||||
Command *command = nullptr;
|
||||
for (Command &command : this->commands) {
|
||||
if (command.name == commandName) {
|
||||
command = &command;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Command *command = nullptr;
|
||||
// for (Command &command : this->commands) {
|
||||
// if (command.name == commandName) {
|
||||
// command = &command;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (command == nullptr) {
|
||||
return text;
|
||||
}
|
||||
// if (command == nullptr) {
|
||||
// return text;
|
||||
// }
|
||||
|
||||
QString result;
|
||||
// QString result;
|
||||
|
||||
static QRegularExpression parseCommand("[^{]({{)*{(\d+\+?)}");
|
||||
for (QRegularExpressionMatch &match : parseCommand.globalMatch(command->text)) {
|
||||
result += text.mid(match.capturedStart(), match.capturedLength());
|
||||
// static QRegularExpression parseCommand("[^{]({{)*{(\d+\+?)}");
|
||||
// for (QRegularExpressionMatch &match : parseCommand.globalMatch(command->text)) {
|
||||
// result += text.mid(match.capturedStart(), match.capturedLength());
|
||||
|
||||
QString wordIndexMatch = match.captured(2);
|
||||
// QString wordIndexMatch = match.captured(2);
|
||||
|
||||
bool ok;
|
||||
int wordIndex = wordIndexMatch.replace("=", "").toInt(ok);
|
||||
if (!ok) {
|
||||
result += match.captured();
|
||||
continue;
|
||||
}
|
||||
if (words.length() <= wordIndex) {
|
||||
// alternatively return text because the operation failed
|
||||
result += "";
|
||||
return;
|
||||
}
|
||||
// bool ok;
|
||||
// int wordIndex = wordIndexMatch.replace("=", "").toInt(ok);
|
||||
// if (!ok) {
|
||||
// result += match.captured();
|
||||
// continue;
|
||||
// }
|
||||
// if (words.length() <= wordIndex) {
|
||||
// // alternatively return text because the operation failed
|
||||
// result += "";
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (wordIndexMatch[wordIndexMatch.length() - 1] == '+') {
|
||||
for (int i = wordIndex; i < words.length(); i++) {
|
||||
result += words[i];
|
||||
}
|
||||
} else {
|
||||
result += words[wordIndex];
|
||||
}
|
||||
}
|
||||
// if (wordIndexMatch[wordIndexMatch.length() - 1] == '+') {
|
||||
// for (int i = wordIndex; i < words.length(); i++) {
|
||||
// result += words[i];
|
||||
// }
|
||||
// } else {
|
||||
// result += words[wordIndex];
|
||||
// }
|
||||
// }
|
||||
|
||||
result += text.mid(match.capturedStart(), match.capturedLength());
|
||||
// result += text.mid(match.capturedStart(), match.capturedLength());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CommandManager::Command::Command(QString _text)
|
||||
{
|
||||
int index = _text.indexOf(' ');
|
||||
|
||||
if (index == -1) {
|
||||
this->name == _text;
|
||||
return;
|
||||
}
|
||||
|
||||
this->name = _text.mid(0, index);
|
||||
this->text = _text.mid(index + 1);
|
||||
}
|
||||
// return result;
|
||||
//}
|
||||
|
||||
// CommandManager::Command::Command(QString _text)
|
||||
//{
|
||||
// int index = _text.indexOf(' ');
|
||||
|
||||
// if (index == -1) {
|
||||
// this->name == _text;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// this->name = _text.mid(0, index);
|
||||
// this->text = _text.mid(index + 1);
|
||||
//}
|
||||
}
|
||||
|
|
|
@ -7,28 +7,28 @@ namespace chatterino {
|
|||
|
||||
class CommandManager
|
||||
{
|
||||
public:
|
||||
CommandManager() = delete;
|
||||
// public:
|
||||
// CommandManager() = delete;
|
||||
|
||||
QString execCommand(QString text);
|
||||
// QString execCommand(QString text);
|
||||
// void addCommand ?
|
||||
// void loadCommands(QString) taking all commands as a \n seperated list ?
|
||||
|
||||
static CommandManager *getInstance()
|
||||
{
|
||||
static CommandManager manager;
|
||||
// static CommandManager *getInstance()
|
||||
// {
|
||||
// static CommandManager manager;
|
||||
|
||||
return manager;
|
||||
}
|
||||
// return manager;
|
||||
// }
|
||||
|
||||
private:
|
||||
struct Command {
|
||||
QString name;
|
||||
QString text;
|
||||
// private:
|
||||
// struct Command {
|
||||
// QString name;
|
||||
// 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();
|
||||
|
||||
size_t start = this->scrollBar.getCurrentValue();
|
||||
// int layoutWidth =
|
||||
// (this->scrollBar.isVisible() ? width() - this->scrollBar.width() : width()) - 4;
|
||||
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
|
||||
if (messagesSnapshot.getLength() > start) {
|
||||
|
@ -251,8 +253,9 @@ QString ChannelView::getSelectedText()
|
|||
|
||||
if (first) {
|
||||
first = false;
|
||||
bool isSingleWord = isSingleMessage && this->selection.max.charIndex - charIndex <
|
||||
part.getCharacterLength();
|
||||
bool isSingleWord =
|
||||
isSingleMessage &&
|
||||
this->selection.max.charIndex - charIndex < part.getCharacterLength();
|
||||
|
||||
if (isSingleWord) {
|
||||
// return single word
|
||||
|
@ -573,9 +576,10 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap
|
|||
// this->selectionMax.messageIndex >= messageIndex) {
|
||||
// painter.fillRect(buffer->rect(), QColor(24, 55, 25));
|
||||
//} else {
|
||||
painter.fillRect(buffer->rect(), (messageRef->getMessage()->containsHighlightedPhrase())
|
||||
? this->colorScheme.ChatBackgroundHighlighted
|
||||
: this->colorScheme.ChatBackground);
|
||||
painter.fillRect(buffer->rect(),
|
||||
(messageRef->getMessage()->containsHighlightedPhrase())
|
||||
? this->colorScheme.ChatBackgroundHighlighted
|
||||
: this->colorScheme.ChatBackground);
|
||||
//}
|
||||
|
||||
// draw selection
|
||||
|
|
Loading…
Reference in a new issue