Mercurial > octave
changeset 28390:f3200b8cff19
maint: merge stable to default.
file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h,
__print_parse_opts__.m: merge from stable.
* plotyy.m: merge from stable, and change "activepositionproperty" to
"positionconstraint".
author | Rik <rik@octave.org> |
---|---|
date | Mon, 01 Jun 2020 11:33:39 -0700 |
parents | 28676df1deaf (current diff) 38ebf4885e0f (diff) |
children | c126a60b0d52 |
files | libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h libgui/src/m-editor/file-editor.cc scripts/plot/draw/plotyy.m scripts/plot/util/private/__print_parse_opts__.m |
diffstat | 6 files changed, 93 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc Sun May 31 09:56:56 2020 -0700 +++ b/libgui/src/m-editor/file-editor-tab.cc Mon Jun 01 11:33:39 2020 -0700 @@ -107,6 +107,7 @@ m_lexer_apis = nullptr; m_is_octave_file = true; m_lines_changed = false; + m_autoc_active = false; m_ced = directory_arg; @@ -264,8 +265,6 @@ if (settings) notice_settings (settings, true); - setFocusProxy (m_edit_area); - // encoding, not updated with the settings QString locale_enc_name = QString ("SYSTEM (") + @@ -1448,6 +1447,8 @@ if (ID != this) return; + m_autoc_active = true; + QsciScintilla::AutoCompletionSource s = m_edit_area->autoCompletionSource (); switch (s) { @@ -3042,9 +3043,19 @@ void file_editor_tab::handle_cursor_moved (int line, int col) { + // Cursor has moved, first check wether an autocompletion list + // is active or if it was closed. Scintilla provides signals for + // completed or cancelled lists, but not for list that where hidden + // due to a new character not matching anymore with the list entries if (m_edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCACTIVE)) - show_auto_completion (this); - + m_autoc_active = true; + else if (m_autoc_active) + { + m_autoc_active = false; + emit autoc_closed (); // Tell editor about closed list + } + + // Lines changed? Take care of indentation if (m_lines_changed) // cursor moved and lines have changed { m_lines_changed = false; @@ -3057,9 +3068,9 @@ } } + // Update line and column indicator in the status bar m_line = line; m_col = col; - m_row_indicator->setNum (line+1); m_col_indicator->setNum (col+1); }
--- a/libgui/src/m-editor/file-editor-tab.h Sun May 31 09:56:56 2020 -0700 +++ b/libgui/src/m-editor/file-editor-tab.h Mon Jun 01 11:33:39 2020 -0700 @@ -86,6 +86,8 @@ void edit_mfile_request (const QString&, const QString&, const QString&, int); + void autoc_closed (void); + void update_breakpoints_signal (const octave_value_list& args); void remove_breakpoint_via_debugger_linenr (int debugger_linenr); @@ -314,6 +316,7 @@ QString m_new_encoding; QDateTime m_last_modified; + bool m_autoc_active; bool m_long_title; bool m_copy_available; bool m_is_octave_file;
--- a/libgui/src/m-editor/file-editor.cc Sun May 31 09:56:56 2020 -0700 +++ b/libgui/src/m-editor/file-editor.cc Mon Jun 01 11:33:39 2020 -0700 @@ -92,6 +92,7 @@ return retval; } + // File editor file_editor::file_editor (QWidget *p, base_qobject& oct_qobj) @@ -120,6 +121,7 @@ setVisible (false); setAcceptDrops (true); + setFocusPolicy (Qt::StrongFocus); } file_editor::~file_editor (void) @@ -127,6 +129,18 @@ delete m_mru_file_menu; } + void file_editor::focusInEvent (QFocusEvent *e) + { + // The focus is transferred to the active tab and its edit + // area in this focus in event handler. This is to avoid + // using focus proxies with conflicts in the proxy change + // presumably introduced by bug + // https://bugreports.qt.io/browse/QTBUG-61092 + reset_focus (); // Make sure editor tab with edit area get focus + + QDockWidget::focusInEvent (e); + } + // insert global actions, that should also be displayed in the editor window, // into the editor's menu and/or toolbar void file_editor::insert_global_actions (QList<QAction*> shared_actions) @@ -338,9 +352,7 @@ octave_dock_widget::activate (); // set focus to current tab - QWidget *fileEditorTab = m_tab_widget->currentWidget (); - if (fileEditorTab) - emit fetab_set_focus (fileEditorTab); + reset_focus (); } void file_editor::set_focus (QWidget *fet) @@ -963,8 +975,6 @@ m_cut_action->setEnabled (copy_available); m_run_selection_action->setEnabled (copy_available); m_run_action->setEnabled (is_octave_file); - - setFocusProxy (m_tab_widget->currentWidget ()); } m_copy_action_enabled = m_copy_action->isEnabled (); @@ -2294,6 +2304,40 @@ check_actions (); } + // Slot when autocompletion list was cancelled + void file_editor::handle_autoc_cancelled (void) + { + // List was cancelled but somehow still active and blocking the + // edit area from accepting shortcuts. Only after another keypress + // shortcuts and lists are working againnas expected. This is + // probably caused by qt bug https://bugreports.qt.io/browse/QTBUG-83720 + // Hack: Accept the list, which is hidden but still active + // and undo the text insertion, if any + + file_editor_tab *f = reset_focus (); + octave_qscintilla *qsci = f->qsci_edit_area (); + + int line, col; + qsci->getCursorPosition (&line, &col); + int l1 = qsci->lineLength (line); // Current line length + + // Accept autocompletion + qsci->SendScintilla (QsciScintillaBase::SCI_AUTOCCOMPLETE); + + // Was text inserted? If yes, undo + if (qsci->text (line).length () - l1) + qsci->undo (); + } + + file_editor_tab* file_editor::reset_focus (void) + { + // Reset the focus of the tab and the related edit area + file_editor_tab *f + = static_cast<file_editor_tab *> (m_tab_widget->currentWidget ()); + emit fetab_set_focus (f); + return f; + } + file_editor_tab * file_editor::make_file_editor_tab (const QString& directory) { @@ -2317,7 +2361,17 @@ SIGNAL (focus_console_after_command_signal (void)), main_win (), SLOT (focus_console_after_command (void))); + connect (f->qsci_edit_area (), + SIGNAL (SCN_AUTOCCOMPLETED (const char*, int, int, int)), + this, SLOT (reset_focus (void))); + + connect (f->qsci_edit_area (), SIGNAL (SCN_AUTOCCANCELLED (void)), + this, SLOT (handle_autoc_cancelled (void))); + // Signals from the file editor_tab + connect (f, SIGNAL (autoc_closed (void)), + this, SLOT (reset_focus (void))); + connect (f, SIGNAL (file_name_changed (const QString&, const QString&, bool)), this, SLOT (handle_file_name_changed (const QString&, const QString&, bool)));
--- a/libgui/src/m-editor/file-editor.h Sun May 31 09:56:56 2020 -0700 +++ b/libgui/src/m-editor/file-editor.h Mon Jun 01 11:33:39 2020 -0700 @@ -274,6 +274,10 @@ void toplevel_change (bool toplevel); + void handle_autoc_cancelled (void); + + file_editor_tab* reset_focus (void); + protected slots: void copyClipboard (void); @@ -311,6 +315,7 @@ void closeEvent (QCloseEvent *event); void dragEnterEvent (QDragEnterEvent *event); void dropEvent (QDropEvent *event); + void focusInEvent (QFocusEvent *e); private:
--- a/scripts/plot/draw/plotyy.m Sun May 31 09:56:56 2020 -0700 +++ b/scripts/plot/draw/plotyy.m Mon Jun 01 11:33:39 2020 -0700 @@ -232,7 +232,13 @@ unwind_protect recursion = true; val = get (h, prop); - set (ax2, prop, get (h, prop)); + if (strcmpi (prop, "position") || strcmpi (prop, "outerposition")) + ## Save/restore "positionconstraint" + constraint = get (ax2, "positionconstraint"); + set (ax2, prop, get (h, prop), "positionconstraint", constraint); + else + set (ax2, prop, get (h, prop)); + endif unwind_protect_cleanup recursion = false; end_unwind_protect
--- a/scripts/plot/util/private/__print_parse_opts__.m Sun May 31 09:56:56 2020 -0700 +++ b/scripts/plot/util/private/__print_parse_opts__.m Mon Jun 01 11:33:39 2020 -0700 @@ -91,7 +91,9 @@ for i = 1:numel (varargin) arg = strtrim (varargin{i}); if (ischar (arg)) - if (strcmp (arg, "-color")) + if (isempty (arg)) + continue; + elseif (strcmp (arg, "-color")) arg_st.use_color = 1; elseif (strcmp (arg, "-append")) arg_st.append_to_file = true;