Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17967/scintilla
Modified Files:
Tag: py3k
IDLEenvironment.py bindings.py config.py configui.py
control.py document.py find.py formatter.py keycodes.py
view.py
Log Message:
Changes for Python 3
Index: config.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla/config.py,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -C2 -d -r1.6 -r1.6.2.1
*** config.py 9 Aug 2008 16:47:07 -0000 1.6
--- config.py 29 Aug 2008 06:16:42 -0000 1.6.2.1
***************
*** 11,15 ****
import sys
import string
! import keycodes
import marshal
import stat
--- 11,15 ----
import sys
import string
! from . import keycodes
import marshal
import stat
***************
*** 37,41 ****
if sep_pos == -1:
if line.strip():
! print "Warning: Line %d: %s is an invalid entry" % (lineno, `line`)
return None, None
return "", ""
--- 37,41 ----
if sep_pos == -1:
if line.strip():
! print("Warning: Line %d: %s is an invalid entry" % (lineno, repr(line)))
return None, None
return "", ""
***************
*** 59,63 ****
def find_config_files():
! return map( lambda x: os.path.split(x)[1], map( lambda x: os.path.splitext(x)[0], glob.glob(os.path.join(pywin.__path__[0], "*.cfg"))))
class ConfigManager:
--- 59,63 ----
def find_config_files():
! return [os.path.split(x)[1] for x in [os.path.splitext(x)[0] for x in glob.glob(os.path.join(pywin.__path__[0], "*.cfg"))]]
class ConfigManager:
***************
*** 161,165 ****
ns = {}
try:
! exec codeob in ns
except:
traceback.print_exc()
--- 161,165 ----
ns = {}
try:
! exec(codeob, ns)
except:
traceback.print_exc()
***************
*** 168,172 ****
if ns:
num = 0
! for name, func in ns.items():
if type(func)==types.FunctionType and name[:1] != '_':
bindings.bind(name, func)
--- 168,172 ----
if ns:
num = 0
! for name, func in list(ns.items()):
if type(func)==types.FunctionType and name[:1] != '_':
bindings.bind(name, func)
***************
*** 201,205 ****
map = {}
keymap = subsection_keymap.get(subsection, {})
! for key_info, map_event in keymap.items():
map[map_event] = key_info
self.key_to_events[subsection] = map
--- 201,205 ----
map = {}
keymap = subsection_keymap.get(subsection, {})
! for key_info, map_event in list(keymap.items()):
map[map_event] = key_info
self.key_to_events[subsection] = map
***************
*** 212,218 ****
def report_error(self, msg):
self.last_error = msg
! print "Error in %s: %s" % (self.filename, msg)
def report_warning(self, msg):
! print "Warning in %s: %s" % (self.filename, msg)
def _readline(self, fp, lineno, bStripComments = 1):
--- 212,218 ----
def report_error(self, msg):
self.last_error = msg
! print("Error in %s: %s" % (self.filename, msg))
def report_warning(self, msg):
! print("Warning in %s: %s" % (self.filename, msg))
def _readline(self, fp, lineno, bStripComments = 1):
***************
*** 280,284 ****
c = compile("".join(lines), self.filename, "exec")
self._save_data("extension code", c)
! except SyntaxError, details:
msg = details[0]
errlineno = details[1][1] + start_lineno
--- 280,284 ----
c = compile("".join(lines), self.filename, "exec")
self._save_data("extension code", c)
! except SyntaxError as details:
msg = details[0]
errlineno = details[1][1] + start_lineno
***************
*** 308,312 ****
map = cm.get_data("keys")
took = time.clock()-start
! print "Loaded %s items in %.4f secs" % (len(map), took)
if __name__=='__main__':
--- 308,312 ----
map = cm.get_data("keys")
took = time.clock()-start
! print("Loaded %s items in %.4f secs" % (len(map), took))
if __name__=='__main__':
Index: IDLEenvironment.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla/IDLEenvironment.py,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -C2 -d -r1.11 -r1.11.2.1
*** IDLEenvironment.py 9 Aug 2008 16:47:07 -0000 1.11
--- IDLEenvironment.py 29 Aug 2008 06:16:42 -0000 1.11.2.1
***************
*** 23,27 ****
modname = "pywin.idle." + module
__import__(modname)
! except ImportError, details:
msg = "The IDLE extension '%s' can not be located.\r\n\r\n" \
"Please correct the installation and restart the" \
--- 23,27 ----
modname = "pywin.idle." + module
__import__(modname)
! except ImportError as details:
msg = "The IDLE extension '%s' can not be located.\r\n\r\n" \
"Please correct the installation and restart the" \
***************
*** 42,46 ****
if self.finished:
return ""
! if not self.__dict__.has_key("_scint_lines"):
# XXX - note - assumes this is only called once the file is loaded!
self._scint_lines = self.text.edit.GetTextRange().split("\n")
--- 42,46 ----
if self.finished:
return ""
! if "_scint_lines" not in self.__dict__:
# XXX - note - assumes this is only called once the file is loaded!
self._scint_lines = self.text.edit.GetTextRange().split("\n")
***************
*** 69,73 ****
self.extension_menus = None
try:
! for ext in self.extensions.values():
closer = getattr(ext, "close", None)
if closer is not None:
--- 69,73 ----
self.extension_menus = None
try:
! for ext in list(self.extensions.values()):
closer = getattr(ext, "close", None)
if closer is not None:
***************
*** 84,88 ****
ext = self.extensions[extension] = klass(self)
# Find and bind all the events defined in the extension.
! events = filter(lambda item: item[-6:]=="_event", dir(klass))
for event in events:
name = "<<%s>>" % (event[:-6].replace("_", "-"), )
--- 84,88 ----
ext = self.extensions[extension] = klass(self)
# Find and bind all the events defined in the extension.
! events = [item for item in dir(klass) if item[-6:]=="_event"]
for event in events:
name = "<<%s>>" % (event[:-6].replace("_", "-"), )
***************
*** 94,102 ****
bindings = self.edit.bindings
ret = []
! for ext in self.extensions.values():
menudefs = getattr(ext, "menudefs", [])
for name, items in menudefs:
if name == menu_name:
! for text, event in filter(lambda item: item is not None, items):
text = text.replace("&", "&&")
text = text.replace("_", "&")
--- 94,102 ----
bindings = self.edit.bindings
ret = []
! for ext in list(self.extensions.values()):
menudefs = getattr(ext, "menudefs", [])
for name, items in menudefs:
if name == menu_name:
! for text, event in [item for item in items if item is not None]:
text = text.replace("&", "&&")
text = text.replace("_", "&")
***************
*** 202,206 ****
def TkIndexToOffset(bm, edit, marks):
base, nextTokPos = _NextTok(bm, 0)
! if base is None: raise ValueError, "Empty bookmark ID!"
if base.find(".")>0:
try:
--- 202,206 ----
def TkIndexToOffset(bm, edit, marks):
base, nextTokPos = _NextTok(bm, 0)
! if base is None: raise ValueError("Empty bookmark ID!")
if base.find(".")>0:
try:
***************
*** 208,212 ****
if col=="first" or col=="last":
# Tag name
! if line != "sel": raise ValueError, "Tags arent here!"
sel = edit.GetSel()
if sel[0]==sel[1]:
--- 208,212 ----
if col=="first" or col=="last":
# Tag name
! if line != "sel": raise ValueError("Tags arent here!")
sel = edit.GetSel()
if sel[0]==sel[1]:
***************
*** 226,230 ****
pos = pos + int(col)
except (ValueError, IndexError):
! raise ValueError, "Unexpected literal in '%s'" % base
elif base == 'insert':
pos = edit.GetSel()[0]
--- 226,230 ----
pos = pos + int(col)
except (ValueError, IndexError):
! raise ValueError("Unexpected literal in '%s'" % base)
elif base == 'insert':
pos = edit.GetSel()[0]
***************
*** 238,242 ****
pos = marks[base]
except KeyError:
! raise ValueError, "Unsupported base offset or undefined mark '%s'" % base
while 1:
--- 238,242 ----
pos = marks[base]
except KeyError:
! raise ValueError("Unsupported base offset or undefined mark '%s'" % base)
while 1:
***************
*** 245,252 ****
if word in ['+','-']:
num, nextTokPos = _NextTok(bm, nextTokPos)
! if num is None: raise ValueError, "+/- operator needs 2 args"
what, nextTokPos = _NextTok(bm, nextTokPos)
! if what is None: raise ValueError, "+/- operator needs 2 args"
! if what[0] <> "c": raise ValueError, "+/- only supports chars"
if word=='+':
pos = pos + int(num)
--- 245,252 ----
if word in ['+','-']:
num, nextTokPos = _NextTok(bm, nextTokPos)
! if num is None: raise ValueError("+/- operator needs 2 args")
what, nextTokPos = _NextTok(bm, nextTokPos)
! if what is None: raise ValueError("+/- operator needs 2 args")
! if what[0] != "c": raise ValueError("+/- only supports chars")
if word=='+':
pos = pos + int(num)
***************
*** 268,272 ****
pos = pos + 1
else:
! raise ValueError, "Unsupported relative offset '%s'" % word
return max(pos, 0) # Tkinter is tollerant of -ve indexes - we aren't
--- 268,272 ----
pos = pos + 1
else:
! raise ValueError("Unsupported relative offset '%s'" % word)
return max(pos, 0) # Tkinter is tollerant of -ve indexes - we aren't
***************
*** 349,354 ****
pos = self._getoffset(pos)
except EmptyRange:
! raise TextError, "Empty range"
self.edit.SetSel((pos, pos))
# IDLE only deals with "\n" - we will be nicer
bits = text.split('\n')
--- 349,356 ----
pos = self._getoffset(pos)
except EmptyRange:
! raise TextError("Empty range")
self.edit.SetSel((pos, pos))
+ self.edit.SCIAddText(text)
+ """
# IDLE only deals with "\n" - we will be nicer
bits = text.split('\n')
***************
*** 357,360 ****
--- 359,363 ----
self.edit.SCINewline()
self.edit.SCIAddText(bit)
+ """
def delete(self, start, end=None):
***************
*** 363,367 ****
if end is not None: end = self._getoffset(end)
except EmptyRange:
! raise TextError, "Empty range"
# If end is specified and == start, then we must delete nothing.
if start==end: return
--- 366,370 ----
if end is not None: end = self._getoffset(end)
except EmptyRange:
! raise TextError("Empty range")
# If end is specified and == start, then we must delete nothing.
if start==end: return
***************
*** 396,400 ****
pos = self._getoffset(pos)
except EmptyRange:
! raise TextError, "Empty range '%s'" % pos
if name == "insert":
self.edit.SetSel( pos )
--- 399,403 ----
pos = self._getoffset(pos)
except EmptyRange:
! raise TextError("Empty range '%s'" % pos)
if name == "insert":
self.edit.SetSel( pos )
***************
*** 403,417 ****
def tag_add(self, name, start, end):
! if name != "sel": raise ValueError, "Only sel tag is supported"
try:
start = self._getoffset(start)
end = self._getoffset(end)
except EmptyRange:
! raise TextError, "Empty range"
self.edit.SetSel( start, end )
def tag_remove(self, name, start, end):
if name !="sel" or start != "1.0" or end != "end":
! raise ValueError, "Cant remove this tag"
# Turn the sel into a cursor
self.edit.SetSel(self.edit.GetSel()[0])
--- 406,420 ----
def tag_add(self, name, start, end):
! if name != "sel": raise ValueError("Only sel tag is supported")
try:
start = self._getoffset(start)
end = self._getoffset(end)
except EmptyRange:
! raise TextError("Empty range")
self.edit.SetSel( start, end )
def tag_remove(self, name, start, end):
if name !="sel" or start != "1.0" or end != "end":
! raise ValueError("Cant remove this tag")
# Turn the sel into a cursor
self.edit.SetSel(self.edit.GetSel()[0])
***************
*** 442,451 ****
rc = TkIndexToOffset(index, edit, {})
if rc != expected:
! print "ERROR: Index", index,", expected", expected, "but got", rc
def TestGet(fr, to, t, expected):
got = t.get(fr, to)
if got != expected:
! print "ERROR: get(%s, %s) expected %s, but got %s" % (`fr`, `to`, `expected`, `got`)
def test():
--- 445,454 ----
rc = TkIndexToOffset(index, edit, {})
if rc != expected:
! print("ERROR: Index", index,", expected", expected, "but got", rc)
def TestGet(fr, to, t, expected):
got = t.get(fr, to)
if got != expected:
! print("ERROR: get(%s, %s) expected %s, but got %s" % (repr(fr), repr(to), repr(expected), repr(got)))
def test():
Index: keycodes.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla/keycodes.py,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -C2 -d -r1.5 -r1.5.2.1
*** keycodes.py 9 Aug 2008 16:47:07 -0000 1.5
--- keycodes.py 29 Aug 2008 06:16:42 -0000 1.5.2.1
***************
*** 31,35 ****
def _fillmap():
# Pull the VK_names from win32con
! names = filter(lambda entry: entry[:3]=="VK_", win32con.__dict__.keys())
for name in names:
n = name[3:].lower()
--- 31,35 ----
def _fillmap():
# Pull the VK_names from win32con
! names = [entry for entry in list(win32con.__dict__.keys()) if entry[:3]=="VK_"]
for name in names:
n = name[3:].lower()
***************
*** 126,130 ****
def _psc(char):
sc = get_scan_code(char)
! print "Char %s -> %d -> %s" % (`char`, sc, key_code_to_name.get(sc))
def test1():
--- 126,130 ----
def _psc(char):
sc = get_scan_code(char)
! print("Char %s -> %d -> %s" % (repr(char), sc, key_code_to_name.get(sc)))
def test1():
***************
*** 136,140 ****
def _pkn(n):
scancode, flags = parse_key_name(n)
! print "%s -> %s,%s -> %s" % (n, scancode, flags, make_key_name(scancode, flags))
def test2():
--- 136,140 ----
def _pkn(n):
scancode, flags = parse_key_name(n)
! print("%s -> %s,%s -> %s" % (n, scancode, flags, make_key_name(scancode, flags)))
def test2():
Index: document.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla/document.py,v
retrieving revision 1.6
retrieving revision 1.6.4.1
diff -C2 -d -r1.6 -r1.6.4.1
*** document.py 29 Oct 2000 23:44:42 -0000 1.6
--- document.py 29 Aug 2008 06:16:42 -0000 1.6.4.1
***************
*** 2,6 ****
from pywin.mfc import docview
from pywin import is_platform_unicode, default_platform_encoding, default_scintilla_encoding
! from scintillacon import *
import win32con
import string
--- 2,6 ----
from pywin.mfc import docview
from pywin import is_platform_unicode, default_platform_encoding, default_scintilla_encoding
! from .scintillacon import *
import win32con
import string
***************
*** 23,31 ****
f = codecs.open(filename, 'rb', default_platform_encoding)
else:
! f = open(filename, 'rb')
try:
text = f.read()
finally:
f.close()
if is_platform_unicode:
# Translate from locale-specific (MCBS) encoding to UTF-8 for Scintilla
--- 23,32 ----
f = codecs.open(filename, 'rb', default_platform_encoding)
else:
! f = open(filename, 'r')
try:
text = f.read()
finally:
f.close()
+ text = text.encode('utf-8')
if is_platform_unicode:
# Translate from locale-specific (MCBS) encoding to UTF-8 for Scintilla
***************
*** 64,68 ****
doc = self
view.SendScintilla(SCI_CLEARALL)
! view.SendMessage(SCI_ADDTEXT, buffer(text))
view.SendScintilla(SCI_SETUNDOCOLLECTION, 1, 0)
view.SendScintilla(win32con.EM_EMPTYUNDOBUFFER, 0, 0)
--- 65,69 ----
doc = self
view.SendScintilla(SCI_CLEARALL)
! view.SendMessage(SCI_ADDTEXT, text)
view.SendScintilla(SCI_SETUNDOCOLLECTION, 1, 0)
view.SendScintilla(win32con.EM_EMPTYUNDOBUFFER, 0, 0)
***************
*** 126,135 ****
for view in self.GetAllViews():
func = getattr(view, funcName)
! apply(func, args)
def _ApplyOptionalToViews(self, funcName, *args):
for view in self.GetAllViews():
func = getattr(view, funcName, None)
if func is not None:
! apply(func, args)
def GetEditorView(self):
# Find the first frame with a view,
--- 127,136 ----
for view in self.GetAllViews():
func = getattr(view, funcName)
! func(*args)
def _ApplyOptionalToViews(self, funcName, *args):
for view in self.GetAllViews():
func = getattr(view, funcName, None)
if func is not None:
! func(*args)
def GetEditorView(self):
# Find the first frame with a view,
***************
*** 151,155 ****
for v in self.doc.GetAllViews():
if v.GetSafeHwnd() == hwndFrom:
! return apply(getattr(v, self.name), (std, extra))
# Delegate to the document, but only from a single view (as each view sends it seperately)
--- 152,156 ----
for v in self.doc.GetAllViews():
if v.GetSafeHwnd() == hwndFrom:
! return getattr(v, self.name)(*(std, extra))
# Delegate to the document, but only from a single view (as each view sends it seperately)
***************
*** 161,163 ****
(hwndFrom, idFrom, code) = std
if hwndFrom == self.doc.GetEditorView().GetSafeHwnd():
! apply(self.delegate, (std, extra))
--- 162,164 ----
(hwndFrom, idFrom, code) = std
if hwndFrom == self.doc.GetEditorView().GetSafeHwnd():
! self.delegate(*(std, extra))
Index: control.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla/control.py,v
retrieving revision 1.17
retrieving revision 1.17.2.1
diff -C2 -d -r1.17 -r1.17.2.1
*** control.py 9 Aug 2008 16:47:07 -0000 1.17
--- control.py 29 Aug 2008 06:16:42 -0000 1.17.2.1
***************
*** 6,9 ****
--- 6,10 ----
from pywin.mfc import window
+ from pywin import default_scintilla_encoding
import win32con
import win32ui
***************
*** 13,17 ****
import string
import os
! from scintillacon import *
# Load Scintilla.dll to get access to the control.
--- 14,18 ----
import string
import os
! from .scintillacon import *
# Load Scintilla.dll to get access to the control.
***************
*** 58,62 ****
def SCIAddText(self, text):
! self.SendMessage(SCI_ADDTEXT, buffer(text))
def SCIAddStyledText(self, text, style = None):
# If style is None, text is assumed to be a "native" Scintilla buffer.
--- 59,63 ----
def SCIAddText(self, text):
! self.SendMessage(SCI_ADDTEXT, text.encode(default_scintilla_encoding))
def SCIAddStyledText(self, text, style = None):
# If style is None, text is assumed to be a "native" Scintilla buffer.
***************
*** 64,74 ****
# assumed to apply to the entire string.
if style is not None:
! text = map(lambda char, style=style: char+chr(style), text)
text = ''.join(text)
! self.SendMessage(SCI_ADDSTYLEDTEXT, buffer(text))
def SCIInsertText(self, text, pos=-1):
! sma = array.array('c', text+"\0")
! (a,l) = sma.buffer_info()
! self.SendScintilla(SCI_INSERTTEXT, pos, a)
def SCISetSavePoint(self):
self.SendScintilla(SCI_SETSAVEPOINT)
--- 65,76 ----
# assumed to apply to the entire string.
if style is not None:
! text = list(map(lambda char, style=style: char+chr(style), text))
text = ''.join(text)
! self.SendMessage(SCI_ADDSTYLEDTEXT, text.encode(default_scintilla_encoding))
def SCIInsertText(self, text, pos=-1):
! ## sma = array.array('u', text+"\0")
! ## (a,l) = sma.buffer_info()
! buff=(text+'\0').encode(default_scintilla_encoding)
! self.SendScintilla(SCI_INSERTTEXT, pos, buff)
def SCISetSavePoint(self):
self.SendScintilla(SCI_SETSAVEPOINT)
***************
*** 107,113 ****
return self.SendScintilla(SCI_STYLESETEOLFILLED, num, v)
def SCIStyleSetFont(self, num, name, characterset=0):
! buff = array.array('c', name + "\0")
! addressBuffer = buff.buffer_info()[0]
! self.SendScintilla(SCI_STYLESETFONT, num, addressBuffer)
self.SendScintilla(SCI_STYLESETCHARACTERSET, num, characterset)
def SCIStyleSetBold(self, num, bBold):
--- 109,115 ----
return self.SendScintilla(SCI_STYLESETEOLFILLED, num, v)
def SCIStyleSetFont(self, num, name, characterset=0):
! buff = (name + "\0").encode(default_scintilla_encoding)
! ## addressBuffer = buff.buffer_info()[0]
! self.SendScintilla(SCI_STYLESETFONT, num, buff)
self.SendScintilla(SCI_STYLESETCHARACTERSET, num, characterset)
def SCIStyleSetBold(self, num, bBold):
***************
*** 180,186 ****
if type(text) in [type([]), type(())]:
text = ' '.join(text)
! buff = array.array('c', text + "\0")
! addressBuffer = buff.buffer_info()[0]
! return self.SendScintilla(SCI_AUTOCSHOW, 0, addressBuffer)
def SCIAutoCCancel(self):
self.SendScintilla(SCI_AUTOCCANCEL)
--- 182,187 ----
if type(text) in [type([]), type(())]:
text = ' '.join(text)
! buff = (text + "\0").encode(default_scintilla_encoding)
! return self.SendScintilla(SCI_AUTOCSHOW, 0, buff)
def SCIAutoCCancel(self):
self.SendScintilla(SCI_AUTOCCANCEL)
***************
*** 190,196 ****
return self.SendScintilla(SCI_AUTOCCOMPLETE)
def SCIAutoCStops(self, stops):
! buff = array.array('c', stops + "\0")
! addressBuffer = buff.buffer_info()[0]
! self.SendScintilla(SCI_AUTOCSTOPS, 0, addressBuffer)
def SCIAutoCSetAutoHide(self, hide):
self.SendScintilla(SCI_AUTOCSETAUTOHIDE, hide)
--- 191,196 ----
return self.SendScintilla(SCI_AUTOCCOMPLETE)
def SCIAutoCStops(self, stops):
! buff = (stops + "\0").encode(default_scintilla_encoding)
! self.SendScintilla(SCI_AUTOCSTOPS, 0, buff)
def SCIAutoCSetAutoHide(self, hide):
self.SendScintilla(SCI_AUTOCSETAUTOHIDE, hide)
***************
*** 200,211 ****
def SCICallTipShow(self, text, pos=-1):
if pos==-1: pos = self.GetSel()[0]
! if isinstance(text, unicode):
# I'm really not sure what the correct encoding
# to use is - but it has gotta be better than total
# failure due to the array module
text = text.encode("mbcs")
! buff = array.array('c', text + "\0")
! addressBuffer = buff.buffer_info()[0]
! self.SendScintilla(SCI_CALLTIPSHOW, pos, addressBuffer)
def SCICallTipCancel(self):
self.SendScintilla(SCI_CALLTIPCANCEL)
--- 200,213 ----
def SCICallTipShow(self, text, pos=-1):
if pos==-1: pos = self.GetSel()[0]
! """
! if isinstance(text, str):
# I'm really not sure what the correct encoding
# to use is - but it has gotta be better than total
# failure due to the array module
text = text.encode("mbcs")
! """
! buff = (text + "\0").encode(default_scintilla_encoding)
! ## addressBuffer = buff.buffer_info()[0]
! self.SendScintilla(SCI_CALLTIPSHOW, pos, buff)
def SCICallTipCancel(self):
self.SendScintilla(SCI_CALLTIPCANCEL)
***************
*** 218,227 ****
# Lexer etc
def SCISetKeywords(self, keywords, kw_list_no = 0):
! ar = array.array('c', keywords+"\0")
! (a,l) = ar.buffer_info()
! self.SendScintilla(SCI_SETKEYWORDS, kw_list_no, a)
def SCISetProperty(self, name, value):
! name_buff = array.array('c', name + "\0")
! val_buff = array.array("c", str(value) + "\0")
address_name_buffer = name_buff.buffer_info()[0]
address_val_buffer = val_buff.buffer_info()[0]
--- 220,228 ----
# Lexer etc
def SCISetKeywords(self, keywords, kw_list_no = 0):
! buff = (keywords+"\0").encode(default_scintilla_encoding)
! self.SendScintilla(SCI_SETKEYWORDS, kw_list_no, buff)
def SCISetProperty(self, name, value):
! name_buff = array.array('b', (name + '\0').encode('utf-8'))
! val_buff = array.array("b", (str(value)+'\0').encode('utf-8'))
address_name_buffer = name_buff.buffer_info()[0]
address_val_buffer = val_buff.buffer_info()[0]
***************
*** 279,289 ****
"""
findtextex_fmt='llPll'
! buff = array.array('c', findText + "\0")
! addressBuffer = buff.buffer_info()[0]
! ft = struct.pack(findtextex_fmt, range[0], range[1], addressBuffer, 0, 0)
! ftBuff = array.array('c', ft)
! addressFtBuff = ftBuff.buffer_info()[0]
! rc = self.SendScintilla(EM_FINDTEXTEX, flags, addressFtBuff)
! ftUnpacked = struct.unpack(findtextex_fmt, ftBuff.tostring())
return rc, (ftUnpacked[3], ftUnpacked[4])
--- 280,290 ----
"""
findtextex_fmt='llPll'
! ## Scintilla does not handle unicode in EM_FINDTEXT msg (FINDTEXTEX struct)
! txt_buff = (findText+'\0').encode('utf-8')
! txt_array = array.array('b', txt_buff)
! ft_buff = struct.pack(findtextex_fmt, range[0], range[1], txt_array.buffer_info()[0], 0, 0)
! ft_array = array.array('b', ft_buff)
! rc = self.SendScintilla(EM_FINDTEXTEX, flags, ft_array.buffer_info()[0])
! ftUnpacked = struct.unpack(findtextex_fmt, ft_array)
return rc, (ftUnpacked[3], ftUnpacked[4])
***************
*** 299,306 ****
def GetSelText(self):
start, end = self.GetSel()
! txtBuf = array.array('c', " " * ((end-start)+1))
addressTxtBuf = txtBuf.buffer_info()[0]
self.SendScintilla(EM_GETSELTEXT, 0, addressTxtBuf)
! return txtBuf.tostring()[:-1]
def SetSel(self, start=0, end=None):
--- 300,307 ----
def GetSelText(self):
start, end = self.GetSel()
! txtBuf = array.array('u', " " * ((end-start)+1))
addressTxtBuf = txtBuf.buffer_info()[0]
self.SendScintilla(EM_GETSELTEXT, 0, addressTxtBuf)
! return txtBuf.tostring().decode(default_scintilla_encoding)
def SetSel(self, start=0, end=None):
***************
*** 315,319 ****
assert end <= self.GetTextLength(), "The end postion is invalid (%d/%d)" % (end, self.GetTextLength())
cr = struct.pack('ll', start, end)
! crBuff = array.array('c', cr)
addressCrBuff = crBuff.buffer_info()[0]
rc = self.SendScintilla(EM_EXSETSEL, 0, addressCrBuff)
--- 316,320 ----
assert end <= self.GetTextLength(), "The end postion is invalid (%d/%d)" % (end, self.GetTextLength())
cr = struct.pack('ll', start, end)
! crBuff = array.array('b', cr)
addressCrBuff = crBuff.buffer_info()[0]
rc = self.SendScintilla(EM_EXSETSEL, 0, addressCrBuff)
***************
*** 347,362 ****
assert end >= 0 and end <= self.GetTextLength(), "The end postion is invalid"
initer = "=" * (end - start + 1)
! buff = array.array('c', initer)
addressBuffer = buff.buffer_info()[0]
tr = struct.pack('llP', start, end, addressBuffer)
! trBuff = array.array('c', tr)
addressTrBuff = trBuff.buffer_info()[0]
numChars = self.SendScintilla(EM_GETTEXTRANGE, 0, addressTrBuff)
! return buff.tostring()[:numChars]
!
def ReplaceSel(self, str):
! buff = array.array('c', str + "\0")
! self.SendScintilla(SCI_REPLACESEL, 0, buff.buffer_info()[0]);
! buff = None
def GetLine(self, line=-1):
--- 348,363 ----
assert end >= 0 and end <= self.GetTextLength(), "The end postion is invalid"
initer = "=" * (end - start + 1)
! buff = array.array('u', initer)
addressBuffer = buff.buffer_info()[0]
tr = struct.pack('llP', start, end, addressBuffer)
! trBuff = array.array('b', tr)
addressTrBuff = trBuff.buffer_info()[0]
numChars = self.SendScintilla(EM_GETTEXTRANGE, 0, addressTrBuff)
! ## return buff.tounicode()[:numChars]
! return buff.tostring()[:numChars].decode(default_scintilla_encoding)
!
def ReplaceSel(self, str):
! buff = (str + "\0").encode(default_scintilla_encoding)
! self.SendScintilla(SCI_REPLACESEL, 0, buff)
def GetLine(self, line=-1):
***************
*** 376,381 ****
def SetWordWrap(self, mode):
! if mode <> win32ui.CRichEditView_WrapNone:
! raise ValueError, "We dont support word-wrap (I dont think :-)"
class CScintillaColorEditInterface(CScintillaEditInterface):
--- 377,382 ----
def SetWordWrap(self, mode):
! if mode != win32ui.CRichEditView_WrapNone:
! raise ValueError("We dont support word-wrap (I dont think :-)")
class CScintillaColorEditInterface(CScintillaEditInterface):
***************
*** 391,395 ****
if parent_func is not None:
return parent_func()
! import formatter
## return formatter.PythonSourceFormatter(self)
return formatter.BuiltinPythonSourceFormatter(self)
--- 392,396 ----
if parent_func is not None:
return parent_func()
! from . import formatter
## return formatter.PythonSourceFormatter(self)
return formatter.BuiltinPythonSourceFormatter(self)
Index: find.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla/find.py,v
retrieving revision 1.10
retrieving revision 1.10.4.1
diff -C2 -d -r1.10 -r1.10.4.1
*** find.py 16 Jun 2005 08:59:11 -0000 1.10
--- find.py 29 Aug 2008 06:16:42 -0000 1.10.4.1
***************
*** 27,31 ****
def __setattr__(self, attr, val):
if not hasattr(self, attr):
! raise AttributeError, attr
self.__dict__[attr]=val
--- 27,31 ----
def __setattr__(self, attr, val):
if not hasattr(self, attr):
! raise AttributeError(attr)
self.__dict__[attr]=val
***************
*** 104,108 ****
doc = control.GetParent().GetDocument()
except AttributeError:
! print "Cant find a document for the control!"
doc = None
if doc is not None:
--- 104,108 ----
doc = control.GetParent().GetDocum...
[truncated message content] |