1. since the line length is used, removed the 'as you type' chracter counter
2. the 'ticking' sound is used as a reminder that the macro is active,
but now only 'ticks' when a real character is typed
3. when using a GetKey() loop, if youu attempt to exit TSE, you can't
without actually using the assigned key to exit the macro first. So,
a routine should be added inside such a loop that checks for the
existence of loaded files and if there are none, as with a TSE exit
all files, then the loop gracefully exits itself
BTW, the line character counter keeps track of the current line length
even when changing lines.
And, if you hadn't noticed, in addition to the 'ticking' and the hilited
character count, a reminder ribbon is place on the right side of the
screen always on the opposite half of the screen from the cursor line.
***/
/*** jigcc.s
If you write facebook wall messages or tweets or other messages that
limit text to a number of characters, you might write them in TSE with
the wordwrap turned off giving you a long line up to the character
limit.
This macro might help keep you informed about how many characters you
have in the line and do so as you type, putting the character count
conveniently near the cursor.
Because the lines could be beyond the edge of the window, the macro
keeps the character count inside the window near the cursor.
The character count IS the line length, so it responds to backspacing,
deletions, and block insertions/deletions.
***/
// jigcc.s - character counter as you type
<ctrlalt x> execmacro("jigcc")
proc main()
integer n=0
integer x=0
integer y=0
integer k=0
sound(1000,30)
pushkey(<home>)
loop
k=getkey()
case k
when <ctrlalt x>,<alt pause>
sound(30,30)
goto ending
otherwise
presskey(k)
updatedisplay(_window_refresh_)
n=currlinelen()
x=wherex()
if currcol()-currxoffset()>query(windowcols)-2*length(str(n))
x=query(windowcols)-2*length(str(n))
endif
if currrow()>query(windowrows)-1
y=wherey()-1
else
y=wherey()+1
endif
putstrxy(x,y,str(n),query(hiliteattr))
if k in 32..255
sound(11000,1)
endif
endcase
y=query(windowrows)-5
if wherey()>query(windowrows)/2
y=query(windowy1)+5
endif
putstrxy(query(windowcols)-15,y-1,format("jigcc":-15:" "),159)
putstrxy(query(windowcols)-15,y,"CtrlAlt x: Exit",159)
if numfiles()==0
goto ending
endif
endloop
goto ending
ending:
sound(9000,90)
updatedisplay(_all_windows_refresh_)
end