editor.py :  » IDE » RUR » rurple1.0rc3 » rur_py » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » IDE » RUR 
RUR » rurple1.0rc3 » rur_py » editor.py
""" RUR-PLE: Roberge's Used Robot - a Python Learning Environment
    editor.py - editor for program files.
    March 2006: major change to use the "lightning compiler" basis.
    Author: Andre Roberge    Copyright  2005, 2006
    andre.roberge@gmail.com
"""
import wx
import wx.stc as stc
from lightning import PythonEditor

if wx.Platform == '__WXMSW__':
    faces = { 'mono' : 'Courier New',
              'helv' : 'Arial',
              'size' : 11,
              'size2': 8,
             }
else:
    faces = { 'mono' : 'Courier',
              'helv' : 'Helvetica',
              'size' : 11,
              'size2': 9,
             }

class rur_editor(PythonEditor):
    def __init__(self, parent, ID):
        PythonEditor.__init__(self, parent, ID)
        self.parent = parent

        # changes from defaults: for pedagogical reasons, I chose to highlight python keywords (bold, blue),
        # all strings (including comments) in green and everything else in black.
        self.StyleSetSpec(stc.STC_P_WORD, "fore:#6699CC,bold,face:%(mono)s,size:%(size)d" % faces)# Keywords
        all_strings_style = "fore:#660066,face:%(mono)s,size:%(size)d"
        comments_style = "fore:#009900,face:%(mono)s,size:%(size)d"
        self.SetViewWhiteSpace(1)  # show white spaces ...
        self.SetIndentationGuides(False) # therefore, do not show indent guides
        self.StyleSetSpec(stc.STC_P_COMMENTLINE, comments_style % faces) # Comments
        self.StyleSetSpec(stc.STC_P_STRING, all_strings_style % faces)      # String
        self.StyleSetSpec(stc.STC_P_CHARACTER, all_strings_style % faces)   # Single quoted string
        self.StyleSetSpec(stc.STC_P_TRIPLE, all_strings_style % faces)      # Triple quotes
        self.StyleSetSpec(stc.STC_P_TRIPLEDOUBLE, all_strings_style % faces)# Triple double quotes
        self.StyleSetSpec(stc.STC_P_COMMENTBLOCK, comments_style % faces)# Comment-blocks

#--- highlighting user_code line --------------------------------

        self.MarkerDefine(7, stc.STC_MARK_BACKGROUND, 'white', 'wheat')
        self.marked_line = -1

    def highlight(self, line):
        if self.marked_line != -1:
            self.MarkerDelete(self.marked_line, 7)
        self.MarkerAdd(line, 7)
        self.marked_line = line

    def remove_highlight(self):
        self.MarkerDelete(self.marked_line, 7)
        self.marked_line = -1
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.