Mercurial > octave-nkf
changeset 19281:9582fad68730 gui-release
add actions for converting the eol characters of the editor file
* file-editor-tab.cc (convert_eol): new slot for converting the line endings
* file-editor-tab.h: new slot convert_eol
* file-editor.cc (request_conv_eol_windows, request_conv_eol_unix,
request_conv_eol_mac): new slots for converting the line ending,
emitting new signal for activating the slot convert_eol in file_editor_tab;
(constructor): add separators to the edit/format menu, add new actions for
converting the line endings;
(set_shortcuts): set the shortcuts for the new actions
* file-editor.h: new function, new actions, and new signal
* shortcut_manager.cc (do_init_data): set the initial shortcuts for new actions
author | Torsten <ttl@justmail.de> |
---|---|
date | Sat, 11 Oct 2014 11:15:59 +0200 |
parents | 62756ba9e4e5 |
children | 54943eb0ce37 |
files | libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h libgui/src/shortcut-manager.cc |
diffstat | 5 files changed, 69 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc Sat Oct 11 11:08:21 2014 +0200 +++ b/libgui/src/m-editor/file-editor-tab.cc Sat Oct 11 11:15:59 2014 +0200 @@ -947,6 +947,16 @@ do_indent_selected_text (false); } +void +file_editor_tab::convert_eol (const QWidget *ID, QsciScintilla::EolMode eol_mode) +{ + if (ID != this) + return; + + _edit_area->convertEols (eol_mode); + _edit_area->setEolMode (eol_mode); + update_eol_indicator (); +} void file_editor_tab::zoom_in (const QWidget *ID)
--- a/libgui/src/m-editor/file-editor-tab.h Sat Oct 11 11:08:21 2014 +0200 +++ b/libgui/src/m-editor/file-editor-tab.h Sat Oct 11 11:15:59 2014 +0200 @@ -96,6 +96,7 @@ void indent_selected_text (const QWidget *ID); void unindent_selected_text (const QWidget *ID); + void convert_eol (const QWidget *ID, QsciScintilla::EolMode); void zoom_in (const QWidget *ID); void zoom_out (const QWidget *ID);
--- a/libgui/src/m-editor/file-editor.cc Sat Oct 11 11:08:21 2014 +0200 +++ b/libgui/src/m-editor/file-editor.cc Sat Oct 11 11:15:59 2014 +0200 @@ -812,6 +812,25 @@ emit fetab_unindent_selected_text (_tab_widget->currentWidget ()); } +void +file_editor::request_conv_eol_windows (bool) +{ + emit fetab_convert_eol (_tab_widget->currentWidget (), + QsciScintilla::EolWindows); +} +void +file_editor::request_conv_eol_unix (bool) +{ + emit fetab_convert_eol (_tab_widget->currentWidget (), + QsciScintilla::EolUnix); +} +void +file_editor::request_conv_eol_mac (bool) +{ + emit fetab_convert_eol (_tab_widget->currentWidget (), + QsciScintilla::EolMac); +} + void file_editor::request_find (bool) @@ -1325,15 +1344,33 @@ tr ("&Uppercase Selection"), SLOT (request_upper_case (bool))); _lower_case_action = add_action (_edit_fmt_menu, QIcon (), tr ("&Lowercase Selection"), SLOT (request_lower_case (bool))); + + _edit_fmt_menu->addSeparator (); + _comment_selection_action = add_action (_edit_fmt_menu, QIcon (), tr ("&Comment"), SLOT (request_comment_selected_text (bool))); _uncomment_selection_action = add_action (_edit_fmt_menu, QIcon (), tr ("&Uncomment"), SLOT (request_uncomment_selected_text (bool))); + + _edit_fmt_menu->addSeparator (); + _indent_selection_action = add_action (_edit_fmt_menu, QIcon (), tr ("&Indent"), SLOT (request_indent_selected_text (bool))); _unindent_selection_action = add_action (_edit_fmt_menu, QIcon (), tr ("&Unindent"), SLOT (request_unindent_selected_text (bool))); + _edit_fmt_menu->addSeparator (); + + _conv_eol_windows_action = add_action (_edit_fmt_menu, QIcon (), + tr ("Convert Line Endings to &Windows (CRLF)"), + SLOT (request_conv_eol_windows (bool))); + _conv_eol_unix_action = add_action (_edit_fmt_menu, QIcon (), + tr ("Convert Line Endings to &Unix (LF)"), + SLOT (request_conv_eol_unix (bool))); + _conv_eol_mac_action = add_action (_edit_fmt_menu, QIcon (), + tr ("Convert Line Endings to &Mac (CR)"), + SLOT (request_conv_eol_mac (bool))); + _edit_nav_menu = editMenu->addMenu (tr ("Navi&gation")); _goto_line_action = add_action (_edit_nav_menu, QIcon (), @@ -1636,6 +1673,9 @@ connect (this, SIGNAL (fetab_unindent_selected_text (const QWidget*)), f, SLOT (unindent_selected_text (const QWidget*))); + connect (this, SIGNAL (fetab_convert_eol (const QWidget*, QsciScintilla::EolMode)), + f, SLOT (convert_eol (const QWidget*, QsciScintilla::EolMode))); + connect (this, SIGNAL (fetab_find (const QWidget*)), f, SLOT (find (const QWidget*))); @@ -1740,6 +1780,10 @@ shortcut_manager::set_shortcut (_preferences_action, "editor_edit:preferences"); shortcut_manager::set_shortcut (_styles_preferences_action, "editor_edit:styles_preferences"); + shortcut_manager::set_shortcut (_conv_eol_windows_action, "editor_edit:conv_eol_winows"); + shortcut_manager::set_shortcut (_conv_eol_unix_action, "editor_edit:conv_eol_unix"); + shortcut_manager::set_shortcut (_conv_eol_mac_action, "editor_edit:conv_eol_mac"); + // View menu shortcut_manager::set_shortcut (_show_linenum_action, "editor_view:show_line_numbers"); shortcut_manager::set_shortcut (_show_whitespace_action, "editor_view:show_white_spaces");
--- a/libgui/src/m-editor/file-editor.h Sat Oct 11 11:08:21 2014 +0200 +++ b/libgui/src/m-editor/file-editor.h Sat Oct 11 11:15:59 2014 +0200 @@ -96,6 +96,7 @@ void fetab_uncomment_selected_text (const QWidget* ID); void fetab_indent_selected_text (const QWidget* ID); void fetab_unindent_selected_text (const QWidget* ID); + void fetab_convert_eol (const QWidget* ID, QsciScintilla::EolMode eol_mode); void fetab_find (const QWidget* ID); void fetab_goto_line (const QWidget* ID, int line = -1); void fetab_completion (const QWidget*); @@ -167,6 +168,9 @@ void request_lower_case (bool); void request_indent_selected_text (bool); void request_unindent_selected_text (bool); + void request_conv_eol_windows (bool); + void request_conv_eol_unix (bool); + void request_conv_eol_mac (bool); void request_find (bool); @@ -267,6 +271,9 @@ QAction *_uncomment_selection_action; QAction *_indent_selection_action; QAction *_unindent_selection_action; + QAction *_conv_eol_windows_action; + QAction *_conv_eol_unix_action; + QAction *_conv_eol_mac_action; QAction *_copy_action; QAction *_cut_action;
--- a/libgui/src/shortcut-manager.cc Sat Oct 11 11:08:21 2014 +0200 +++ b/libgui/src/shortcut-manager.cc Sat Oct 11 11:15:59 2014 +0200 @@ -246,6 +246,13 @@ QKeySequence (ctrl_shift + Qt::Key_Tab)); #endif + init (tr ("Convert Line Ednings to Windows"), "editor_edit:conv_eol_winows", + QKeySequence ()); + init (tr ("Convert Line Ednings to Unix"), "editor_edit:conv_eol_unix", + QKeySequence ()); + init (tr ("Convert Line Ednings to Mac"), "editor_edit:conv_eol_mac", + QKeySequence ()); + init (tr ("Goto Line"), "editor_edit:goto_line", QKeySequence (ctrl + Qt::Key_G)); init (tr ("Toggle Bookmark"), "editor_edit:toggle_bookmark",