X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8a693e6e0460b6b3c32e4b6f114a3ab7b7cd24ea..f6bcfd974ef26faf6f91a62cac09827e09463fd1:/utils/wxPython/lib/editor/editor.py diff --git a/utils/wxPython/lib/editor/editor.py b/utils/wxPython/lib/editor/editor.py deleted file mode 100644 index b34d724798..0000000000 --- a/utils/wxPython/lib/editor/editor.py +++ /dev/null @@ -1,668 +0,0 @@ -#---------------------------------------------------------------------- -# Name: wxPython.lib.editor.wxEditor -# Purpose: An intelligent text editor with colorization capabilities. -# -# Author: Dirk Holtwic, Robin Dunn -# -# Created: 15-Dec-1999 -# RCS-ID: $Id$ -# Copyright: (c) 1999 by Dirk Holtwick, 1999 -# Licence: wxWindows license -#---------------------------------------------------------------------- - - -# PLEASE NOTE: This is experimental code. It needs an overhall in the -# drawing and update code, and there is occasionally a -# mysteriously disappearing line... -# -# I am working on a StyledTextEditor that will likely -# render this editor obsolete... But this one is at -# least somewhat functional now while the other is still -# vapor. -# -# - Robin - - -from wxPython.wx import * -from string import * -from keyword import * -from regsub import * -from tokenizer import * - -#--------------------------------------------------------------------------- - - -class Line: - def __init__(self, text=""): - self.text = text # the string itself - self.syntax = [] # the colors of the line - self.editable = true # edit? - self.visible = 0 # will be incremented if not - self.indent = 0 # not used yet - -#---------------------------------------------------------------------- - -class wxEditor(wxScrolledWindow): - - def __init__(self, parent, id, - pos=wxDefaultPosition, size=wxDefaultSize, style=0): - ############################################################### - """ - Alles hat einen Anfang - """ - - wxScrolledWindow.__init__(self, parent, id, - pos, size, - style|wxWANTS_CHARS) - - # the syntax informations, if they don't exist, - # all syntax stuff will be ignored - - # cursor pos - self.cx = 0 - self.cy = 0 - - # the lines that are visible - self.lines = [] - self.line = 0 - self.len = 0 - - self.ocy = 0 - - # border pos - #self.bx = 0 - #self.by = 0 - - # screen - self.sx = 0 - self.sy = 0 - self.sw = 0 - self.sh = 0 - self.osx= 0 - self.osy= 0 - - # font - dc = wxClientDC(self) - - if wxPlatform == "__WXMSW__": - self.font = wxFont(10, wxMODERN, wxNORMAL, wxNORMAL) - else: - self.font = wxFont(12, wxMODERN, wxNORMAL, wxNORMAL, false) - dc.SetFont(self.font) - - # font weight, height - self.fw = dc.GetCharWidth() - self.fh = dc.GetCharHeight() - - # back, for colour - self.bcol = wxNamedColour('white') - self.fcol = wxNamedColour('black') - - self.cfcol = wxNamedColour('black') - self.cbcol = wxNamedColour('red') - - # nicht edierbare zeile (hintergrund) - self.nedcol = wxNamedColour('grey') - - self.SetBackgroundColour(self.bcol) - #dc.SetForegroundColour(self.fcol) - - # events - EVT_LEFT_DOWN(self, self.OnMouseClick) - EVT_RIGHT_DOWN(self, self.OnMouseClick) - EVT_SCROLLWIN(self, self.OnScroll) - - self.o_cx = self.cx - self.o_cy = self.cy - self.o_sx = self.sx - self.o_sy = self.sy - self.o_line = self.line - self.sco_x = 0 - self.sco_y = 0 - - self.tabsize = 4 - - self.update = true - self.in_scroll =FALSE - self.inUpdate = FALSE - - - bw,bh = self.GetSizeTuple() - # double buffering - self.mdc = wxMemoryDC() - self.mdc.SelectObject(wxEmptyBitmap(bw,bh)) - # disable physical scrolling because invisible parts are not drawn - self.EnableScrolling(FALSE, FALSE) - - # the ordinary text as it is - self.SetText() - self.SetFocus() - - -#--------------------------------------------------------------------------- - - def CalcLines(self): - ############################################################### - self.lines = [] - x =maxlen =0 - for line in self.text: - if line.visible==0: - self.lines.append(x) - else: - if len(line.text) >maxlen: - maxlen =len(line.text) - x = x + 1 - self.len = len(self.lines) - self.max_linelength =maxlen - - - def SetFontTab(self, fonttab): - ############################################################### - """ Fonttabelle zum schnellen Zugriff """ - self.ftab = fonttab - - - def SetText(self, text = [""]): - ############################################################### - """ Text mittels Liste setzen """ - self.cx = 0 - self.cy = 0 - self.text = [] - - for t in text: - self.text.append(Line(t)) - - for l in range(0,len(text)-1): - #self.UpdateSyntax(l) - self.OnUpdateHighlight(l) - - self.OnInit() - - self.update = true - self.UpdateView(None, true) - - - # show new text - def GetText(self): - ############################################################### - """ Der gesamte Text als Liste """ - text = [] - for line in self.text: - text.append(line.text) - return text - - - def IsEmpty(self): - ############################################################### - """see if at least one text line is not empty""" - for line in self.text: - if line.text: return 0 - return 1 - - - def IsLine(self, line): - ############################################################### - """ Schauen, ob alles im grünen Bereich ist """ - return (line>=0) and (line Cursor setzen - """ - self.SetFocus() - - self.cy = self.sy + (event.GetY() / self.fh) - if self.cy >= self.len: self.cy =max(self.len -1, 0) - linelen =len(self.text[self.GetLine(self.cy)].text) - self.cx = self.sx + (event.GetX() / self.fw) - # allow positioning right behind the last character - if self.cx > linelen: self.cx =linelen - if event.GetEventType() ==wxEVT_RIGHT_DOWN: - self.update = true - self.OnFold() - self.UpdateView() - - - def DrawCursor(self, dc = None): - ############################################################### - """ - Auch der Cursor muß ja irgendwie gezeichnet werden - """ - if not dc: - dc = wxClientDC(self) - - if (self.len)(self.max_linelength -self.sw +1): - self.sx =self.max_linelength -self.sw +1 - if self.sx <0: self.sx =0 - if self.cx >(self.sx +self.sw -1): self.cx =self.sx +self.sw -1 - if self.cx (self.len -self.sh +1): - self.sy =self.len -self.sh +1 - if self.sy <0: self.sy =0 - if self.cy >(self.sy +self.sh -1): self.cy =self.sy +self.sh -1 - if self.cy