Mercurial > octave
changeset 24495:0a567c6489ef
store last comment string which was manually selected (bug #52695)
* file-editor-tab.cc (do_comment_selected_text): propose last comment string
in the input dialog for selecting the comment string;
* octave-settings.h: add key name for new preference (last comment string)
author | Torsten <mttl@mailbox.org> |
---|---|
date | Fri, 29 Dec 2017 22:25:01 +0100 |
parents | 7070fab40871 |
children | 1c96b44feb7a |
files | libgui/src/m-editor/file-editor-tab.cc libgui/src/octave-settings.h |
diffstat | 2 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc Fri Dec 29 08:41:54 2017 -0800 +++ b/libgui/src/m-editor/file-editor-tab.cc Fri Dec 29 22:25:01 2017 +0100 @@ -80,6 +80,7 @@ #include "unwind-prot.h" #include "utils.h" #include "version.h" +#include "octave-settings.h" bool file_editor_tab::_cancelled = false; @@ -1472,13 +1473,18 @@ if (input_str) { bool ok; + QSettings *settings = resource_manager::get_settings (); used_comment_str = QInputDialog::getText ( - this, tr ("Comment selected text"), tr ("Comment string to use:\n"), - QLineEdit::Normal, comment_str.at (0), &ok); + this, tr ("Comment selected text"), + tr ("Comment string to use:\n"), QLineEdit::Normal, + settings->value (oct_last_comment_str, comment_str.at (0)).toString (), + &ok); if ((! ok) || used_comment_str.isEmpty ()) - used_comment_str = comment_str.at (0); // No input, use preference + return; // No input, do nothing + else + settings->setValue (oct_last_comment_str, used_comment_str); // Store last } } else
--- a/libgui/src/octave-settings.h Fri Dec 29 08:41:54 2017 -0800 +++ b/libgui/src/octave-settings.h Fri Dec 29 22:25:01 2017 +0100 @@ -35,6 +35,7 @@ const QString oct_comment_str ("editor/oct_comment_str"); const QString oct_uncomment_str ("editor/oct_uncomment_str"); +const QString oct_last_comment_str ("editor/oct_last_comment_str"); const QStringList oct_comment_strings (QStringList () << "##" << "#" << "%"<< "%%" << "%!"); const int oct_comment_strings_count = 5; const int oct_comment_str_d = 0;