You are not logged in.
Pages: 1
I noticed that the text editor medit or mooedit has every feature I would want in a text editor except word count. Luckily, medit was made to be extensible so I added that function. It requires coreutils and that the document you're working with be saved. Here's how to do it:
Go to Settings > Preferences > Tools to see a list of what functions are (or can be) in the tools menu. I added a new one and called it Statistics with the option need-doc. I then clicked disable, the made it a shell command. (Clicking shell command while it was enabled crashed medit). The input is the whole document, and the code goes in the spot for text below.
I had 5 variables:
VAR1=`wc -c $DOC`
VAR2=`wc -m $DOC`
VAR3=`wc -w $DOC`
VAR4=`wc -l $DOC`
VAR5=`wc -L $DOC`
for size, chars, words, lines and longest line respectively. $DOC is just the path of the file you have open. You could choose the output to be an output pane or new file where you echo $VAR1, echo $VAR2, etc but I wanted a window to come up and list them.
So i downloaded zenity, a tool for scripting GTK+ dialog boxes and did the following:
LENGTH=${#DOC}
VAR1=`wc -c $DOC`
VAR2=`wc -m $DOC`
VAR3=`wc -w $DOC`
VAR4=`wc -l $DOC`
VAR5=`wc -L $DOC`
zenity --list --title="Statistics" --width=200 --height=300 --text="Powered by wc and zenity" --column "Sort" "File size: "${VAR1:0:${#VAR1}-LENGTH} "Characters: "${VAR2:0:${#VAR2}-LENGTH} "Words: "${VAR3:0:${#VAR3}-LENGTH} "Lines: "${VAR4:0:${#VAR4}-LENGTH} "Longest Line: "${VAR5:0:${#VAR5}-LENGTH}
That way a user friendly box appears saying what the number represents and then the number for all 5 of them. And it doesn't keep saying the file path after each one, because I excluded that many characters from the end of the string (that's what I was doing with $LENGTH).
Basically it's the kind of solution where if I were a new person who just sat down and used it, I would think it were part of the original program . Hope you find it useful!
6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.
Offline
Pages: 1