# HG changeset patch # User Torsten # Date 1413035047 -7200 # Node ID 54943eb0ce3751b330ba5ad1b281a515c31e12d4 # Parent 9582fad687303d7b5a1aaf5e5d549a1517f4846f 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 diff -r 9582fad68730 -r 54943eb0ce37 libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Sat Oct 11 11:15:59 2014 +0200 +++ b/libgui/src/m-editor/file-editor-tab.cc Sat Oct 11 15:44:07 2014 +0200 @@ -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 ( + 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 ( + settings->value("editor/default_eol_mode",eol_mode).toInt ())); update_eol_indicator (); diff -r 9582fad68730 -r 54943eb0ce37 libgui/src/settings-dialog.cc --- a/libgui/src/settings-dialog.cc Sat Oct 11 11:15:59 2014 +0200 +++ b/libgui/src/settings-dialog.cc Sat Oct 11 15:44:07 2014 +0200 @@ -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 () ); diff -r 9582fad68730 -r 54943eb0ce37 libgui/src/settings-dialog.ui --- a/libgui/src/settings-dialog.ui Sat Oct 11 11:15:59 2014 +0200 +++ b/libgui/src/settings-dialog.ui Sat Oct 11 15:44:07 2014 +0200 @@ -52,8 +52,8 @@ 0 0 - 678 - 378 + 560 + 353 @@ -697,24 +697,24 @@ - QComboBox::AdjustToMinimumContentsLength + QComboBox::AdjustToContents 7 - Windows + Windows (CRLF) - Unix + Mac (CR) - Mac + Unix (LF) @@ -1280,8 +1280,8 @@ 0 0 - 678 - 378 + 488 + 262 @@ -1545,8 +1545,8 @@ 0 0 - 678 - 378 + 474 + 318 @@ -1709,8 +1709,8 @@ 0 0 - 678 - 378 + 203 + 134 @@ -1784,8 +1784,8 @@ 0 0 - 678 - 378 + 368 + 244 @@ -2047,8 +2047,8 @@ 0 0 - 678 - 378 + 529 + 204