Skip to main content

EnsPortal.Util.CodeEditorBase

abstract class EnsPortal.Util.CodeEditorBase

Base class to implement common code editor code to allow for code indentation and similar functionality.

Method Inventory

Methods

clientmethod codeKeyPress(zenControl, evt, language="") [ Language = javascript ]
Keypress handler for Zen textarea controls which automatically inserts the indentation used on the previous line of the control when the user hits the Enter key. Note that the actual whitespace determination is performed in getPrevWhitespace()().
clientmethod getPrevWhitespace(previousData, codelanguage="") [ Language = javascript ]
Helper method to supply anticipated indentiation required based on preceeding code input lines (previousData)

Object Script and Basic

Continue previous indent or default to indent of two whitespace characters

Python code entry conveniences

Feature Colon ":"

When the user types colon ":" ( ignoring trailing white space) + Enter key. This will automatically increment indent for new or nested block
for item in range(0,int(request.StringVaue)):
  context.TheList.Insert(item+1)
Where indent of increment was automatically provided for new line starting "context.TheList ..."

Feature "pass" keyword

When a line only contains pass keyword anticipate placeholder for code block and decrement indent on the following line
if (x==1):
  pass
else:
  pass
Where indent was automatically decremented on new line after "pass" keyword

Feature Empty lines

Second empty line indicates end of block scope When two sequential empty lines ( ignoring whitespace ) are typed, the following new line will decrement the indent
  for item in range(0,int(request.StringValue)):
    context.TheList.Insert(item+1)
    
    
  if (x==1):
    pass
  
At end of line with "context ... " line, enter key was pressed three times. The increment is automatically decremented so that the "if" command starts in a lower code block scope In this example no indent was needed.

Subclasses

FeedbackOpens in a new tab