comparison libgui/src/m-editor/file-editor-tab.cc @ 17790:86c6ae5f969e

Use GNU style coding conventions for code in libgui/ * libgui/qterminal/libqterminal/QTerminal.h, libgui/src/color-picker.cc, libgui/src/color-picker.h, libgui/src/dialog.cc, libgui/src/dialog.h, libgui/src/documentation-dock-widget.cc, libgui/src/files-dock-widget.cc, libgui/src/files-dock-widget.h, libgui/src/find-files-dialog.cc, libgui/src/find-files-dialog.h, libgui/src/find-files-model.cc, libgui/src/find-files-model.h, libgui/src/history-dock-widget.cc, libgui/src/history-dock-widget.h, libgui/src/m-editor/file-editor-interface.h, 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/find-dialog.cc, libgui/src/m-editor/find-dialog.h, libgui/src/m-editor/octave-qscintilla.cc, libgui/src/main-window.cc, libgui/src/main-window.h, libgui/src/news-dock-widget.h, libgui/src/octave-dock-widget.cc, libgui/src/octave-dock-widget.h, libgui/src/octave-gui.cc, libgui/src/octave-qt-link.cc, libgui/src/octave-qt-link.h, libgui/src/qtinfo/parser.cc, libgui/src/qtinfo/parser.h, libgui/src/qtinfo/webinfo.cc, libgui/src/qtinfo/webinfo.h, libgui/src/resource-manager.cc, libgui/src/settings-dialog.cc, libgui/src/settings-dialog.h, libgui/src/terminal-dock-widget.cc, libgui/src/welcome-wizard.cc, libgui/src/workspace-model.cc, libgui/src/workspace-model.h, libgui/src/workspace-view.cc, libgui/src/workspace-view.h: Use GNU style coding conventions for code in libgui/
author Rik <rik@octave.org>
date Tue, 29 Oct 2013 09:54:40 -0700
parents d63878346099
children 4a53bcc1a4ae
comparison
equal deleted inserted replaced
17789:f2b047f9b605 17790:86c6ae5f969e
196 emit mru_add_file (_file_name); 196 emit mru_add_file (_file_name);
197 } 197 }
198 198
199 void 199 void
200 file_editor_tab::handle_margin_clicked (int margin, int line, 200 file_editor_tab::handle_margin_clicked (int margin, int line,
201 Qt::KeyboardModifiers state) 201 Qt::KeyboardModifiers state)
202 { 202 {
203 if (margin == 1) 203 if (margin == 1)
204 { 204 {
205 unsigned int markers_mask = _edit_area->markersAtLine (line); 205 unsigned int markers_mask = _edit_area->markersAtLine (line);
206 206
266 else if (_file_name.endsWith (".diff")) 266 else if (_file_name.endsWith (".diff"))
267 { 267 {
268 lexer = new QsciLexerDiff (); 268 lexer = new QsciLexerDiff ();
269 } 269 }
270 else if (_file_name.isEmpty () 270 else if (_file_name.isEmpty ()
271 || _file_name.at (_file_name.count () - 1) == '/') 271 || _file_name.at (_file_name.count () - 1) == '/')
272 { // new, no yet named file: let us assume it is octave 272 {
273 // new, no yet named file: let us assume it is octave
273 #if defined (HAVE_LEXER_OCTAVE) 274 #if defined (HAVE_LEXER_OCTAVE)
274 lexer = new QsciLexerOctave (); 275 lexer = new QsciLexerOctave ();
275 #elif defined (HAVE_LEXER_MATLAB) 276 #elif defined (HAVE_LEXER_MATLAB)
276 lexer = new QsciLexerMatlab (); 277 lexer = new QsciLexerMatlab ();
277 #else 278 #else
278 lexer = new QsciLexerBash (); 279 lexer = new QsciLexerBash ();
279 #endif 280 #endif
280 } 281 }
281 else 282 else
282 { // other or no extension 283 {
284 // other or no extension
283 lexer = new QsciLexerBash (); 285 lexer = new QsciLexerBash ();
284 } 286 }
285 } 287 }
286 288
287 _lexer_apis = new QsciAPIs(lexer); 289 _lexer_apis = new QsciAPIs(lexer);
288 if (_lexer_apis) 290 if (_lexer_apis)
289 { 291 {
290 // get path to prepared api info 292 // get path to prepared api info
291 QDesktopServices desktopServices; 293 QDesktopServices desktopServices;
292 QString prep_apis_path 294 QString prep_apis_path
293 = desktopServices.storageLocation (QDesktopServices::HomeLocation) 295 = desktopServices.storageLocation (QDesktopServices::HomeLocation)
294 + "/.config/octave/" + QString(OCTAVE_VERSION) + "/qsci/"; 296 + "/.config/octave/" + QString(OCTAVE_VERSION) + "/qsci/";
295 _prep_apis_file = prep_apis_path + lexer->lexer () + ".pap"; 297 _prep_apis_file = prep_apis_path + lexer->lexer () + ".pap";
296 298
297 if (!_lexer_apis->loadPrepared (_prep_apis_file)) 299 if (!_lexer_apis->loadPrepared (_prep_apis_file))
298 { // no prepared info loaded, prepare and save if possible 300 {
301 // no prepared info loaded, prepare and save if possible
299 302
300 // create raw apis info 303 // create raw apis info
301 QString keyword; 304 QString keyword;
302 QStringList keyword_list; 305 QStringList keyword_list;
303 int i,j; 306 int i,j;
311 314
312 // dsiconnect slot for saving prepared info if already connected 315 // dsiconnect slot for saving prepared info if already connected
313 disconnect (_lexer_apis, SIGNAL (apiPreparationFinished ()), 0, 0); 316 disconnect (_lexer_apis, SIGNAL (apiPreparationFinished ()), 0, 0);
314 // check whether path for prepared info exists or can be created 317 // check whether path for prepared info exists or can be created
315 if (QDir("/").mkpath (prep_apis_path)) 318 if (QDir("/").mkpath (prep_apis_path))
316 { // path exists, apis info can be saved there 319 {
320 // path exists, apis info can be saved there
317 connect (_lexer_apis, SIGNAL (apiPreparationFinished ()), 321 connect (_lexer_apis, SIGNAL (apiPreparationFinished ()),
318 this, SLOT (save_apis_info ())); 322 this, SLOT (save_apis_info ()));
319 } 323 }
320 _lexer_apis->prepare (); // prepare apis info 324 _lexer_apis->prepare (); // prepare apis info
321 } 325 }
719 // better, but individual find dialogs has the nice feature of 723 // better, but individual find dialogs has the nice feature of
720 // retaining position per file editor tabs, which can be undocked. 724 // retaining position per file editor tabs, which can be undocked.
721 725
722 if (!_find_dialog) 726 if (!_find_dialog)
723 { 727 {
724 _find_dialog = new find_dialog (_edit_area, 728 _find_dialog = new find_dialog (_edit_area,
725 qobject_cast<QWidget *> (sender ())); 729 qobject_cast<QWidget *> (sender ()));
726 connect (_find_dialog, SIGNAL (finished (int)), 730 connect (_find_dialog, SIGNAL (finished (int)),
727 this, SLOT (handle_find_dialog_finished (int))); 731 this, SLOT (handle_find_dialog_finished (int)));
728 _find_dialog->setWindowModality (Qt::NonModal); 732 _find_dialog->setWindowModality (Qt::NonModal);
729 _find_dialog_geometry = _find_dialog->geometry (); 733 _find_dialog_geometry = _find_dialog->geometry ();
793 _edit_area->removeSelectedText (); 797 _edit_area->removeSelectedText ();
794 } 798 }
795 } 799 }
796 } 800 }
797 //set selection on (un)commented section 801 //set selection on (un)commented section
798 _edit_area->setSelection (lineFrom, 0, lineTo, _edit_area->text (lineTo).length ()); 802 _edit_area->setSelection (lineFrom, 0, lineTo,
803 _edit_area->text (lineTo).length ());
799 } 804 }
800 else 805 else
801 { 806 {
802 int cpline, col; 807 int cpline, col;
803 _edit_area->getCursorPosition (&cpline, &col); 808 _edit_area->getCursorPosition (&cpline, &col);
861 QMessageBox::StandardButtons buttons = QMessageBox::Save | 866 QMessageBox::StandardButtons buttons = QMessageBox::Save |
862 QMessageBox::Discard; 867 QMessageBox::Discard;
863 QString available_actions; 868 QString available_actions;
864 869
865 if (_app_closing) 870 if (_app_closing)
866 available_actions = tr ("Do you want to save or discard the changes?"); 871 available_actions = tr ("Do you want to save or discard the changes?");
867 else 872 else
868 { 873 {
869 buttons = buttons | QMessageBox::Cancel; // cancel is allowed 874 buttons = buttons | QMessageBox::Cancel; // cancel is allowed
870 available_actions 875 available_actions
871 = tr ("Do you want to cancel closing, save or discard the changes?"); 876 = tr ("Do you want to cancel closing, save or discard the changes?");
898 else 903 else
899 { 904 {
900 // Nothing was modified, just remove from editor. 905 // Nothing was modified, just remove from editor.
901 emit tab_remove_request (); 906 emit tab_remove_request ();
902 } 907 }
903 908
904 return decision; 909 return decision;
905 } 910 }
906 911
907 void 912 void
908 file_editor_tab::handle_file_modified_answer (int decision) 913 file_editor_tab::handle_file_modified_answer (int decision)
970 { 975 {
971 // If it is a new file with no name, signal that saveFileAs 976 // If it is a new file with no name, signal that saveFileAs
972 // should be performed. 977 // should be performed.
973 if (saveFileName.isEmpty () 978 if (saveFileName.isEmpty ()
974 || saveFileName.at (saveFileName.count () - 1) == '/') 979 || saveFileName.at (saveFileName.count () - 1) == '/')
975 { 980 {
976 save_file_as (remove_on_success); 981 save_file_as (remove_on_success);
977 return; 982 return;
978 } 983 }
979 // get the absolute path (if existing) 984 // get the absolute path (if existing)
980 QFileInfo file_info = QFileInfo (saveFileName); 985 QFileInfo file_info = QFileInfo (saveFileName);
1238 (settings->value ("editor/highlightCurrentLine", true).toBool ()); 1243 (settings->value ("editor/highlightCurrentLine", true).toBool ());
1239 1244
1240 if (settings->value ("editor/codeCompletion", true).toBool ()) // auto compl. 1245 if (settings->value ("editor/codeCompletion", true).toBool ()) // auto compl.
1241 { 1246 {
1242 bool match_keywords = settings->value 1247 bool match_keywords = settings->value
1243 ("editor/codeCompletion_keywords",true).toBool (); 1248 ("editor/codeCompletion_keywords",true).toBool ();
1244 bool match_document = settings->value 1249 bool match_document = settings->value
1245 ("editor/codeCompletion_document",true).toBool (); 1250 ("editor/codeCompletion_document",true).toBool ();
1246 1251
1247 QsciScintilla::AutoCompletionSource source = QsciScintilla::AcsNone; 1252 QsciScintilla::AutoCompletionSource source = QsciScintilla::AcsNone;
1248 if (match_keywords) 1253 if (match_keywords)
1249 if (match_document) 1254 if (match_document)
1250 source = QsciScintilla::AcsAll; 1255 source = QsciScintilla::AcsAll;
1251 else 1256 else
1252 source = QsciScintilla::AcsAPIs; 1257 source = QsciScintilla::AcsAPIs;
1253 else 1258 else if (match_document)
1254 if (match_document) 1259 source = QsciScintilla::AcsDocument;
1255 source = QsciScintilla::AcsDocument;
1256 _edit_area->setAutoCompletionSource (source); 1260 _edit_area->setAutoCompletionSource (source);
1257 1261
1258 _edit_area->setAutoCompletionReplaceWord 1262 _edit_area->setAutoCompletionReplaceWord
1259 (settings->value ("editor/codeCompletion_replace",false).toBool ()); 1263 (settings->value ("editor/codeCompletion_replace",false).toBool ());
1260 _edit_area->setAutoCompletionCaseSensitivity 1264 _edit_area->setAutoCompletionCaseSensitivity