Patch #2173 2007-09-16 16:07
buergi
added new comment types (box-,streamcomment) to edit menu- Download
- 2173-added_new_comm.patch (28.6 KB)
Index: src/src/main.cpp
===================================================================
--- src/src/main.cpp (Revision 4590)
+++ src/src/main.cpp (Arbeitskopie)
@@ -206,6 +206,8 @@
int idEditCommentSelected = XRCID("idEditCommentSelected");
int idEditUncommentSelected = XRCID("idEditUncommentSelected");
int idEditToggleCommentSelected = XRCID("idEditToggleCommentSelected");
+int idEditStreamCommentSelected = XRCID("idEditStreamCommentSelected");
+int idEditBoxCommentSelected = XRCID("idEditBoxCommentSelected");
int idEditAutoComplete = XRCID("idEditAutoComplete");
int idViewLayoutDelete = XRCID("idViewLayoutDelete");
@@ -296,6 +298,8 @@
EVT_UPDATE_UI(idEditAutoComplete, MainFrame::OnEditMenuUpdateUI)
EVT_UPDATE_UI(idEditUncommentSelected, MainFrame::OnEditMenuUpdateUI)
EVT_UPDATE_UI(idEditToggleCommentSelected, MainFrame::OnEditMenuUpdateUI)
+ EVT_UPDATE_UI(idEditStreamCommentSelected, MainFrame::OnEditMenuUpdateUI)
+ EVT_UPDATE_UI(idEditBoxCommentSelected, MainFrame::OnEditMenuUpdateUI)
EVT_UPDATE_UI(idSearchFind, MainFrame::OnSearchMenuUpdateUI)
EVT_UPDATE_UI(idSearchFindInFiles, MainFrame::OnSearchMenuUpdateUI)
@@ -408,6 +412,8 @@
EVT_MENU(idEditAutoComplete, MainFrame::OnEditAutoComplete)
EVT_MENU(idEditUncommentSelected, MainFrame::OnEditUncommentSelected)
EVT_MENU(idEditToggleCommentSelected, MainFrame::OnEditToggleCommentSelected)
+ EVT_MENU(idEditStreamCommentSelected, MainFrame::OnEditStreamCommentSelected)
+ EVT_MENU(idEditBoxCommentSelected, MainFrame::OnEditBoxCommentSelected)
EVT_MENU(idSearchFind, MainFrame::OnSearchFind)
EVT_MENU(idSearchFindInFiles, MainFrame::OnSearchFind)
@@ -2839,81 +2845,174 @@
ed->GetControl()->SelectAll();
}
-wxString GetCommentToken(cbStyledTextCtrl* stc)
+CommentToken GetCommentToken(cbStyledTextCtrl* stc)
{
- wxString comment;
+ CommentToken comment;
+ comment.lineComment = _T("");
+ comment.streamCommentStart = _T("");
+ comment.streamCommentEnd = _T("");
+ comment.boxCommentStart = _T("");
+ comment.boxCommentMid = _T("");
+ comment.boxCommentEnd = _T("");
+
switch(stc->GetLexer())
{
- case wxSCI_LEX_CONTAINER: comment = _T(""); break;
- case wxSCI_LEX_NULL: comment = _T(""); break;
- case wxSCI_LEX_PYTHON: comment = _T("#"); break;
- case wxSCI_LEX_CPP: comment = _T("//"); break;
- case wxSCI_LEX_HTML: comment = _T("//"); break; // PHP uses HTML lexer
- case wxSCI_LEX_XML: comment = _T(""); break;
- case wxSCI_LEX_PERL: comment = _T("#"); break;
- case wxSCI_LEX_SQL: comment = _T("--"); break;
- case wxSCI_LEX_VB: comment = _T("'"); break;
- case wxSCI_LEX_PROPERTIES: comment = _T("#"); break;
- case wxSCI_LEX_ERRORLIST: comment = _T(""); break;
- case wxSCI_LEX_MAKEFILE: comment = _T("#"); break;
- case wxSCI_LEX_BATCH: comment = _T("REM "); break;
- case wxSCI_LEX_XCODE: comment = _T(""); break;
- case wxSCI_LEX_LATEX: comment = _T("%"); break;
- case wxSCI_LEX_LUA: comment = _T("--"); break;
- case wxSCI_LEX_DIFF: comment = _T(""); break;
- case wxSCI_LEX_CONF: comment = _T(""); break;
- case wxSCI_LEX_PASCAL: comment = _T("//"); break; //delphi style comments, otherwise use { } or (* and *)
- case wxSCI_LEX_AVE: comment = _T(""); break;
- case wxSCI_LEX_ADA: comment = _T("--"); break;
- case wxSCI_LEX_LISP: comment = _T(";"); break;
- case wxSCI_LEX_RUBY: comment = _T("#"); break;
- case wxSCI_LEX_EIFFEL: comment = _T("--"); break;
- case wxSCI_LEX_EIFFELKW: comment = _T("--"); break;
- case wxSCI_LEX_TCL: comment = _T(""); break;
- case wxSCI_LEX_NNCRONTAB: comment = _T(""); break;
- case wxSCI_LEX_BULLANT: comment = _T(""); break;
- case wxSCI_LEX_VBSCRIPT: comment = _T("'"); break;
- case wxSCI_LEX_BAAN: comment = _T(""); break;
- case wxSCI_LEX_MATLAB: comment = _T("%"); break;
- case wxSCI_LEX_SCRIPTOL: comment = _T("`"); break;
- case wxSCI_LEX_ASM: comment = _T("#"); break;
- case wxSCI_LEX_CPPNOCASE: comment = _T("//"); break;
- case wxSCI_LEX_FORTRAN: comment = _T("!"); break;
- case wxSCI_LEX_CSS: comment = _T(""); break; // uses /* and */
- case wxSCI_LEX_POV: comment = _T("//@-"); break;
- case wxSCI_LEX_LOUT: comment = _T("#"); break;
- case wxSCI_LEX_ESCRIPT: comment = _T(""); break; //couldn't find
- case wxSCI_LEX_PS: comment = _T("%"); break; // not sure if it's only one % or multiple
- case wxSCI_LEX_NSIS: comment = _T(""); break;
- case wxSCI_LEX_MMIXAL: comment = _T(""); break;
- case wxSCI_LEX_CLW: comment = _T(""); break;
- case wxSCI_LEX_CLWNOCASE: comment = _T(""); break;
- case wxSCI_LEX_LOT: comment = _T(""); break;
- case wxSCI_LEX_YAML: comment = _T(""); break;
-
download for full patch...
History
some people prefer using /**/ comments instead of //, because, as you all know only the first style is ANSI-C.
so I added new comments types: box and stream comment, for all languages, which supports them.
Stream-comments are using e.g. /* */ to comment the whole selection.
Box-comments are using (mostly) the same characters, but the comment are always lines e.g.:
/* foo
* bar
*/
Further i changed the 'Comment' function to insert stream comments if there are no single line comments available in the current language. So this does also solve commenting problems with languages which don't support single line comments (like CSS).
I also fixed the 'Uncomment' function to remove the stream comments and single line box comments (which actually are stream comments). But it cannot uncomment multi line box comments
I hope there are no bugs in this patch :) it's my first one for C::B
btw I added a new struct CommentToken to the main.h. perhaps such types should be declared somewhere else, sry if its the wrong place.
--buergi
oh btw i did not add keybindings to the new comment types, it would be useful but i didn't know which one would be the best. think this should be decided by someone else :)
i would prefer Ctrl-Shift-V for stream comment, because its directly next to X and C which are the current hotkeys for (un)comment, and its currently not used.
the box comment does not need a hotkey i think, because its only rarely used and Ctrl-Shift-B is already assigned.
Doesn't compile.
@mandrav for me it works, just uploaded a revised patch for the current revision(4590), i made no changes in the source code, it compiles fine, but the executable doesn't run, cause an segmentation fault occures in the AutoDetectCompilers's constructor, but that has nothing to do with my patch, it also crashes without it.
i only tried if the patch worked with winxp but im very sure that it also works with linux etc. there should be no problem
--buergi
Will have another look. Maybe it didn't apply correctly and I didn't notice but now that you synced it to current HEAD maybe things are okay.
Applied, thanks :).