def add_editor(self, filename=None, content=""):
        if filename is None:
            filename = "Untitled-%s" % self._tabcount
            self._tabcount += 1
        _content = '<div id="%s" class="editclass" style="width:100%%;height:100%%">%s</div>'
        self._jquery(self._tab_container).tabs('add', {
            'title': filename,
            'content': _content % (filename, content),
            'closable': True
        })
        #add ace editor to filename pre tag
        _editor = JSObject(window.ace).edit(filename)
        _session = _editor.getSession()
        _session.setMode("ace/mode/python")
        #_editor.setTheme("ace/theme/crimson_editor")
        #_session.setMode("ace/mode/python")
        #_session.setUseWrapMode(true)
        #_session.setTabSize(4)
        _editor.setOptions({
            'enableLiveAutocompletion': True,
            'enableSnippets': True,
            'highlightActiveLine': False,
            'highlightSelectedWord': True
        })
        _editor.focus()

        self._editors[filename] = _editor
        #set resize
        document[filename].bind('resize', lambda x: self._editors[filename].resize(True))
    def add_editor(self, filename=None, content=""):
        if filename is None:
            filename = "Untitled-%s" % self._tabcount
            self._tabcount += 1
        _content = '<div id="%s" class="editclass" style="width:100%%;height:100%%">%s</div>'
        self._jquery(self._tab_container).tabs(
            'add', {
                'title': filename,
                'content': _content % (filename, content),
                'closable': True
            })
        #add ace editor to filename pre tag
        _editor = JSObject(ace).edit(filename)
        _session = _editor.getSession()
        _session.setMode("ace/mode/python")
        #_editor.setTheme("ace/theme/crimson_editor")
        #_session.setMode("ace/mode/python")
        #_session.setUseWrapMode(true)
        #_session.setTabSize(4)
        _editor.setOptions({
            'enableLiveAutocompletion': True,
            'enableSnippets': True,
            'highlightActiveLine': False,
            'highlightSelectedWord': True
        })
        _editor.focus()

        self._editors[filename] = _editor
        #set resize
        document[filename].bind('resize',
                                lambda x: self._editors[filename].resize(True))
  def add_editor(self, filename=None, content=""):
      if filename is None:
         filename = "Untitled-%s" % self._tabcount
         self._tabcount+=1

      #_content='<pre id="%s" class="editclass">%s</pre>'
      _content='<pre id="%s" class="editclass" style="width:100%%;height:100%%">%s</pre>'
      self._jquery(self._tab_container).tabs('add',
        {'title': filename,
         'content': _content % (filename, content), 
         'closable': True
        })

      #add ace editor to filename pre tag
      _editor=JSObject(ace).edit(filename)
      _session=_editor.getSession()
      _session.setMode("ace/mode/python")
      _editor.setTheme("ace/theme/crimson_editor")
      _session.setMode("ace/mode/python")
      #_session.setUseWrapMode(true)
      _session.setTabSize(4)

      _editor.focus()

      self._editors[filename]=_editor

      #set resize
      document[filename].bind('resize', lambda x: self._editors[filename].resize(True))
Beispiel #4
0
import time
import dis
import traceback

from browser import document as doc
from javascript import JSObject

# set height of container to 66% of screen
_height = doc.documentElement.clientHeight
_s = doc["container"]
_s.style.height = "%spx" % int(_height * 0.66)

has_ace = True
try:
    editor = JSObject(ace).edit("editor")
    editor.getSession().setMode("ace/mode/python")
    editor.setTheme("ace/theme/monokai")
except:
    from browser import html

    editor = html.TEXTAREA(rows=20, cols=70)
    doc["editor"] <= editor

    def get_value():
        return editor.value

    def set_value(x):
        editor.value = x

    editor.getValue = get_value
    editor.setValue = set_value
Beispiel #5
0
import time
import dis
import traceback

from browser import doc
from javascript import JSObject

# set height of container to 66% of screen
_height = doc.documentElement.clientHeight
_s = doc['container']
_s.style.height = '%spx' % int(_height * 0.66)

has_ace = True
try:
    editor = JSObject(ace).edit("editor")
    editor.getSession().setMode("ace/mode/python")
    editor.setTheme("ace/theme/monokai")
except:
    from browser import html
    editor = html.TEXTAREA(rows=20, cols=70)
    doc["editor"] <= editor

    def get_value():
        return editor.value

    def set_value(x):
        editor.value = x

    editor.getValue = get_value
    editor.setValue = set_value
    has_ace = False