29 #ifdef HAVE_QSCINTILLA
31 #include <Qsci/qscilexer.h>
32 #include <Qsci/qscicommandset.h>
34 #include <QMessageBox>
43 connect (
this, SIGNAL (textChanged ()),
this, SLOT (text_changed ()));
46 QsciCommandSet *cmd_set = standardCommands ();
48 #ifdef HAVE_QSCI_VERSION_2_6_0
50 cmd_set->find (QsciCommand::SelectionCopy)->setKey (0);
51 cmd_set->find (QsciCommand::SelectionCut)->setKey (0);
52 cmd_set->find (QsciCommand::Paste)->setKey (0);
53 cmd_set->find (QsciCommand::SelectAll)->setKey (0);
54 cmd_set->find (QsciCommand::SelectionDuplicate)->setKey (0);
55 cmd_set->find (QsciCommand::LineTranspose)->setKey (0);
56 cmd_set->find (QsciCommand::Undo)->setKey (0);
57 cmd_set->find (QsciCommand::Redo)->setKey (0);
58 cmd_set->find (QsciCommand::SelectionUpperCase)->setKey (0);
59 cmd_set->find (QsciCommand::SelectionLowerCase)->setKey (0);
60 cmd_set->find (QsciCommand::ZoomIn)->setKey (0);
61 cmd_set->find (QsciCommand::ZoomOut)->setKey (0);
62 cmd_set->find (QsciCommand::DeleteWordLeft)->setKey (0);
63 cmd_set->find (QsciCommand::DeleteWordRight)->setKey (0);
64 cmd_set->find (QsciCommand::DeleteLineLeft)->setKey (0);
65 cmd_set->find (QsciCommand::DeleteLineRight)->setKey (0);
66 cmd_set->find (QsciCommand::LineDelete)->setKey (0);
67 cmd_set->find (QsciCommand::LineCut)->setKey (0);
68 cmd_set->find (QsciCommand::LineCopy)->setKey (0);
72 for (
int i = 0; i < cmd_list.length (); i++)
74 int cmd_key = cmd_list.at (i)->key ();
85 case Qt::Key_Z |
Qt::CTRL | Qt::SHIFT :
87 case Qt::Key_U |
Qt::CTRL | Qt::SHIFT :
90 case Qt::Key_Backspace |
Qt::CTRL | Qt::SHIFT :
91 case Qt::Key_Delete |
Qt::CTRL | Qt::SHIFT :
92 case Qt::Key_K | Qt::META :
95 case Qt::Key_L |
Qt::CTRL | Qt::SHIFT :
97 case Qt::Key_T |
Qt::CTRL | Qt::SHIFT :
98 cmd_list.at (i)->setKey (0);
103 #if defined (Q_OS_MAC)
107 for (
int i = 0; i < cmd_list_mac.length (); i++)
110 int key = cmd_list_mac.at (i)->key ();
112 if (static_cast<int> (key | Qt::META) == key &&
113 static_cast<int> (key |
Qt::CTRL) != key)
115 else if (static_cast<int> (key |
Qt::CTRL) == key)
118 cmd_list_mac.at (i)->setKey (key);
121 key = cmd_list_mac.at (i)->alternateKey ();
123 if (static_cast<int> (key | Qt::META) == key &&
124 static_cast<int> (key | Qt::CTRL) != key)
125 key = (key ^ Qt::META) | Qt::CTRL;
126 else if (static_cast<int> (key | Qt::CTRL) == key)
127 key = (key ^ Qt::CTRL) | Qt::META;
129 cmd_list_mac.at (i)->setAlternateKey (key);
141 long position = SendScintilla (SCI_GETCURRENTPOS);
142 long point_x = SendScintilla
143 (SCI_POINTXFROMPOSITION,0,position);
144 long point_y = SendScintilla
145 (SCI_POINTYFROMPOSITION,0,position);
146 *local_pos = QPoint (point_x,point_y);
147 *global_pos = mapToGlobal (*local_pos);
154 QPoint global_pos, local_pos;
157 QString lexer_name =
lexer ()->lexer ();
158 return ((lexer_name ==
"octave" || lexer_name ==
"matlab")
182 if (hasSelectedText ())
186 #ifdef HAVE_QSCI_VERSION_2_6_0
189 octave_qscintilla::contextMenuEvent (QContextMenuEvent *e)
191 QPoint global_pos, local_pos;
192 QMenu *context_menu = createStandardContextMenu ();
198 if (e->reason () == QContextMenuEvent::Mouse)
201 global_pos = e->globalPos ();
202 local_pos = e->pos ();
208 QRect editor_rect = geometry ();
209 editor_rect.moveTopLeft
210 (parentWidget ()->mapToGlobal (editor_rect.topLeft ()));
211 if (!editor_rect.contains (global_pos))
212 global_pos = editor_rect.topLeft ();
216 context_menu->addSeparator ();
220 QString lexer_name =
lexer ()->lexer ();
221 if (lexer_name ==
"octave" || lexer_name ==
"matlab")
228 context_menu->addAction (tr (
"Documentation on")
237 context_menu->exec (global_pos);
273 QStringList commands = selectedText ().split (QRegExp(
"[\r\n]"),
274 QString::SkipEmptyParts);
275 for (
int i = 0; i < commands.size (); i++)
void contextmenu_help_doc(bool)
void context_menu_edit_signal(const QString &)
void contextmenu_run(bool)
void contextmenu_edit(bool)
void status_update(bool, bool)
void show_doc_signal(const QString &)
void context_help_doc(bool)
void contextmenu_help(bool)
void create_context_menu_signal(QMenu *)
octave_qscintilla(QWidget *p)
void execute_command_in_terminal_signal(const QString &)
void contextmenu_doc(bool)
void get_global_textcursor_pos(QPoint *global_pos, QPoint *local_pos)