Author Topic: Length of selected text  (Read 485 times)

Offline zdena

  • Multiple posting newcomer
  • *
  • Posts: 21
Length of selected text
« on: May 10, 2019, 08:27:25 am »
Hello,
if I make a selection of text in the code, can I get somehow the length (number of selected characters) of the selection?

Windows 10 64b
Arduino 1.8.5 with (modified) Arduino Builder 1.4.5 through (modified) C::B 17.12 32b
Occasional C(C++) hobbyist almost only for Arduino.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11827
    • Travis build status
Re: Length of selected text
« Reply #1 on: May 11, 2019, 03:40:45 pm »
At the moment I don't think it is possible.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2379
Re: Length of selected text
« Reply #2 on: May 11, 2019, 05:12:54 pm »
What would you like to do with it?
How would you like to get it?
I think it would not be to difficult to add a script binding...

Offline zdena

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: Length of selected text
« Reply #3 on: May 11, 2019, 06:37:54 pm »
@oBFusCATed: Thank you.

@BlueHazzard:
  • It could help me with counting characters in a (long) string if it could fit in a char array.
  • I don't know how. But for example Programmer's Notepad can count it.
  • I am not so good to write scripts.
Windows 10 64b
Arduino 1.8.5 with (modified) Arduino Builder 1.4.5 through (modified) C::B 17.12 32b
Occasional C(C++) hobbyist almost only for Arduino.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2379
Re: Length of selected text
« Reply #4 on: May 12, 2019, 12:49:22 am »
This would be a quite easy fix:
Code: [Select]
diff --git a/src/src/main.cpp b/src/src/main.cpp
index 87e5c5e5c..df2ff0655 100644
--- a/src/src/main.cpp
+++ b/src/src/main.cpp
@@ -2055,7 +2055,7 @@ void MainFrame::DoCreateStatusBar()
     dc.GetTextExtent(_(" Highlight Button "),                &widths[num++], &h);
     dc.GetTextExtent(_(" Windows (CR+LF) "),                 &widths[num++], &h);
     dc.GetTextExtent(_(" WINDOWS-1252 "),                    &widths[num++], &h);
-    dc.GetTextExtent(_(" Line 12345, Col 123, Pos 123456 "), &widths[num++], &h);
+    dc.GetTextExtent(_(" Line 12345, Col 123, Pos 123456, Sel 123456 "), &widths[num++], &h);
     dc.GetTextExtent(_(" Overwrite "),                       &widths[num++], &h);
     dc.GetTextExtent(_(" Modified "),                        &widths[num++], &h);
     dc.GetTextExtent(_(" Read/Write "),                      &widths[num++], &h);
@@ -2127,7 +2127,7 @@ void MainFrame::DoUpdateStatusBar()
         }
         SetStatusText(msg, panel++);
         SetStatusText(ed->GetEncodingName(), panel++);
-        msg.Printf(_("Line %d, Col %d, Pos %d"), control->GetCurrentLine() + 1, control->GetColumn(pos) + 1, pos);
+        msg.Printf(_("Line %d, Col %d, Pos %d, Sel %d"), control->GetCurrentLine() + 1, control->GetColumn(pos) + 1, pos, control->GetSelectionEnd() - control->GetSelectionStart());
         SetStatusText(msg, panel++);
         SetStatusText(control->GetOvertype() ? _("Overwrite") : _("Insert"), panel++);
 #if wxCHECK_VERSION(3, 0, 0)

Does something speaks against this?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11827
    • Travis build status
Re: Length of selected text
« Reply #5 on: May 12, 2019, 10:42:25 am »
Yes, it is getting too long and it doesn't convey that it is length.

After the previous change in this area there was a discussion to make this thing configurable with some kind of a formatting string.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline zdena

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: Length of selected text
« Reply #6 on: May 12, 2019, 11:08:23 am »
@BlueHazzard: It was whole morning fight. I lost the battle with automatic patching :( , but I solved it manually :) . Next the C::B sources compiling was hard - especially battle with libexchndl.
But the result: Yes, your solution works pretty good  ;) Thank you
Windows 10 64b
Arduino 1.8.5 with (modified) Arduino Builder 1.4.5 through (modified) C::B 17.12 32b
Occasional C(C++) hobbyist almost only for Arduino.