mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-01 00:57:26 +00:00
Added support for ctrl+Enter submission in open shellcode tab (#2851)
* Added support for ctrl+Enter submission in shellcode tab in the new file dialog
This commit is contained in:
parent
98411b4dbf
commit
138078a6f4
@ -75,6 +75,9 @@ NewFileDialog::NewFileDialog(MainWindow *main)
|
|||||||
/* Set focus on the TextInput */
|
/* Set focus on the TextInput */
|
||||||
ui->newFileEdit->setFocus();
|
ui->newFileEdit->setFocus();
|
||||||
|
|
||||||
|
/* Install an event filter for shellcode text edit to enable ctrl+return event */
|
||||||
|
ui->shellcodeText->installEventFilter(this);
|
||||||
|
|
||||||
updateLoadProjectButton();
|
updateLoadProjectButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,3 +369,32 @@ void NewFileDialog::on_tabWidget_currentChanged(int index)
|
|||||||
{
|
{
|
||||||
Config()->setNewFileLastClicked(index);
|
Config()->setNewFileLastClicked(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NewFileDialog::eventFilter(QObject * /*obj*/, QEvent *event)
|
||||||
|
{
|
||||||
|
QString shellcode = ui->shellcodeText->toPlainText();
|
||||||
|
QString extractedCode = "";
|
||||||
|
static const QRegularExpression rx("([0-9a-f]{2})", QRegularExpression::CaseInsensitiveOption);
|
||||||
|
QRegularExpressionMatchIterator i = rx.globalMatch(shellcode);
|
||||||
|
int size = 0;
|
||||||
|
|
||||||
|
if (event->type() == QEvent::KeyPress) {
|
||||||
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
|
|
||||||
|
// Confirm comment by pressing Ctrl/Cmd+Return
|
||||||
|
if ((keyEvent->modifiers() & Qt::ControlModifier)
|
||||||
|
&& ((keyEvent->key() == Qt::Key_Enter) || (keyEvent->key() == Qt::Key_Return))) {
|
||||||
|
while (i.hasNext()) {
|
||||||
|
QRegularExpressionMatch match = i.next();
|
||||||
|
extractedCode.append(match.captured(1));
|
||||||
|
}
|
||||||
|
size = extractedCode.size() / 2;
|
||||||
|
if (size > 0) {
|
||||||
|
loadShellcode(extractedCode, size);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -69,6 +69,8 @@ private:
|
|||||||
void loadProject(const QString &project);
|
void loadProject(const QString &project);
|
||||||
void loadShellcode(const QString &shellcode, const int size);
|
void loadShellcode(const QString &shellcode, const int size);
|
||||||
|
|
||||||
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
|
|
||||||
static const int MaxRecentFiles = 5;
|
static const int MaxRecentFiles = 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user