/* Toggle_Comment (c) 2007/08/09, by Thorsten Willert (thorsten.willert[at]gmx.de) Toggles a line-comment depending on buffer mode ================================================================================ */ void main(View view) { import java.util.regex.*; comment = buffer.getContextSensitiveProperty( textArea.getCaretPosition() ,"lineComment"); try { if(comment != null && comment.length() > 0) { Pattern p1 = Pattern.compile("^[ \\t]*" + comment); textArea.selectLine(); sText = textArea.getSelectedText(); if ( p1.matcher(sText).find() ) textArea.setSelectedText( p1.matcher(sText).replaceAll("").trim() ); else textArea.lineComment(); } } catch(Exception e) { e.printStackTrace(); } } //============================================================================== if(buffer.isReadOnly()) Macros.error(view, "Buffer is read-only."); else main(view);