25 #if defined (HAVE_CONFIG_H)
29 #if defined (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 #if defined (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);
144 long position = SendScintilla (SCI_GETCURRENTPOS);
145 long point_x = SendScintilla
146 (SCI_POINTXFROMPOSITION,0,position);
147 long point_y = SendScintilla
148 (SCI_POINTYFROMPOSITION,0,position);
149 *local_pos = QPoint (point_x,point_y);
150 *global_pos = mapToGlobal (*local_pos);
157 QPoint global_pos, local_pos;
160 QString lexer_name =
lexer ()->lexer ();
161 return ((lexer_name ==
"octave" || lexer_name ==
"matlab")
185 if (hasSelectedText ())
193 #if defined (HAVE_QSCI_VERSION_2_6_0)
194 QPoint global_pos, local_pos;
195 QMenu *context_menu = createStandardContextMenu ();
197 bool in_left_margin =
false;
200 if (e->reason () == QContextMenuEvent::Mouse)
203 global_pos = e->globalPos ();
204 local_pos = e->pos ();
205 if (e->x () < marginWidth (1) + marginWidth (2))
206 in_left_margin =
true;
212 QRect editor_rect = geometry ();
213 editor_rect.moveTopLeft
214 (parentWidget ()->mapToGlobal (editor_rect.topLeft ()));
215 if (! editor_rect.contains (global_pos))
216 global_pos = editor_rect.topLeft ();
219 #if defined (HAVE_QSCI_VERSION_2_6_0)
220 if (! in_left_margin)
227 context_menu->addSeparator ();
231 QString lexer_name =
lexer ()->lexer ();
232 if (lexer_name ==
"octave" || lexer_name ==
"matlab")
239 context_menu->addAction (tr (
"Documentation on")
247 #if defined (HAVE_QSCI_VERSION_2_6_0)
254 foreach (a, all_actions)
255 context_menu->removeAction (a);
257 a = context_menu->addAction (tr (
"dbstop if ..."),
this,
259 a->setData (local_pos);
264 context_menu->exec (global_pos);
299 QStringList
commands = selectedText ().split (QRegExp(
"[\r\n]"),
300 QString::SkipEmptyParts);
301 for (
int i = 0;
i < commands.size ();
i++)
311 #if defined (HAVE_QSCI_VERSION_2_6_0)
312 QAction *action = qobject_cast<QAction *>(sender());
313 QPoint local_pos = action->data ().value<QPoint> ();
316 int margins = marginWidth (1) + marginWidth (2) + marginWidth (3);
317 local_pos = QPoint (margins + 1, local_pos.y ());
326 #if defined (HAVE_QSCI_VERSION_2_6_0)
342 QsciScintilla::focusInEvent(focusEvent);
void contextmenu_help_doc(bool)
void context_menu_break_condition_signal(int)
void context_menu_edit_signal(const QString &)
virtual void contextMenuEvent(QContextMenuEvent *e)
void contextmenu_run(bool)
void contextmenu_edit(bool)
void status_update(bool, bool)
void contextmenu_break_once(const QPoint &)
void show_doc_signal(const QString &)
void context_menu_break_once(int)
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
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 &)
=val(i)}if ode{val(i)}occurs in table i
void contextmenu_doc(bool)
void focusInEvent(QFocusEvent *focusEvent)
void contextmenu_break_condition(bool)
void get_global_textcursor_pos(QPoint *global_pos, QPoint *local_pos)
to define functions rather than attempting to enter them directly on the command line The block of commands is executed as soon as you exit the editor To avoid executing any commands