Mercurial > octave-dspies
comparison libgui/src/m-editor/file-editor-tab.cc @ 19005:bf7c5d96d1ff gui-release
improved regexp for file name suggestion when saving a new editor file
* file-editor-tab.cc (get_function_name): improved regexp used for finding the
function name when saving a new function file in the editor
author | Torsten <ttl@justmail.de> |
---|---|
date | Mon, 11 Aug 2014 19:28:08 +0200 |
parents | e87e65bc71ae |
children |
comparison
equal
deleted
inserted
replaced
19004:e87e65bc71ae | 19005:bf7c5d96d1ff |
---|---|
1865 } | 1865 } |
1866 | 1866 |
1867 QString | 1867 QString |
1868 file_editor_tab::get_function_name () | 1868 file_editor_tab::get_function_name () |
1869 { | 1869 { |
1870 QRegExp rxfun1 ("^([\t ]*)function([^=]+)=([^\\(]+)\\(([^\\)]*)\\)"); | 1870 QRegExp rxfun1 ("^[\t ]*function[^=]+=([^\\(]+)\\([^\\)]*\\)[\t ]*$"); |
1871 QRegExp rxfun2 ("^([\t ]*)function([^\\(]+)\\(([^\\)]*)\\)"); | 1871 QRegExp rxfun2 ("^[\t ]*function[\t ]+([^\\(]+)\\([^\\)]*\\)[\t ]*$"); |
1872 QRegExp rxfun3 ("^([\t ]*)function([\t ]*)([^\t ]+)"); | 1872 QRegExp rxfun3 ("^[\t ]*function[^=]+=[\t ]*([^\s]+)[\t ]*$"); |
1873 QRegExp rxfun4 ("^[\t ]*function[\t ]+([^\s]+)[\t ]*$"); | |
1873 | 1874 |
1874 QStringList lines = _edit_area->text ().split ("\n"); | 1875 QStringList lines = _edit_area->text ().split ("\n"); |
1875 | 1876 |
1876 for (int i = 0; i < lines.count (); i++) | 1877 for (int i = 0; i < lines.count (); i++) |
1877 { | 1878 { |
1878 if (rxfun1.indexIn (lines.at (i)) != -1) | 1879 if (rxfun1.indexIn (lines.at (i)) != -1) |
1879 return rxfun1.cap (3).remove (QRegExp("[ \t]*")); | 1880 return rxfun1.cap (1).remove (QRegExp("[ \t]*")); |
1880 else if (rxfun2.indexIn (lines.at (i)) != -1) | 1881 else if (rxfun2.indexIn (lines.at (i)) != -1) |
1881 return rxfun2.cap (2).remove (QRegExp("[ \t]*")); | 1882 return rxfun2.cap (1).remove (QRegExp("[ \t]*")); |
1882 else if (rxfun3.indexIn (lines.at (i)) != -1) | 1883 else if (rxfun3.indexIn (lines.at (i)) != -1) |
1883 return rxfun3.cap (3).remove (QRegExp("[ \t]*")); | 1884 return rxfun3.cap (1).remove (QRegExp("[ \t]*")); |
1885 else if (rxfun4.indexIn (lines.at (i)) != -1) | |
1886 return rxfun4.cap (1).remove (QRegExp("[ \t]*")); | |
1884 } | 1887 } |
1885 | 1888 |
1886 return QString (); | 1889 return QString (); |
1887 } | 1890 } |
1888 | 1891 |