Mercurial > hg > octave-nkf
changeset 19437:f3c4b48f3c53 gui-release
add a preference for the default eol mode of new files (bug #43334)
* file-editor-tab.cc (new_file): get eol mode from the settings or from the OS;
(notice_settings): set visibility of eol chars depending on settings
* settings-dialog.ui: new checkbox for showing eol chars, new combobox for
the default eol mode
* settings-dialog.cc (constructor): init preferences for showing eol chars and
for the default eol mode from the settings;
(write_changed_settings): write these new preferences to the settings files
author | Torsten <ttl@justmail.de> |
---|---|
date | Sat, 11 Oct 2014 11:05:53 +0200 |
parents | 05d8e71d20cb |
children | 62756ba9e4e5 |
files | libgui/src/m-editor/file-editor-tab.cc libgui/src/settings-dialog.cc libgui/src/settings-dialog.ui |
diffstat | 3 files changed, 138 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -1396,9 +1396,28 @@ file_editor_tab::new_file (const QString &commands) { update_window_title (false); // window title (no modification) + + QSettings *settings = resource_manager::get_settings (); + + // set the eol mode from the settings or depending on the OS if the entry is + // missing in the settings + QsciScintilla::EolMode eol_modes[] = + {QsciScintilla::EolWindows, QsciScintilla::EolUnix, QsciScintilla::EolMac}; + +#if defined (Q_OS_WIN32) + int eol_mode = QsciScintilla::EolWindows; +#elif defined (Q_OS_MAC) + int eol_mode = QsciScintilla::EolMac; +#else + int eol_mode = QsciScintilla::EolUnix; +#endif + _edit_area->setEolMode ( + eol_modes[settings->value("editor/default_eol_mode",eol_mode).toInt ()]); + + update_eol_indicator (); + _edit_area->setText (commands); _edit_area->setModified (false); // new file is not modified yet - update_eol_indicator (); } void @@ -1735,6 +1754,9 @@ else _edit_area->setWhitespaceVisibility (QsciScintilla::WsInvisible); + _edit_area->setEolVisibility ( + settings->value("editor/show_eol_chars",false).toBool ()); + if (settings->value ("editor/showLineNumbers", true).toBool ()) { _edit_area->setMarginLineNumbers (2, true);
--- a/libgui/src/settings-dialog.cc +++ b/libgui/src/settings-dialog.cc @@ -36,6 +36,7 @@ #include <QHash> #ifdef HAVE_QSCINTILLA +#include "octave-qscintilla.h" #include <QScrollArea> #if defined (HAVE_QSCI_QSCILEXEROCTAVE_H) @@ -184,6 +185,21 @@ settings->value ("editor/show_white_space", false).toBool ()); ui->editor_ws_indent_checkbox->setChecked ( settings->value ("editor/show_white_space_indent",false).toBool ()); + ui->cb_show_eol->setChecked ( + settings->value ("editor/show_eol_chars",false).toBool () ); +#ifdef HAVE_QSCINTILLA +#if defined (Q_OS_WIN32) + int eol_mode = QsciScintilla::EolWindows; +#elif defined (Q_OS_MAC) + int eol_mode = QsciScintilla::EolMac; +#else + int eol_mode = QsciScintilla::EolUnix; +#endif +#else + int eol_mode = 1; +#endif + ui->combo_eol_mode->setCurrentIndex ( + settings->value ("editor/default_eol_mode",eol_mode).toInt () ); ui->editor_auto_ind_checkbox->setChecked ( settings->value ("editor/auto_indent", true).toBool ()); ui->editor_tab_ind_checkbox->setChecked ( @@ -633,6 +649,10 @@ ui->editor_ws_checkbox->isChecked ()); settings->setValue ("editor/show_white_space_indent", ui->editor_ws_indent_checkbox->isChecked ()); + settings->setValue ("editor/show_eol_chars", + ui->cb_show_eol->isChecked ()); + settings->setValue ("editor/default_eol_mode", + ui->combo_eol_mode->currentIndex ()); settings->setValue ("editor/auto_indent", ui->editor_auto_ind_checkbox->isChecked ()); settings->setValue ("editor/tab_indents_line",
--- a/libgui/src/settings-dialog.ui +++ b/libgui/src/settings-dialog.ui @@ -32,7 +32,7 @@ </size> </property> <property name="currentIndex"> - <number>5</number> + <number>1</number> </property> <widget class="QWidget" name="tab_general"> <property name="enabled"> @@ -406,7 +406,7 @@ <x>0</x> <y>0</y> <width>662</width> - <height>580</height> + <height>613</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_16"> @@ -417,6 +417,43 @@ <property name="horizontalSpacing"> <number>6</number> </property> + <item row="6" column="2"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLabel" name="editor_long_line_column_text"> + <property name="text"> + <string>After Column</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="editor_long_line_column"> + <property name="minimum"> + <number>2</number> + </property> + <property name="maximum"> + <number>256</number> + </property> + <property name="value"> + <number>80</number> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_7"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> <item row="3" column="0"> <widget class="QCheckBox" name="editor_ws_checkbox"> <property name="text"> @@ -457,7 +494,7 @@ </property> </widget> </item> - <item row="4" column="0"> + <item row="5" column="0"> <widget class="QCheckBox" name="editor_highlightCurrentLine"> <property name="enabled"> <bool>true</bool> @@ -467,7 +504,7 @@ </property> </widget> </item> - <item row="4" column="2"> + <item row="5" column="2"> <layout class="QGridLayout" name="editor_grid_current_line" rowstretch="0" columnstretch="0,0,0,0,0"> <property name="horizontalSpacing"> <number>12</number> @@ -608,7 +645,7 @@ </property> </spacer> </item> - <item row="5" column="0"> + <item row="6" column="0"> <widget class="QCheckBox" name="editor_long_line_marker"> <property name="toolTip"> <string>This works well for monospaced fonts. The line is drawn at a position based on the width of a space character in the default font. It may not work very well if styles use proportional fonts or if varied font sizes or bold, italic and normal texts are used.</string> @@ -621,30 +658,69 @@ </property> </widget> </item> - <item row="5" column="2"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item row="7" column="0"> + <widget class="QCheckBox" name="cb_code_folding"> + <property name="text"> + <string>Enable Code Folding</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="8" column="0"> + <widget class="QCheckBox" name="cb_edit_status_bar"> + <property name="text"> + <string>Show status bar</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QCheckBox" name="cb_show_eol"> + <property name="text"> + <string>Show eol characters</string> + </property> + </widget> + </item> + <item row="4" column="2"> + <layout class="QHBoxLayout" name="horizontalLayout_17"> <item> - <widget class="QLabel" name="editor_long_line_column_text"> + <widget class="QLabel" name="label_22"> <property name="text"> - <string>After Column</string> + <string>Default eol mode</string> </property> </widget> </item> <item> - <widget class="QSpinBox" name="editor_long_line_column"> - <property name="minimum"> - <number>2</number> + <widget class="QComboBox" name="combo_eol_mode"> + <property name="sizeAdjustPolicy"> + <enum>QComboBox::AdjustToMinimumContentsLength</enum> + </property> + <property name="minimumContentsLength"> + <number>7</number> </property> - <property name="maximum"> - <number>256</number> - </property> - <property name="value"> - <number>80</number> - </property> + <item> + <property name="text"> + <string>Windows</string> + </property> + </item> + <item> + <property name="text"> + <string>Unix</string> + </property> + </item> + <item> + <property name="text"> + <string>Mac</string> + </property> + </item> </widget> </item> <item> - <spacer name="horizontalSpacer_7"> + <spacer name="horizontalSpacer_17"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> @@ -658,26 +734,6 @@ </item> </layout> </item> - <item row="6" column="0"> - <widget class="QCheckBox" name="cb_code_folding"> - <property name="text"> - <string>Enable Code Folding</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="7" column="0"> - <widget class="QCheckBox" name="cb_edit_status_bar"> - <property name="text"> - <string>Show status bar</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> </layout> </item> <item>