Cut and copy
This commit is contained in:
parent
d72e35add3
commit
6ba81591c5
|
|
@ -89,6 +89,7 @@ class CodeEditor(ScrollableView):
|
|||
self.lexer = ActionScriptLexer()
|
||||
self.cursorpos = 0
|
||||
self.scursorpos = 0
|
||||
self.selection = (0,0)
|
||||
self.formatter = PyGUIFormatter()
|
||||
# self.filter = NameHighlightFilter(
|
||||
self.filter = EverythingHighlightFilter(
|
||||
|
|
@ -169,6 +170,7 @@ class CodeEditor(ScrollableView):
|
|||
except:
|
||||
pass
|
||||
self.scursorpos = self.cursorpos
|
||||
self.selection = (self.cursorpos, self.cursorpos)
|
||||
if int(y/self.font.height):
|
||||
self.cursorpos+=1
|
||||
self.invalidate_rect([0,0,self.extent[0],self.extent[1]])
|
||||
|
|
@ -183,6 +185,7 @@ class CodeEditor(ScrollableView):
|
|||
pass
|
||||
if int(y/self.font.height):
|
||||
self.cursorpos+=1
|
||||
self.selection = (min(self.cursorpos, self.scursorpos), max(self.cursorpos, self.scursorpos))
|
||||
self.invalidate_rect([0,0,self.extent[0],self.extent[1]])
|
||||
def key_down(self, event):
|
||||
keydict = {127:"backspace",63272:"delete",63232:"up_arrow",63233:"down_arrow",
|
||||
|
|
@ -242,6 +245,7 @@ class CodeEditor(ScrollableView):
|
|||
self.text=self.text[:self.cursorpos]+str(key)+self.text[self.cursorpos:]
|
||||
self.cursorpos += 1
|
||||
self.scursorpos = self.cursorpos
|
||||
self.selection = (self.cursorpos, self.cursorpos)
|
||||
self.invalidate_rect([0,0,self.extent[0],self.extent[1]])
|
||||
class test(Application):
|
||||
def __init__(self):
|
||||
|
|
|
|||
|
|
@ -821,10 +821,16 @@ def redo(widget=None):
|
|||
undo_stack.append(e)
|
||||
MainWindow.stage.draw()
|
||||
|
||||
def cut(widget=None):
|
||||
if MainWindow.scriptwindow.is_focused():
|
||||
clip = MainWindow.scriptwindow.text[MainWindow.scriptwindow.selection[0]:MainWindow.scriptwindow.selection[1]]
|
||||
MainWindow.scriptwindow.insert("")
|
||||
svlgui.app.set_clipboard(clip)
|
||||
|
||||
def copy(widget=None):
|
||||
clip = svlgui.app.get_clipboard() if svlgui.app.query_clipboard() else None
|
||||
print clip
|
||||
raise blearrghh
|
||||
if MainWindow.scriptwindow.is_focused():
|
||||
clip = MainWindow.scriptwindow.text[MainWindow.scriptwindow.selection[0]:MainWindow.scriptwindow.selection[1]]
|
||||
svlgui.app.set_clipboard(clip)
|
||||
def paste(widget=None):
|
||||
clip = svlgui.app.get_clipboard() if svlgui.app.query_clipboard() else None
|
||||
if clip:
|
||||
|
|
@ -947,7 +953,7 @@ svlgui.menufuncs([["File",
|
|||
["Edit",
|
||||
("Undo", undo, "/z"),
|
||||
("Redo", redo, "/^z"),
|
||||
"Cut",
|
||||
("Cut", cut, "/x"),
|
||||
("Copy", copy, "/c"),
|
||||
("Paste", paste, "/v"),
|
||||
"Delete",
|
||||
|
|
|
|||
14
svlgui.py
14
svlgui.py
|
|
@ -341,6 +341,7 @@ if SYSTEM=="osx":
|
|||
m.undo_cmd.enabled = 1
|
||||
m.redo_cmd.enabled = 1
|
||||
m.copy_cmd.enabled = 1
|
||||
m.cut_cmd.enabled = 1
|
||||
m.paste_cmd.enabled = 1
|
||||
m.run_file.enabled = 1
|
||||
m.run_html.enabled = 1
|
||||
|
|
@ -573,7 +574,7 @@ def menufuncs(j):
|
|||
menus.append(menu)
|
||||
else:
|
||||
cmds={"New...":"new_cmd", "Save":"save_cmd", "Save As":"save_as_cmd", "Open":"open_cmd","About Lightningbeam...":"about_cmd",\
|
||||
"Preferences":"preferences_cmd", "Undo":"undo_cmd", "Redo":"redo_cmd", "Copy":"copy_cmd", "Paste":"paste_cmd"}
|
||||
"Preferences":"preferences_cmd", "Undo":"undo_cmd", "Redo":"redo_cmd", "Cut":"cut_cmd", "Copy":"copy_cmd", "Paste":"paste_cmd"}
|
||||
[setattr(app,cmds[k[0]],k[1]) for k in i if (k[0] in cmds)]
|
||||
|
||||
class VBox(Widget):
|
||||
|
|
@ -1215,7 +1216,14 @@ class TextView(Widget):
|
|||
def _settext(self, text):
|
||||
if SYSTEM=="osx":
|
||||
self.box.text = text
|
||||
def _getselection(self):
|
||||
if SYSTEM=="osx":
|
||||
return self.box.selection
|
||||
def _setselection(self, tup):
|
||||
if SYSTEM=="osx":
|
||||
self.box.selection = tup
|
||||
text = property(_gettext, _settext)
|
||||
selection = property(_getselection, _setselection)
|
||||
def __init__(self,editable=True,width=False,height=False,code=False):
|
||||
if SYSTEM=="gtk":
|
||||
self.sw=ScrolledWindow()
|
||||
|
|
@ -1256,7 +1264,9 @@ class TextView(Widget):
|
|||
def insert(self, text):
|
||||
if SYSTEM=="osx":
|
||||
if isinstance(self.box, CodeEditor):
|
||||
self.box.text = self.box.text[:self.box.scursorpos]+text+self.box.text[self.box.cursorpos:]
|
||||
self.box.text = self.box.text[:self.box.selection[0]]+text+self.box.text[self.box.selection[1]:]
|
||||
self.box.scursorpos = self.box.cursorpos = self.box.selection[0]+len(text)
|
||||
self.box.selection = (self.box.selection[0]+len(text), self.box.selection[0]+len(text))
|
||||
self.box.invalidate_rect([0,0,self.box.extent[0],self.box.extent[1]])
|
||||
def scroll_bottom(self):
|
||||
if SYSTEM=="osx":
|
||||
|
|
|
|||
Loading…
Reference in New Issue