GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
command-widget.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2021-2023 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_command_widget_h)
27 #define octave_command_widget_h 1
28 
29 #include <QWidget>
30 
31 #include <Qsci/qsciscintilla.h>
32 
33 #include "octave-qobject.h"
34 #include "gui-settings.h"
35 
36 class QsciScintilla;
37 
39 
40 class base_qobject;
41 class command_widget;
42 
43 class console : public QsciScintilla
44 {
45  Q_OBJECT
46 
47 public:
48 
49  console (command_widget *p, base_qobject& oct_qobj);
50 
51 public slots:
52 
53  void cursor_position_changed (int line, int col);
54 
55  void text_changed (void);
56 
57  void move_cursor_to_end (void);
58 
59  void new_command_line (const QString& command = QString ());
60 
61  void execute_command (const QString& command);
62 
63 protected:
64 
65  void keyPressEvent (QKeyEvent *e);
66 
67 private:
68 
69  void append_string (const QString& string);
70 
71  void accept_command_line (void);
72 
78 
79 };
80 
81 class command_widget : public QWidget
82 {
83  Q_OBJECT
84 
85 public:
86 
87  command_widget (base_qobject& oct_qobj, QWidget *p);
88 
89  console * get_console ( ) { return m_console; };
90 
91  void init_command_prompt ();
92 
93  QString prompt (void);
94 
95 signals:
96 
97  void clear_line_edit (void);
98 
99  void interpreter_pause (void);
100  void interpreter_resume (void);
101  void interpreter_stop (void);
102 
103  void interpreter_event (const fcn_callback& fcn);
104  void interpreter_event (const meth_callback& meth);
105 
106  void new_command_line_signal (const QString& command = QString ());
107 
108 public slots:
109 
110  void process_input_line (const QString& input_line);
111 
112  void update_prompt (const QString& prompt);
113 
114  void insert_interpreter_output (const QString& msg);
115 
116  void notice_settings (const gui_settings *settings);
117 
118 private:
119 
121  QString m_prompt;
123 };
124 
126 
127 #endif
OCTAVE_END_NAMESPACE(octave)
Base class for Octave interfaces that use Qt.
void new_command_line_signal(const QString &command=QString())
void clear_line_edit(void)
void interpreter_event(const meth_callback &meth)
console * get_console()
QString prompt(void)
void interpreter_event(const fcn_callback &fcn)
command_widget(base_qobject &oct_qobj, QWidget *p)
console * m_console
void process_input_line(const QString &input_line)
void init_command_prompt()
void insert_interpreter_output(const QString &msg)
void interpreter_resume(void)
void notice_settings(const gui_settings *settings)
void update_prompt(const QString &prompt)
void interpreter_stop(void)
void interpreter_pause(void)
bool m_text_changed
QString m_last_key_string
void move_cursor_to_end(void)
void accept_command_line(void)
void execute_command(const QString &command)
command_widget * m_command_widget
void cursor_position_changed(int line, int col)
int m_command_position
int m_cursor_position
console(command_widget *p, base_qobject &oct_qobj)
void text_changed(void)
void new_command_line(const QString &command=QString())
void keyPressEvent(QKeyEvent *e)
void append_string(const QString &string)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::function< void(void)> fcn_callback
Definition: event-manager.h:43
std::function< void(interpreter &)> meth_callback
Definition: event-manager.h:48