Hi,

Attached is a patch to add new functionality to the text editor. Every
programmer editor I have ever used allows you to comment a line of code
*without* first having to make a selection.

Old behaviour: To comment a line, you had to first select the whole
  line, starting at column 1 and the text cursor must end on the
  following line.

New behaviour: The old selection option still exists, but there is an
  additional behaviour added. If no selection was made, the editor
  will simply comment the current line the text cursor is on. Adding the
  comment markers at the beginning of the line.

-----------------------

Graeme Geldenhuys (1):
  Allows you to comment a line without first having to make whole line
    selections.

 apps/ide/sourcepage.pas | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

-- 
2.17.1



Regards,
  Graeme
>From 40ad0da83dd9be1e06b8a8aa4e43dd102682a5ae Mon Sep 17 00:00:00 2001
From: Graeme Geldenhuys <grae...@gmail.com>
Date: Sun, 7 Mar 2021 00:19:20 +0000
Subject: [PATCH 1/1] Allows you to comment a line without first having to make
 whole line selections.

Every text editor I know allows for this. Not sure how this was
overlooked in mseIDE.
---
 apps/ide/sourcepage.pas | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/apps/ide/sourcepage.pas b/apps/ide/sourcepage.pas
index 4326bc0f2..40dc8a5af 100644
--- a/apps/ide/sourcepage.pas
+++ b/apps/ide/sourcepage.pas
@@ -1771,8 +1771,10 @@ var
  mstr1: msestring;
  i1: int32;
  start,stop: int32;
+ gc1: gridcoordty;
 begin
- if cancomment() then begin
+ if cancomment() then // must have lines selected
+ begin
   edit.getselectedrows(start,stop);
   edit.editor.begingroup();
   mstr1:= edit.selectedtext;
@@ -1787,7 +1789,7 @@ begin
     if mstr1[i1] = #0 then begin
      break;
     end;
-    insert('//',mstr1,i1);    
+    insert('//',mstr1,i1);
    end;
    inc(i1);
   end;
@@ -1797,6 +1799,13 @@ begin
   grid.endupdate();
   edit.editor.endgroup();
   edit.refreshsyntax(start,stop-start);
+ end
+ else
+ begin // comment line - no selection needed
+   gc1 := edit.editpos;
+   mstr1 := edit.datalist.items[gc1.row];
+   edit.datalist.items[gc1.row] := '//' + mstr1;
+   edit.col := edit.col + 2; // advance edit cursor due to inserted text
  end;
 end;
 
-- 
2.17.1

_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to