Add a Character counter!

Roeland

Member³
Hi,

The thing I mostly dislike about Oracle is the limit of only 30 characters.

So, even that I know it's being asked MANY times before, here I go again.

Could you plz add ASAP the following features:
- When selecting or clicking on something => Display the character count (maybe in the window's statusbar?)
- When Refactoring. Add Character counters.

This is such a basic feature, it should have been in PLDEV a long time ago.

Thanks
 
I'd like to see this first one:

- When selecting or clicking on something => Display the character count (maybe in the window's statusbar?)

I often will select the variable name, copy it to the clipboard, and then open my clipboard manager window (ClipMate, definitely worth getting!) to check the name length.

but don't understand the point of the second:

- When Refactoring. Add Character counters.

???
 
Call me dim, and I do admit I haven't used many plug-ins, but I don't get it. This sounded interesting so I installed Scale. The one-line instruction says "copy some text to the clipboard, and select Scale..." Select Scale from where? I right-clicked and dropped down all over the place, but don't see it anywhere. Could you add another sentence or, better still, an 8x10 color glossy photo with circles and arrows?

Thank you.
 
The thing I mostly dislike about Oracle is the limit of only 30 characters.
Surely that is a good thing?

If Oracle allowed table names of 50 characters (for example), we would all have to deal with 50-character table names.
 
or, as usual :) , you can use Browser Extender and do it yourself. Below is an extension which will show in window status bar message with a length of current word.

Cut and Paste then save to a file with .be extension and load in Browser Extender.


Code:
PL/SQL Developer Browser Extender Command

[MAIN]
NAME=Character counter
CAPTION=Count characters...
OTYPE=commandwindow,procedurewindow,sqlwindow,testwindow
OOWNER=%
ONAME=%
SEPARATOR_ABOVE=N
SEPARATOR_BELOW=N
LOAD_AND_EXECUTE=N
LOAD_COMMAND=N
LOAD_AFTER=REPLACE
LOAD_WIN_TYPE=1
EXECUTE_AND_CLOSE=Y
PRIVILEGE_REQ=N
PRIVILEGE=
ORACLE_VERSION_REQ=N
ORACLE_VERSION=7.0.0
ONCLICK_CONFIRM=N
ONCLICK_CONFIRM_MSG=
ONCLICK_SPLASH=N
ONCLICK_SPLASH_MSG=
ONCLICK_SPLASH_MSG_BL=N
ONCLICK_SPLASH_MSG_AFTER=
ONCLICK_SPLASH_DELAY=0
ONCLICK_IGNORE_EXCEPTIONS=Y
ONPOPUP_IGNORE_EXCEPTIONS=Y

ONCLICK_CODE_TYPE=4
ONCLICK_EXTERNAL_CODE_FILE=
[ONCLICK]
program CharacterCounter;
{.$DEFINE DEBUG}                         // enables debug mode and related debug sub-items
const
  { Messages constants }
  WM_USER = 00;

  SB_SETTEXTA = WM_USER+1;
  SB_SETTEXTW = WM_USER+11;
  SB_SETTEXT  = SB_SETTEXTA;

  SB_GETPARTS = WM_USER+6;
  SB_GETTEXTA = WM_USER+2;
  SB_GETTEXTW = WM_USER+13;
  SB_GETTEXT  = SB_GETTEXTA;

  SB_GETTEXTLENGTHA       = WM_USER+3;
  SB_GETTEXTLENGTHW       = WM_USER+12;
  SB_GETTEXTLENGTH        = SB_GETTEXTLENGTHA;

  { MessageBox() Flags }
  MB_OK = ___SNIPPET___000000;
  MB_ICONASTERISK = ___SNIPPET___000040;

var
  sb_CurWinHandle, sb_CurWinStatusBarHandle : HWND;
  sb_Part : Integer;
  sb_TextA : String;
  sb_TextW : WideString;
  CurText: String;

  function FindWindowEx(hwndParent: HWND; hwndChildAfter: HWND; lpszClass: PChar; lpszWindow: PChar): Longint; external 'FindWindowExA@user32.dll stdcall';
  function SendMessageA(hWnd: HWND; Msg: Longint; wParam: Longint; lParam: PChar): Longint; external 'SendMessageA@user32.dll stdcall';
  function SendMessageW(hWnd: HWND; Msg: Longint; wParam: Longint; lParam: PChar): Longint; external 'SendMessageW@user32.dll stdcall';
  function MessageBox(Wnd: HWND; Text: PChar; Caption: PChar; Typ: Longint): Longint; external 'MessageBoxA@user32.dll stdcall';

  function ANSI2Wide(AString: String): WideString;
     var i: Integer;
  begin
      Result := '';
      For i := 1 to Length(AString) do
        begin
          Result := Result + AString\{i\} + #0;
        end;
  end;

begin

  sb_CurWinHandle := IDE_GetChildHandle;

  { Starting version 710 the interface supports Unicode and Status bar Class name was changed }
  If  SYS_Version >= 710 then
    sb_CurWinStatusBarHandle := FindWindowEx(sb_CurWinHandle,0,'TControlStatusBar.UnicodeClass','')
  else
    sb_CurWinStatusBarHandle := FindWindowEx(sb_CurWinHandle,0,'TControlStatusBar','');

  { get the last panel index }
  sb_Part := SendMessageA(sb_CurWinStatusBarHandle,SB_GETPARTS,0,'') - 1;

  CurText := IDE_GetCursorWord;

  If  SYS_Version >= 710 then
    begin
      sb_TextW := ANSI2Wide('Current word ''' + UpperCase(CurText) + ''' is ' + IntToStr(Length(CurText)) + ' character(s) long.');
      SendMessageW(sb_CurWinStatusBarHandle,SB_SETTEXTW,sb_Part,sb_TextW);
    end
  else
    begin
      sb_TextA := 'Current word ''' + UpperCase(CurText) + ''' is ' + IntToStr(Length(CurText)) + ' character(s) long.';
      SendMessageA(sb_CurWinStatusBarHandle,SB_SETTEXTA,sb_Part,sb_TextA);
    end;

end.

[ONPOPUP]
 
Originally posted by cmj:
Call me dim, and I do admit I haven't used many plug-ins, but I don't get it. This sounded interesting so I installed Scale. The one-line instruction says "copy some text to the clipboard, and select Scale..." Select Scale from where? I right-clicked and dropped down all over the place, but don't see it anywhere. Could you add another sentence or, better still, an 8x10 color glossy photo with circles and arrows?

Thank you.
You aren't dim, you just can't read minds.

Select Scale from under Edit on the Main Menu .
 
Does this BE 'script' only work on the 2.5 version? I tried it under 2.0 and while the Count Characters item appears in the right click menu it is inactive with something selected.

BTW, that is some 'script' - it looks like real code.
 
Rupik,
OK, thank you.

For those with AutoHotKey, here is a basic functionality script to report length of selected text in any app

(I had to update this because non-text clipboard contents would be lost :eek: , now they are saved/restored :D )

(oops again, needed to add 'return' at the end)

( 2007-05-22 changed to ensure that the clipboard is empty before sending the ctl-c )

=============
#s::
; save the contents of the clipboare
clipboard_save = %clipboardall% ; save text and non-text contents of clipboard
clipboard := ; clear out the clipboard

; get the selected text into the clipboard
send, ^c
clipwait, 5 ; wait for clipboard contents to change, wait at most 5 seconds

; save the text to measure
clip_text = %clipboard%

; restore the clipboard contents
clipboard = %clipboard_save%

; determine the length of the text
stringlen, text_len, clip_text

; let the user know how long
msgbox, "%clip_text%" is %text_len% characters long
return
 
For those with TextPad installed, here's a key-sequence to report the length of selected text in any app:

Control-C
Win-R
type: textpad
Enter
Control-N (optional)
Control-V
Control-A

Length is reported in the status bar.

;)
 
Well,

1. Go to start of a word
2. Enter
3. Go to end of a word
4. Status shows the caret position in format r:c, the length is c - 1.

It is shorter and you can do it inside PLD. ;)
 
If it's stored subprogram, then

Code:
select sum(length(text))
  from user_source
 where name = 'MYTEST'
;
:)
 
Stew, it could be shorter of course (everybody could write shorter code :) ):


Code:
begin
  IDE_SetStatusMessage(IntToStr(Length(IDE_GetCursorWord)));
end;
That was only an example to show how powerful Browser Extender could be using Win32 API and PL/SQL Developer Plug-in API.
 
Hi,

Thanks for all the good suggestions. But I still think it should be in PLDEV by default.

To Stew:
- When Refactoring. Add Character counters.
For example, when you do a refactoring -> "Rename item" you get only a textbox.
The only thing you could do at this moment is Copy / Paste it to another application (I don't know about the Browser Extender), or manually count the characters.
Of course I could construct the correct name before, thanks to all your suggestions, copy and paste it. But you get the point.
 
Scott,

I have downloaded and installed the Free AutoHotKey program. I think I like it.

But, ... there's still a problem with your code.
It gives me always the length of the previous selection. (Really weird). I have been trying to solve it myself, but couldn't do it.

Update: It works under Windows 2000, but not under WinXP.

Roeland
 
Roeland,
I agree, that is really weird.

I wrote this under XP Pro and it works just fine for me, but everyone's system will vary, so I made a change to force the clipboard to be empty before sending the ctl-c and lengthened the clipwait from 3 to 5 seconds. Give the new code (above) a try and see if that fixes your problem.
 
I discovered a problem with the default behavior of AutoHotKey (it strips leading/trailing spaces), so here is the fix. This version also reports how many lines are in the selected area.

Code:
;------------------------------------
#s:: ; report the length of selected text

; save the contents of the clipboare
clipboard_save = %clipboardall% ; save text and non-text contents of clipboard
clipboard := ; clear out the clipboard

; get the selected text into the clipboard
send, ^c
clipwait, 5 ; wait for clipboard contents to change, wait at most 5 seconds

; save the text to measure
clip_text = %clipboard%

; restore the clipboard contents
clipboard = %clipboard_save%

; determine the length of the text
stringlen, text_len, clip_text

; split the clipboard contents into lines
line_cnt := 0
loop, parse, clip_text, `n
{
  line_cnt := line_cnt + 1
}

; let the user know how long
msgbox, Selected text `n===========`n "%clip_text%" `n===========`nis `n %text_len% characters`n %line_cnt% lines

return
 

Similar threads

Back
Top