diff libgui/src/command-widget.cc @ 31648:29d734430e5f stable

maint: Re-indent code after switch to using namespace macros. * BaseControl.cc, BaseControl.h, ButtonControl.cc, ButtonControl.h, ButtonGroup.cc, ButtonGroup.h, Canvas.cc, Canvas.h, CheckBoxControl.cc, CheckBoxControl.h, Container.cc, Container.h, ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h, Figure.cc, Figure.h, FigureWindow.cc, FigureWindow.h, GLCanvas.cc, GLCanvas.h, GenericEventNotify.h, KeyMap.cc, KeyMap.h, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Logger.h, Menu.cc, Menu.h, MenuContainer.h, Object.cc, Object.h, ObjectProxy.cc, ObjectProxy.h, Panel.cc, Panel.h, PopupMenuControl.cc, PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.cc, PushTool.h, QtHandlesUtils.cc, QtHandlesUtils.h, RadioButtonControl.cc, RadioButtonControl.h, SliderControl.cc, SliderControl.h, Table.cc, Table.h, TextControl.cc, TextControl.h, TextEdit.cc, TextEdit.h, ToggleButtonControl.cc, ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h, ToolBarButton.cc, ToolBarButton.h, annotation-dialog.cc, annotation-dialog.h, gl-select.cc, gl-select.h, qopengl-functions.h, qt-graphics-toolkit.cc, qt-graphics-toolkit.h, module.mk, QTerminal.h, color-picker.cc, color-picker.h, command-widget.cc, command-widget.h, community-news.cc, community-news.h, dialog.cc, dialog.h, documentation-bookmarks.cc, documentation-bookmarks.h, documentation-dock-widget.cc, documentation-dock-widget.h, documentation.cc, documentation.h, dw-main-window.cc, dw-main-window.h, external-editor-interface.cc, external-editor-interface.h, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, find-files-dialog.h, find-files-model.cc, find-files-model.h, graphics-init.cc, graphics-init.h, gui-settings.cc, gui-settings.h, gui-utils.cc, gui-utils.h, history-dock-widget.cc, history-dock-widget.h, interpreter-qobject.cc, interpreter-qobject.h, led-indicator.cc, led-indicator.h, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, find-dialog.h, marker.cc, marker.h, octave-qscintilla.cc, octave-qscintilla.h, octave-txt-lexer.cc, octave-txt-lexer.h, main-window.cc, main-window.h, news-reader.cc, news-reader.h, octave-dock-widget.cc, octave-dock-widget.h, octave-qobject.cc, octave-qobject.h, qt-application.cc, qt-application.h, qt-interpreter-events.cc, qt-interpreter-events.h, qt-utils.h, release-notes.cc, release-notes.h, resource-manager.cc, resource-manager.h, set-path-dialog.cc, set-path-dialog.h, set-path-model.cc, set-path-model.h, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h, tab-bar.cc, tab-bar.h, terminal-dock-widget.cc, terminal-dock-widget.h, variable-editor-model.cc, variable-editor-model.h, variable-editor.cc, variable-editor.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc, workspace-model.h, workspace-view.cc, workspace-view.h: Re-indent code after switch to using namespace macros.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Dec 2022 14:53:00 -0500
parents c6d54dd31a7e
children deb553ac2c54 597f3ee61a48
line wrap: on
line diff
--- a/libgui/src/command-widget.cc	Tue Dec 06 14:37:51 2022 -0500
+++ b/libgui/src/command-widget.cc	Tue Dec 06 14:53:00 2022 -0500
@@ -50,255 +50,255 @@
 
 OCTAVE_BEGIN_NAMESPACE(octave)
 
-  command_widget::command_widget (base_qobject& oct_qobj, QWidget *p)
-    : QWidget (p), m_incomplete_parse (false),
-      m_prompt (QString ()),
-      m_console (new console (this, oct_qobj))
-  {
-    QPushButton *pause_button = new QPushButton (tr("Pause"), this);
-    QPushButton *stop_button = new QPushButton (tr("Stop"), this);
-    QPushButton *resume_button = new QPushButton (tr("Continue"), this);
+command_widget::command_widget (base_qobject& oct_qobj, QWidget *p)
+: QWidget (p), m_incomplete_parse (false),
+  m_prompt (QString ()),
+  m_console (new console (this, oct_qobj))
+{
+  QPushButton *pause_button = new QPushButton (tr("Pause"), this);
+  QPushButton *stop_button = new QPushButton (tr("Stop"), this);
+  QPushButton *resume_button = new QPushButton (tr("Continue"), this);
 
-    QGroupBox *input_group_box = new QGroupBox ();
-    QHBoxLayout *input_layout = new QHBoxLayout;
-    input_layout->addWidget (pause_button);
-    input_layout->addWidget (stop_button);
-    input_layout->addWidget (resume_button);
-    input_group_box->setLayout (input_layout);
+  QGroupBox *input_group_box = new QGroupBox ();
+  QHBoxLayout *input_layout = new QHBoxLayout;
+  input_layout->addWidget (pause_button);
+  input_layout->addWidget (stop_button);
+  input_layout->addWidget (resume_button);
+  input_group_box->setLayout (input_layout);
 
-    QVBoxLayout *main_layout = new QVBoxLayout ();
-    main_layout->addWidget (m_console);
-    main_layout->addWidget (input_group_box);
+  QVBoxLayout *main_layout = new QVBoxLayout ();
+  main_layout->addWidget (m_console);
+  main_layout->addWidget (input_group_box);
 
-    setLayout (main_layout);
+  setLayout (main_layout);
 
-    setFocusProxy (m_console);
+  setFocusProxy (m_console);
 
-    connect (pause_button, &QPushButton::clicked,
-             this, &command_widget::interpreter_pause);
+  connect (pause_button, &QPushButton::clicked,
+           this, &command_widget::interpreter_pause);
 
-    connect (resume_button, &QPushButton::clicked,
-             this, &command_widget::interpreter_resume);
+  connect (resume_button, &QPushButton::clicked,
+           this, &command_widget::interpreter_resume);
 
-    connect (stop_button, &QPushButton::clicked,
-             this, &command_widget::interpreter_stop);
+  connect (stop_button, &QPushButton::clicked,
+           this, &command_widget::interpreter_stop);
 
-    connect (this, &command_widget::new_command_line_signal,
-             m_console, &console::new_command_line);
+  connect (this, &command_widget::new_command_line_signal,
+           m_console, &console::new_command_line);
 
-    insert_interpreter_output ("\n\n    Welcome to Octave\n\n");
+  insert_interpreter_output ("\n\n    Welcome to Octave\n\n");
 
-  }
+}
 
-  void command_widget::init_command_prompt ()
-  {
-    emit interpreter_event
-      ([=] (interpreter& interp)
-       {
-         // INTERPRETER THREAD
+void command_widget::init_command_prompt ()
+{
+  emit interpreter_event
+    ([=] (interpreter& interp)
+    {
+      // INTERPRETER THREAD
 
-         event_manager& evmgr = interp.get_event_manager ();
-         input_system& input_sys = interp.get_input_system ();
-         std::string prompt = input_sys.PS1 ();
-         evmgr.update_prompt (command_editor::decode_prompt_string (prompt));
+      event_manager& evmgr = interp.get_event_manager ();
+      input_system& input_sys = interp.get_input_system ();
+      std::string prompt = input_sys.PS1 ();
+      evmgr.update_prompt (command_editor::decode_prompt_string (prompt));
 
-         emit new_command_line_signal ();
-       });
-  }
+      emit new_command_line_signal ();
+    });
+}
 
-  void command_widget::update_prompt (const QString& prompt)
-  {
-    m_prompt = prompt;
-  }
+void command_widget::update_prompt (const QString& prompt)
+{
+  m_prompt = prompt;
+}
 
-  QString command_widget::prompt ()
-  {
-    return m_prompt;
-  }
+QString command_widget::prompt ()
+{
+  return m_prompt;
+}
 
-  void command_widget::insert_interpreter_output (const QString& msg)
-  {
-    m_console->append (msg);
-  }
+void command_widget::insert_interpreter_output (const QString& msg)
+{
+  m_console->append (msg);
+}
 
-  void command_widget::process_input_line (const QString& input_line)
-  {
-    emit interpreter_event
-      ([=] (interpreter& interp)
-       {
-         // INTERPRETER THREAD
+void command_widget::process_input_line (const QString& input_line)
+{
+  emit interpreter_event
+    ([=] (interpreter& interp)
+    {
+      // INTERPRETER THREAD
 
-         interp.parse_and_execute (input_line.toStdString (),
-                                   m_incomplete_parse);
+      interp.parse_and_execute (input_line.toStdString (),
+                                m_incomplete_parse);
 
-         event_manager& evmgr = interp.get_event_manager ();
-         input_system& input_sys = interp.get_input_system ();
+      event_manager& evmgr = interp.get_event_manager ();
+      input_system& input_sys = interp.get_input_system ();
 
-         std::string prompt
-           = m_incomplete_parse ? input_sys.PS2 () : input_sys.PS1 ();
+      std::string prompt
+        = m_incomplete_parse ? input_sys.PS2 () : input_sys.PS1 ();
 
-         evmgr.update_prompt (command_editor::decode_prompt_string (prompt));
+      evmgr.update_prompt (command_editor::decode_prompt_string (prompt));
 
-         emit new_command_line_signal ();
-       });
+      emit new_command_line_signal ();
+    });
 
-  }
+}
 
-  void command_widget::notice_settings (const gui_settings *settings)
-  {
-    // Set terminal font:
-    QFont term_font = QFont ();
-    term_font.setStyleHint (QFont::TypeWriter);
-    QString default_font = settings->value (global_mono_font).toString ();
-    term_font.setFamily
-      (settings->value (cs_font.key, default_font).toString ());
-    term_font.setPointSize
-      (settings->value (cs_font_size).toInt ());
+void command_widget::notice_settings (const gui_settings *settings)
+{
+  // Set terminal font:
+  QFont term_font = QFont ();
+  term_font.setStyleHint (QFont::TypeWriter);
+  QString default_font = settings->value (global_mono_font).toString ();
+  term_font.setFamily
+    (settings->value (cs_font.key, default_font).toString ());
+  term_font.setPointSize
+    (settings->value (cs_font_size).toInt ());
 
-    m_console->setFont (term_font);
+  m_console->setFont (term_font);
 
-    // Colors
-    int mode = settings->value (cs_color_mode).toInt ();
-    QColor fgc = settings->color_value (cs_colors[0], mode);
-    QColor bgc = settings->color_value (cs_colors[1], mode);
+  // Colors
+  int mode = settings->value (cs_color_mode).toInt ();
+  QColor fgc = settings->color_value (cs_colors[0], mode);
+  QColor bgc = settings->color_value (cs_colors[1], mode);
 
-    m_console->setStyleSheet (QString ("color: %1; background-color:%2;")
-                                     .arg (fgc.name ()).arg (bgc.name ()));
-  }
+  m_console->setStyleSheet (QString ("color: %1; background-color:%2;")
+                            .arg (fgc.name ()).arg (bgc.name ()));
+}
 
-  // The console itself using QScintilla.
-  // This implementation is partly based on the basic concept of
-  // "qpconsole" as proposed by user "DerManu" in the Qt-forum thread
-  // https://forum.qt.io/topic/28765/command-terminal-using-qtextedit
+// The console itself using QScintilla.
+// This implementation is partly based on the basic concept of
+// "qpconsole" as proposed by user "DerManu" in the Qt-forum thread
+// https://forum.qt.io/topic/28765/command-terminal-using-qtextedit
 
-  console::console (command_widget *p, base_qobject&)
-    : QsciScintilla (p),
-      m_command_position (-1),
-      m_cursor_position (0),
-      m_text_changed (false),
-      m_command_widget (p),
-      m_last_key_string (QString ())
-  {
-    setMargins (0);
-    setWrapMode (QsciScintilla::WrapWord);
+console::console (command_widget *p, base_qobject&)
+  : QsciScintilla (p),
+    m_command_position (-1),
+    m_cursor_position (0),
+    m_text_changed (false),
+    m_command_widget (p),
+    m_last_key_string (QString ())
+{
+  setMargins (0);
+  setWrapMode (QsciScintilla::WrapWord);
 
-    connect (this, SIGNAL (cursorPositionChanged (int, int)),
-             this, SLOT (cursor_position_changed (int, int)));
+  connect (this, SIGNAL (cursorPositionChanged (int, int)),
+           this, SLOT (cursor_position_changed (int, int)));
 
-    connect (this, SIGNAL (textChanged (void)),
-             this, SLOT (text_changed (void)));
+  connect (this, SIGNAL (textChanged (void)),
+           this, SLOT (text_changed (void)));
 
-    connect (this, SIGNAL (modificationAttempted (void)),
-             this, SLOT (move_cursor_to_end (void)));
-  }
+  connect (this, SIGNAL (modificationAttempted (void)),
+           this, SLOT (move_cursor_to_end (void)));
+}
 
-  // Prepare a new command line with the current prompt
-  void console::new_command_line (const QString& command)
-  {
-    if (! text (lines () -1).isEmpty ())
-      append ("\n");
+// Prepare a new command line with the current prompt
+void console::new_command_line (const QString& command)
+{
+  if (! text (lines () -1).isEmpty ())
+    append ("\n");
 
-    append_string (m_command_widget->prompt ());
+  append_string (m_command_widget->prompt ());
 
-    int line, index;
-    getCursorPosition (&line,&index);
-    m_command_position = positionFromLineIndex (line, index);
+  int line, index;
+  getCursorPosition (&line,&index);
+  m_command_position = positionFromLineIndex (line, index);
 
-    append_string (command);
-  }
+  append_string (command);
+}
 
-  // Accept the current command line (or block)
-  void console::accept_command_line ()
-  {
-    QString input_line = text (lines () - 1);
+// Accept the current command line (or block)
+void console::accept_command_line ()
+{
+  QString input_line = text (lines () - 1);
 
-    if (input_line.startsWith (m_command_widget->prompt ()))
-      input_line.remove(0, m_command_widget->prompt ().length ());
+  if (input_line.startsWith (m_command_widget->prompt ()))
+    input_line.remove(0, m_command_widget->prompt ().length ());
 
-    input_line = input_line.trimmed ();
+  input_line = input_line.trimmed ();
 
-    append_string ("\n");
+  append_string ("\n");
 
-    if (input_line.isEmpty ())
-      new_command_line ();
-    else
-      m_command_widget->process_input_line (input_line);
-  }
+  if (input_line.isEmpty ())
+    new_command_line ();
+  else
+    m_command_widget->process_input_line (input_line);
+}
 
-  // Execute a command
-  void console::execute_command (const QString& command)
-  {
-    if (command.trimmed ().isEmpty ())
-      return;
+// Execute a command
+void console::execute_command (const QString& command)
+{
+  if (command.trimmed ().isEmpty ())
+    return;
 
-    new_command_line (command);
-    accept_command_line ();
-  }
+  new_command_line (command);
+  accept_command_line ();
+}
 
-  // Append a string and update the curdor püosition
-  void console::append_string (const QString& string)
-  {
-    setReadOnly (false);
-    append (string);
+// Append a string and update the curdor püosition
+void console::append_string (const QString& string)
+{
+  setReadOnly (false);
+  append (string);
 
-    int line, index;
-    lineIndexFromPosition (text ().length (), &line, &index);
+  int line, index;
+  lineIndexFromPosition (text ().length (), &line, &index);
 
-    setCursorPosition (line, index);
-  }
+  setCursorPosition (line, index);
+}
 
-  // Cursor position changed: Are we in the command line or not?
-  void console::cursor_position_changed (int line, int col)
-  {
-    m_cursor_position = positionFromLineIndex (line, col);
-    if (m_cursor_position < m_command_position)
-      {
-        // We are in the read only area
-        if (m_text_changed && (m_cursor_position == m_command_position - 1))
-          {
-            setReadOnly (false);
-            insert (m_command_widget->prompt ().right (1)); // And here we have tried to remove the prompt by Backspace
-            setCursorPosition (line+1, col);
-          }
-        setReadOnly (true);
-      }
-    else
-      setReadOnly (false);  // Writable area
+// Cursor position changed: Are we in the command line or not?
+void console::cursor_position_changed (int line, int col)
+{
+  m_cursor_position = positionFromLineIndex (line, col);
+  if (m_cursor_position < m_command_position)
+    {
+      // We are in the read only area
+      if (m_text_changed && (m_cursor_position == m_command_position - 1))
+        {
+          setReadOnly (false);
+          insert (m_command_widget->prompt ().right (1)); // And here we have tried to remove the prompt by Backspace
+          setCursorPosition (line+1, col);
+        }
+      setReadOnly (true);
+    }
+  else
+    setReadOnly (false);  // Writable area
 
-    m_text_changed = false;
-  }
+  m_text_changed = false;
+}
 
-  // User attempted to type on read only mode: move cursor at end and allow
-  // editing
-  void console::move_cursor_to_end (void)
-  {
-    if ((! m_last_key_string.isEmpty ()) && (m_last_key_string.at (0).isPrint ()))
-      {
-        append_string (m_last_key_string);
-        setReadOnly (true); // Avoid that changing read only text is done afterwards
-      }
-  }
+// User attempted to type on read only mode: move cursor at end and allow
+// editing
+void console::move_cursor_to_end (void)
+{
+  if ((! m_last_key_string.isEmpty ()) && (m_last_key_string.at (0).isPrint ()))
+    {
+      append_string (m_last_key_string);
+      setReadOnly (true); // Avoid that changing read only text is done afterwards
+    }
+}
 
-  // Text has changed: is cursor still in "writable" area?
-  // This signal seems to be emitted before cursor position changed.
-  void console::text_changed (void)
-  {
-    m_text_changed = true;
-  }
+// Text has changed: is cursor still in "writable" area?
+// This signal seems to be emitted before cursor position changed.
+void console::text_changed (void)
+{
+  m_text_changed = true;
+}
 
-  // Re-implement key event
-  void console::keyPressEvent (QKeyEvent *e)
-  {
-    if (e->key () == Qt::Key_Return)
-      // On "return", accept the current command line
-      accept_command_line ();
-    else
-      {
-        // Otherwise, store text process the expected event
-        m_last_key_string = e->text ();
-        QsciScintilla::keyPressEvent(e);
-      }
-  }
+// Re-implement key event
+void console::keyPressEvent (QKeyEvent *e)
+{
+  if (e->key () == Qt::Key_Return)
+    // On "return", accept the current command line
+    accept_command_line ();
+  else
+    {
+      // Otherwise, store text process the expected event
+      m_last_key_string = e->text ();
+      QsciScintilla::keyPressEvent(e);
+    }
+}
 
 OCTAVE_END_NAMESPACE(octave)