User forums > Using Code::Blocks
Length of selected text
zdena:
Hello,
if I make a selection of text in the code, can I get somehow the length (number of selected characters) of the selection?
oBFusCATed:
At the moment I don't think it is possible.
BlueHazzard:
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...
zdena:
@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.
BlueHazzard:
This would be a quite easy fix:
--- Code: ---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)
--- End code ---
Does something speaks against this?
Navigation
[0] Message Index
[#] Next page
Go to full version