Mercurial > hg > octave-nkf
comparison libgui/src/m-editor/file-editor-tab.cc @ 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 | 9582fad68730 |
comparison
equal
deleted
inserted
replaced
19436:05d8e71d20cb | 19437:f3c4b48f3c53 |
---|---|
1394 | 1394 |
1395 void | 1395 void |
1396 file_editor_tab::new_file (const QString &commands) | 1396 file_editor_tab::new_file (const QString &commands) |
1397 { | 1397 { |
1398 update_window_title (false); // window title (no modification) | 1398 update_window_title (false); // window title (no modification) |
1399 | |
1400 QSettings *settings = resource_manager::get_settings (); | |
1401 | |
1402 // set the eol mode from the settings or depending on the OS if the entry is | |
1403 // missing in the settings | |
1404 QsciScintilla::EolMode eol_modes[] = | |
1405 {QsciScintilla::EolWindows, QsciScintilla::EolUnix, QsciScintilla::EolMac}; | |
1406 | |
1407 #if defined (Q_OS_WIN32) | |
1408 int eol_mode = QsciScintilla::EolWindows; | |
1409 #elif defined (Q_OS_MAC) | |
1410 int eol_mode = QsciScintilla::EolMac; | |
1411 #else | |
1412 int eol_mode = QsciScintilla::EolUnix; | |
1413 #endif | |
1414 _edit_area->setEolMode ( | |
1415 eol_modes[settings->value("editor/default_eol_mode",eol_mode).toInt ()]); | |
1416 | |
1417 update_eol_indicator (); | |
1418 | |
1399 _edit_area->setText (commands); | 1419 _edit_area->setText (commands); |
1400 _edit_area->setModified (false); // new file is not modified yet | 1420 _edit_area->setModified (false); // new file is not modified yet |
1401 update_eol_indicator (); | |
1402 } | 1421 } |
1403 | 1422 |
1404 void | 1423 void |
1405 file_editor_tab::save_file (const QString& saveFileName, bool remove_on_success) | 1424 file_editor_tab::save_file (const QString& saveFileName, bool remove_on_success) |
1406 { | 1425 { |
1733 else | 1752 else |
1734 _edit_area->setWhitespaceVisibility (QsciScintilla::WsVisible); | 1753 _edit_area->setWhitespaceVisibility (QsciScintilla::WsVisible); |
1735 else | 1754 else |
1736 _edit_area->setWhitespaceVisibility (QsciScintilla::WsInvisible); | 1755 _edit_area->setWhitespaceVisibility (QsciScintilla::WsInvisible); |
1737 | 1756 |
1757 _edit_area->setEolVisibility ( | |
1758 settings->value("editor/show_eol_chars",false).toBool ()); | |
1759 | |
1738 if (settings->value ("editor/showLineNumbers", true).toBool ()) | 1760 if (settings->value ("editor/showLineNumbers", true).toBool ()) |
1739 { | 1761 { |
1740 _edit_area->setMarginLineNumbers (2, true); | 1762 _edit_area->setMarginLineNumbers (2, true); |
1741 auto_margin_width (); | 1763 auto_margin_width (); |
1742 connect (_edit_area, SIGNAL (linesChanged ()), | 1764 connect (_edit_area, SIGNAL (linesChanged ()), |