Mercurial > hg > octave-nkf
changeset 19440:54943eb0ce37 gui-release
reorder eol modes in the editor settings
* settings-dialog.ui: order the eol mode such that their indexes correspond
to the values of the enum value in scintilla
* file-editor-tab.cc (detect_eol_mode): use settings or OS eol mode as default
if no detection is possible (e.g. empty file);
(new_file): use static cast from int to eol enum instead of array
* settings-dialog.cc (constructor): choose 2 (EolUnix) as default eol mode if
qscintilla is not available
author | Torsten <ttl@justmail.de> |
---|---|
date | Sat, 11 Oct 2014 15:44:07 +0200 |
parents | 9582fad68730 |
children | d10c711a08d8 |
files | libgui/src/m-editor/file-editor-tab.cc libgui/src/settings-dialog.cc libgui/src/settings-dialog.ui |
diffstat | 3 files changed, 40 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -1369,17 +1369,34 @@ } } - QsciScintilla::EolMode eol_mode = QsciScintilla::EolUnix; - int count_max = count_lf; + // get default from OS or from settings +#if defined (Q_OS_WIN32) + int os_eol_mode = QsciScintilla::EolWindows; +#elif defined (Q_OS_MAC) + int os_eol_mode = QsciScintilla::EolMac; +#else + int os_eol_mode = QsciScintilla::EolUnix; +#endif +QSettings *settings = resource_manager::get_settings (); +QsciScintilla::EolMode eol_mode = static_cast<QsciScintilla::EolMode> ( + settings->value("editor/default_eol_mode",os_eol_mode).toInt ()); + int count_max = 0; + + if (count_crlf > count_max) + { + eol_mode = QsciScintilla::EolWindows; + count_max = count_crlf; + } if (count_cr > count_max) { eol_mode = QsciScintilla::EolMac; count_max = count_cr; } - if (count_crlf > count_max) + if (count_lf > count_max) { - eol_mode = QsciScintilla::EolWindows; + eol_mode = QsciScintilla::EolUnix; + count_max = count_lf; } return eol_mode; @@ -1411,9 +1428,6 @@ // 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) @@ -1422,7 +1436,8 @@ int eol_mode = QsciScintilla::EolUnix; #endif _edit_area->setEolMode ( - eol_modes[settings->value("editor/default_eol_mode",eol_mode).toInt ()]); + static_cast<QsciScintilla::EolMode> ( + settings->value("editor/default_eol_mode",eol_mode).toInt ())); update_eol_indicator ();
--- a/libgui/src/settings-dialog.cc +++ b/libgui/src/settings-dialog.cc @@ -196,7 +196,7 @@ int eol_mode = QsciScintilla::EolUnix; #endif #else - int eol_mode = 1; + int eol_mode = 2; #endif ui->combo_eol_mode->setCurrentIndex ( settings->value ("editor/default_eol_mode",eol_mode).toInt () );
--- a/libgui/src/settings-dialog.ui +++ b/libgui/src/settings-dialog.ui @@ -52,8 +52,8 @@ <rect> <x>0</x> <y>0</y> - <width>678</width> - <height>378</height> + <width>560</width> + <height>353</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_17"> @@ -697,24 +697,24 @@ <item> <widget class="QComboBox" name="combo_eol_mode"> <property name="sizeAdjustPolicy"> - <enum>QComboBox::AdjustToMinimumContentsLength</enum> + <enum>QComboBox::AdjustToContents</enum> </property> <property name="minimumContentsLength"> <number>7</number> </property> <item> <property name="text"> - <string>Windows</string> + <string>Windows (CRLF)</string> </property> </item> <item> <property name="text"> - <string>Unix</string> + <string>Mac (CR)</string> </property> </item> <item> <property name="text"> - <string>Mac</string> + <string>Unix (LF)</string> </property> </item> </widget> @@ -1280,8 +1280,8 @@ <rect> <x>0</x> <y>0</y> - <width>678</width> - <height>378</height> + <width>488</width> + <height>262</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_7"> @@ -1545,8 +1545,8 @@ <rect> <x>0</x> <y>0</y> - <width>678</width> - <height>378</height> + <width>474</width> + <height>318</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_18"> @@ -1709,8 +1709,8 @@ <rect> <x>0</x> <y>0</y> - <width>678</width> - <height>378</height> + <width>203</width> + <height>134</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_19"> @@ -1784,8 +1784,8 @@ <rect> <x>0</x> <y>0</y> - <width>678</width> - <height>378</height> + <width>368</width> + <height>244</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_25"> @@ -2047,8 +2047,8 @@ <rect> <x>0</x> <y>0</y> - <width>678</width> - <height>378</height> + <width>529</width> + <height>204</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_20">