mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-31 16:47:26 +00:00
Cleanup Nodepad
This commit is contained in:
parent
a7eec66110
commit
f80cf8eb03
@ -353,8 +353,6 @@ void MainWindow::finalizeOpen()
|
|||||||
addOutput("\n" + core->cmd("fo"));
|
addOutput("\n" + core->cmd("fo"));
|
||||||
//previewDock->setWindowTitle("entry0");
|
//previewDock->setWindowTitle("entry0");
|
||||||
showMaximized();
|
showMaximized();
|
||||||
// Initialize syntax highlighters
|
|
||||||
notepadDock->highlightPreview();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::saveProject(bool quit)
|
bool MainWindow::saveProject(bool quit)
|
||||||
|
@ -28,17 +28,12 @@ Notepad::Notepad(MainWindow *main, QWidget *parent) :
|
|||||||
this->main = main;
|
this->main = main;
|
||||||
|
|
||||||
highlighter = new MdHighlighter(ui->notepadTextEdit->document());
|
highlighter = new MdHighlighter(ui->notepadTextEdit->document());
|
||||||
ui->splitter->setStretchFactor(0, 2);
|
|
||||||
isFirstTime = true;
|
isFirstTime = true;
|
||||||
this->notesTextEdit = ui->notepadTextEdit;
|
this->notesTextEdit = ui->notepadTextEdit;
|
||||||
|
|
||||||
// Increase notes document inner margin
|
// Increase notes document inner margin
|
||||||
QTextDocument *docu = this->notesTextEdit->document();
|
QTextDocument *docu = this->notesTextEdit->document();
|
||||||
docu->setDocumentMargin(10);
|
docu->setDocumentMargin(10);
|
||||||
// Increase preview notes document inner margin
|
|
||||||
QPlainTextEdit *preview = ui->previewTextEdit;
|
|
||||||
QTextDocument *preview_docu = preview->document();
|
|
||||||
preview_docu->setDocumentMargin(10);
|
|
||||||
|
|
||||||
// Context menu
|
// Context menu
|
||||||
ui->notepadTextEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->notepadTextEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
@ -70,7 +65,6 @@ void Notepad::on_fontButton_clicked()
|
|||||||
void Notepad::setFonts(QFont font)
|
void Notepad::setFonts(QFont font)
|
||||||
{
|
{
|
||||||
ui->notepadTextEdit->setFont(font);
|
ui->notepadTextEdit->setFont(font);
|
||||||
ui->previewTextEdit->setFont(font);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notepad::on_boldButton_clicked()
|
void Notepad::on_boldButton_clicked()
|
||||||
@ -162,11 +156,6 @@ void Notepad::on_redoButton_clicked()
|
|||||||
doc->redo();
|
doc->redo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notepad::highlightPreview()
|
|
||||||
{
|
|
||||||
disasm_highlighter = new Highlighter(ui->previewTextEdit->document());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Notepad::on_searchEdit_returnPressed()
|
void Notepad::on_searchEdit_returnPressed()
|
||||||
{
|
{
|
||||||
QString searchString = ui->searchEdit->text();
|
QString searchString = ui->searchEdit->text();
|
||||||
@ -289,29 +278,22 @@ void Notepad::showNotepadContextMenu(const QPoint &pt)
|
|||||||
QTextCursor cur = ui->notepadTextEdit->textCursor();
|
QTextCursor cur = ui->notepadTextEdit->textCursor();
|
||||||
QAction *first = menu->actions().at(0);
|
QAction *first = menu->actions().at(0);
|
||||||
|
|
||||||
if (cur.hasSelection())
|
if (!cur.hasSelection())
|
||||||
{
|
{
|
||||||
// Get selected text
|
|
||||||
//this->main->add_debug_output("Selected text: " + cur.selectedText());
|
|
||||||
this->addr = cur.selectedText();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Get word under the cursor
|
|
||||||
cur.select(QTextCursor::WordUnderCursor);
|
cur.select(QTextCursor::WordUnderCursor);
|
||||||
//this->main->add_debug_output("Word: " + cur.selectedText());
|
|
||||||
this->addr = cur.selectedText();
|
|
||||||
}
|
}
|
||||||
ui->actionDisassmble_bytes->setText("Disassemble bytes at: " + this->addr);
|
|
||||||
ui->actionDisassmble_function->setText("Disassemble function at: " + this->addr);
|
addr = cur.selectedText();
|
||||||
ui->actionHexdump_bytes->setText("Hexdump bytes at: " + this->addr);
|
|
||||||
ui->actionCompact_Hexdump->setText("Compact Hexdump at: " + this->addr);
|
static const int maxLength = 20;
|
||||||
ui->actionHexdump_function->setText("Hexdump function at: " + this->addr);
|
if(addr.length() > maxLength)
|
||||||
menu->insertAction(first, ui->actionDisassmble_bytes);
|
{
|
||||||
menu->insertAction(first, ui->actionDisassmble_function);
|
addr = addr.left(maxLength-1) + "\u2026";
|
||||||
menu->insertAction(first, ui->actionHexdump_bytes);
|
}
|
||||||
menu->insertAction(first, ui->actionCompact_Hexdump);
|
|
||||||
menu->insertAction(first, ui->actionHexdump_function);
|
ui->actionSeekToSelection->setText(tr("Seek to \"%1\"").arg(addr));
|
||||||
|
|
||||||
|
menu->insertAction(first, ui->actionSeekToSelection);
|
||||||
menu->insertSeparator(first);
|
menu->insertSeparator(first);
|
||||||
ui->notepadTextEdit->setContextMenuPolicy(Qt::DefaultContextMenu);
|
ui->notepadTextEdit->setContextMenuPolicy(Qt::DefaultContextMenu);
|
||||||
menu->exec(ui->notepadTextEdit->mapToGlobal(pt));
|
menu->exec(ui->notepadTextEdit->mapToGlobal(pt));
|
||||||
@ -319,29 +301,9 @@ void Notepad::showNotepadContextMenu(const QPoint &pt)
|
|||||||
ui->notepadTextEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->notepadTextEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notepad::on_actionDisassmble_bytes_triggered()
|
void Notepad::on_actionSeekToSelection_triggered()
|
||||||
{
|
{
|
||||||
ui->previewTextEdit->setPlainText(CutterCore::getInstance()->cmd("pd 100 @ " + this->addr));
|
Core()->seek(addr);
|
||||||
}
|
|
||||||
|
|
||||||
void Notepad::on_actionDisassmble_function_triggered()
|
|
||||||
{
|
|
||||||
ui->previewTextEdit->setPlainText(CutterCore::getInstance()->cmd("pdf @ " + this->addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Notepad::on_actionHexdump_bytes_triggered()
|
|
||||||
{
|
|
||||||
ui->previewTextEdit->setPlainText(CutterCore::getInstance()->cmd("px 1024 @ " + this->addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Notepad::on_actionCompact_Hexdump_triggered()
|
|
||||||
{
|
|
||||||
ui->previewTextEdit->setPlainText(CutterCore::getInstance()->cmd("pxi 1024 @ " + this->addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Notepad::on_actionHexdump_function_triggered()
|
|
||||||
{
|
|
||||||
ui->previewTextEdit->setPlainText(CutterCore::getInstance()->cmd("pxf @ " + this->addr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notepad::updateNotes(const QString ¬es)
|
void Notepad::updateNotes(const QString ¬es)
|
||||||
|
@ -45,11 +45,7 @@ private slots:
|
|||||||
|
|
||||||
void showNotepadContextMenu(const QPoint &pt);
|
void showNotepadContextMenu(const QPoint &pt);
|
||||||
|
|
||||||
void on_actionDisassmble_bytes_triggered();
|
void on_actionSeekToSelection_triggered();
|
||||||
void on_actionDisassmble_function_triggered();
|
|
||||||
void on_actionHexdump_bytes_triggered();
|
|
||||||
void on_actionCompact_Hexdump_triggered();
|
|
||||||
void on_actionHexdump_function_triggered();
|
|
||||||
|
|
||||||
void updateNotes(const QString ¬es);
|
void updateNotes(const QString ¬es);
|
||||||
void textChanged();
|
void textChanged();
|
||||||
|
@ -388,53 +388,6 @@ QToolTip {
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="underlineButton">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<pointsize>15</pointsize>
|
|
||||||
<underline>true</underline>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string notr="true">Underline</string>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">QToolButton { /* all types of tool button */
|
|
||||||
border: 5px solid #333;
|
|
||||||
border-left: 10px solid #333;
|
|
||||||
border-right: 10px solid #333;
|
|
||||||
border-radius: 0px;
|
|
||||||
background-color: #333;
|
|
||||||
color: rgb(172, 174, 175);
|
|
||||||
}
|
|
||||||
|
|
||||||
QToolButton:hover {
|
|
||||||
border: 5px solid #444;
|
|
||||||
border-radius: 0px;
|
|
||||||
background-color: #444;
|
|
||||||
}
|
|
||||||
|
|
||||||
QToolButton:pressed {
|
|
||||||
border: 5px solid #2180a9;
|
|
||||||
border-radius: 0px;
|
|
||||||
background-color: #2180a9;
|
|
||||||
}
|
|
||||||
|
|
||||||
QToolTip {
|
|
||||||
background-color: #444;
|
|
||||||
border: 3px solid #444;
|
|
||||||
color: rgb(232, 232, 232);
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">U</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolButtonStyle">
|
|
||||||
<enum>Qt::ToolButtonTextOnly</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line">
|
<widget class="Line" name="line">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -644,26 +597,6 @@ QToolTip {
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSplitter" name="splitter">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">QSplitter::handle {
|
|
||||||
height: 2px;
|
|
||||||
background-color: rgb(255, 255, 255);
|
|
||||||
image: url(:/img/icons/tabs.svg);
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::NoFrame</enum>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<widget class="QPlainTextEdit" name="notepadTextEdit">
|
<widget class="QPlainTextEdit" name="notepadTextEdit">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
@ -696,42 +629,6 @@ QToolTip {
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPlainTextEdit" name="previewTextEdit">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Anonymous Pro</family>
|
|
||||||
<pointsize>13</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::NoFrame</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Plain</enum>
|
|
||||||
</property>
|
|
||||||
<property name="horizontalScrollBarPolicy">
|
|
||||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
|
||||||
</property>
|
|
||||||
<property name="lineWrapMode">
|
|
||||||
<enum>QPlainTextEdit::NoWrap</enum>
|
|
||||||
</property>
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="plainText">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
@ -739,44 +636,9 @@ QToolTip {
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<action name="actionDisassmble_bytes">
|
<action name="actionSeekToSelection">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Disassmble bytes at </string>
|
<string>Seek to</string>
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Disassmble bytes at </string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionDisassmble_function">
|
|
||||||
<property name="text">
|
|
||||||
<string>Disassmble function at </string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Disassmble function at </string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionHexdump_bytes">
|
|
||||||
<property name="text">
|
|
||||||
<string>Hexdump bytes at </string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Hexdump bytes at </string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionCompact_Hexdump">
|
|
||||||
<property name="text">
|
|
||||||
<string>Compact Hexdump at </string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Compact Hexdump at </string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionHexdump_function">
|
|
||||||
<property name="text">
|
|
||||||
<string>Hexdump function at</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Hexdump function at</string>
|
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
Reference in New Issue
Block a user