c# - Implement block comment/uncomment in ScintillaNET control -


i'm trying implement custom text-editor in c# using scintillanet component. i've got of right until now, stuck @ 1 point. want give user ability block comment/uncomment selected text. tried lot, cannot find examples online. thing seem control's selection object start , end positions, isn't help

    private void commentblocktoolstripmenuitem_click(object sender, eventargs e)     {         if (txtsql.selection.text.length > 0)         {             string start = txtsql.selection.start.tostring();             string end = txtsql.selection.end.tostring();             messagebox.show(start + "::" + end);          }     } 

were of able implement using scintillanet control?

edit: after improvization, i'm able somehow, after block commented, last line moves out of selection!

    private void commentblocktoolstripmenuitem_click(object sender, eventargs e)     {         if (txtsql.selection.text.length > 0)         {             range range = txtsql.selection.range;             int f = range.startingline.number;             int t = range.endingline.number;             int endpos = txtsql.selection.end;             (int = f; <= t; i++)             {                 //txtsql.goto.line(i);                 string tstr = txtsql.lines[i].text.replace(environment.newline, "");                 txtsql.lines[i].text = "--" + tstr;             }         }     } 

after bit of experimentation, found way accomplish this. though doubt if elegant of solutions!

    private void commentblocktoolstripmenuitem_click(object sender, eventargs e)     {         if (txtsql.selection.text.length > 0)         {             range range = txtsql.selection.range;             int f = range.startingline.number;             int t = range.endingline.number;             (int = f; <= t; i++)             {                 txtsql.inserttext(txtsql.lines[i].startposition,"--");             }             txtsql.selection.start = txtsql.lines[f].startposition;             txtsql.selection.end = txtsql.lines[t].endposition;         }     } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -