Length

From Enso Wiki

Jump to: navigation, search
  • NOTE: This command is written for Command Server not as a stand alone command
  • NOTE: This is my first stab at python, please fix any issues I have made.

[edit] Description

I've been looking at an easy way to get the length of text for awhile and this just seemed to easy. This doesn't put the length anywhere just displays it, since normally I just want to know.

[edit] Code

from base import BaseCommand
 
class Command(BaseCommand):
    def __init__(self, *args):
        BaseCommand.__init__(self, *args)
 
        self.newCommand("length", 
			self._length, 
			"Get Length of Selected Text", 
			"Select Text and Run Length command to get length of text.")
       
    def _length(self, postfix):
	text = self.getUnicodeSelection()
        self.displayMessage(text, "%s" % len(text))