Added python console

master
Yevgen Muntyan 2005-11-08 19:00:32 +00:00
parent 32c710545f
commit 7abbaabfd2
17 changed files with 78 additions and 18 deletions

View File

@ -31,6 +31,7 @@ mooedit_syntax_DATA = \
$(mooedit_syntax)/make.lang \
$(mooedit_syntax)/misc.lang \
$(mooedit_syntax)/python.lang \
$(mooedit_syntax)/python-console.lang \
$(mooedit_syntax)/sh.lang \
$(mooedit_syntax)/xml.lang \
$(mooedit_syntax)/garnacho.styles \

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?><!-- -*- Mode: XML; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -->
<?xml version="1.0" encoding="UTF-8"?><!-- kate: space-indent on; indent-width 2 -->
<!DOCTYPE language SYSTEM "language.dtd"
[
<!ENTITY func_pattern "\b[_\w][_\w\d]*(?=[\s]*[(])">

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?><!-- -*- Mode: XML; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -->
<?xml version="1.0" encoding="UTF-8"?><!-- kate: space-indent on; indent-width 2 -->
<!DOCTYPE language SYSTEM "language.dtd">
<language name="C++" version="1.0" section="Sources"
mimetypes="text/x-c++;text/x-cpp;text/x-c-header;text/x-c++src;text/x-c++hdr"

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?><!-- -*- Mode: XML; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -->
<?xml version="1.0" encoding="UTF-8"?><!-- kate: space-indent on; indent-width 2 -->
<!DOCTYPE language SYSTEM "language.dtd">
<language name="Diff" version="1.01" section="Others" extensions="*.diff;*patch" mimetypes="text/x-diff">
<syntax>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?><!-- -*- Mode: XML; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -->
<?xml version="1.0" encoding="UTF-8"?><!-- kate: space-indent on; indent-width 2 -->
<!DOCTYPE language SYSTEM "language.dtd">
<language name="GAP" version="1.0" section="Scripts"
mimetypes="text/x-gap;application/x-gap"

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?><!-- -*- Mode: XML; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -->
<?xml version="1.0" encoding="UTF-8"?><!-- kate: space-indent on; indent-width 2 -->
<!DOCTYPE scheme SYSTEM "scheme.dtd">
<scheme name="Garnacho" background="DarkSlateGray" foreground="Wheat"
selected-background="darkolivegreen4" current-line="DarkSlateGray">

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?><!-- -*- Mode: XML; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -->
<?xml version="1.0" encoding="UTF-8"?><!-- kate: space-indent on; indent-width 2 -->
<!DOCTYPE scheme SYSTEM "scheme.dtd">
<scheme name="gvim">
<default-style name="Normal"/>

View File

@ -1,3 +1,4 @@
<!-- kate: space-indent on; indent-width 2 -->
<!-- boolean
Boolean attributes are case-insensitive and may be the following:
"TRUE", "YES", "1" mean true,

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?><!-- -*- Mode: XML; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -->
<?xml version="1.0" encoding="UTF-8"?><!-- kate: space-indent on; indent-width 2 -->
<!DOCTYPE language SYSTEM "language.dtd">
<!-- Makefile syntaxfile v0.9 by Per Wigren <wigren@home.se> -->
<!-- Modified by Joseph Wenninger <jowenn@kde.org> -->

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?><!-- -*- Mode: XML; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -->
<?xml version="1.0" encoding="UTF-8"?><!-- kate: space-indent on; indent-width 2 -->
<!DOCTYPE language SYSTEM "language.dtd">
<language name="Misc" version="1.0" hidden="TRUE">
<syntax>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?><!-- kate: space-indent on; indent-width 2 -->
<!DOCTYPE language SYSTEM "language.dtd">
<language name="PythonConsole" visible="FALSE">
<syntax>
<context name="Normal">
<Regex pattern="^>>> " context="InputLine" style="PS1"/>
<Regex pattern="^\.\.\. " context="InputLineCont" style="PS2"/>
</context>
<context name="InputLine" end-of-line-context="#pop">
<IncludeRules from="##Python##Normal"/>
</context>
<context name="InputLineCont" end-of-line-context="#pop">
<IncludeRules from="##Python##Normal"/>
</context>
</syntax>
<styles>
<style name="PS1" default-style="Keyword"/>
<style name="PS2" default-style="Keyword"/>
</styles>
</language>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?><!-- -*- Mode: XML; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -->
<?xml version="1.0" encoding="UTF-8"?><!-- kate: space-indent on; indent-width 2 -->
<!DOCTYPE language SYSTEM "language.dtd">
<language name="Python" version="1.0" section="Scripts"
mimetypes="text/x-python;application/x-python"

View File

@ -1,3 +1,4 @@
<!-- kate: space-indent on; indent-width 2 -->
<!-- boolean
Boolean attributes are case-insensitive and may be the following:
"TRUE", "YES", "1" mean true,

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?><!-- -*- Mode: XML; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -->
<?xml version="1.0" encoding="UTF-8"?><!-- kate: space-indent on; indent-width 2 -->
<!DOCTYPE language SYSTEM "language.dtd">
<language name="sh" version="1.0" section="Scripts"
mimetypes="text/x-shellscript;application/x-shellscript;text/x-sh"

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?><!-- -*- Mode: XML; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -->
<?xml version="1.0" encoding="UTF-8"?><!-- kate: space-indent on; indent-width 2 -->
<!DOCTYPE language SYSTEM "language.dtd">
<language name="SuperCollider" version="1.0" section="Sources"
mimetypes="text/x-supercollider"

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?><!-- -*- Mode: XML; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- -->
<?xml version="1.0" encoding="UTF-8"?><!-- kate: space-indent on; indent-width 2 -->
<!DOCTYPE language SYSTEM "language.dtd"
[
<!ENTITY name "[A-Za-z_:][\w.:_-]*">

View File

@ -1,5 +1,12 @@
import moo
import gtk
import pango
try:
import pyconsole
have_pyconsole = True
except ImportError:
have_pyconsole = False
PLUGIN_ID = "PyStuff"
@ -18,23 +25,50 @@ class Plugin(object):
def init(self):
editor = moo.edit.editor_instance()
xml = editor.get_ui_xml()
moo.utils.window_class_add_action (moo.edit.EditWindow, "ShowPythonConsole",
name="Show Python Console",
label="Show Python Console",
callback=self.show_console)
moo.utils.window_class_add_action (moo.edit.EditWindow, "ShowLogWindow",
name="Show Log Window",
label="Show Log Window",
callback=self.show_log_window)
self.ui_merge_id = xml.new_merge_id()
xml.add_item(self.ui_merge_id, "Editor/Menubar/Tools",
"ShowPythonConsole", "ShowPythonConsole", -1)
"ShowLogWindow", "ShowLogWindow", -1)
if have_pyconsole:
moo.utils.window_class_add_action (moo.edit.EditWindow, "ShowPythonConsole",
name="Show Python Console",
label="Show Python Console",
callback=self.show_console)
xml.add_item(self.ui_merge_id, "Editor/Menubar/Tools",
"ShowPythonConsole", "ShowPythonConsole", -1)
return True
def deinit(self):
editor = moo.edit.editor_instance()
xml = editor.get_ui_xml()
moo.utils.window_class_remove_action(moo.edit.EditWindow, "ShowLogWindow");
moo.utils.window_class_remove_action(moo.edit.EditWindow, "ShowPythonConsole");
xml.remove_ui(self.ui_merge_id)
def show_console(self, window):
def show_log_window(self, window):
moo.app.get_instance().show_python_console()
def show_console(self, window):
window = gtk.Window()
swin = gtk.ScrolledWindow()
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
window.add(swin)
console_type = pyconsole.ConsoleType(moo.edit.TextView)
console = console_type(use_rlcompleter=False)
console.set_property("highlight-current-line", False)
editor = moo.edit.editor_instance()
mgr = editor.get_lang_mgr()
lang = mgr.get_lang("PythonConsole")
console.set_lang(lang)
console.modify_font(pango.FontDescription("Courier New 11"))
swin.add(console)
swin.set_size_request(400,300)
window.show_all()
moo.edit.plugin_register(Plugin)