Skip to content

Commit

Permalink
fix insert
Browse files Browse the repository at this point in the history
Signed-off-by: picobyte <[email protected]>
  • Loading branch information
picobyte authored and picobyte committed Nov 14, 2017
1 parent 5b6005b commit ee32e18
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions game/edit_button.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,14 @@ init -1500 python in _editor:
none_selected = 1
return (cx, cy, CX, CY, none_selected)

def _cursor2buf_coords(self, cx, CX, cy, CY):
def _cursor2buf_coords(self, cx, cy, CX, CY):
sx, sy = self.wrap2buf[cy]
ex, ey = self.wrap2buf[CY]
return (sx+cx, sy+self.lnr, ex+CX, ey+self.lnr)

def DELETE(self):
cx, cy, CX, CY, none_selected = self._ordered_cursor_coordinates()
sx, sy, ex, ey = self._cursor2buf_coords(cx, CX, cy, CY)
sx, sy, ex, ey = self._cursor2buf_coords(cx, cy, CX, CY)

if sx != len(self.data[sy]) or not none_selected:
ex += none_selected # then delete the one right of the cursor
Expand All @@ -319,7 +319,7 @@ init -1500 python in _editor:
def copy(self):
import pyperclip # to use external copy buffer
cx, cy, CX, CY, none_selected = self._ordered_cursor_coordinates()
sx, sy, ex, ey = self._cursor2buf_coords(cx, CX, cy, CY)
sx, sy, ex, ey = self._cursor2buf_coords(cx, cy, CX, CY)
if not none_selected:
copy = ""
for y in xrange(sy, ey):
Expand All @@ -336,21 +336,20 @@ init -1500 python in _editor:
import pyperclip
if entries == None: # is paste in absences of entries
entries = pyperclip.paste().split(os.linesep)
if self.console.CX != self.console.cx or self.console.CY != self.console.cy:
self.DELETE()
buf = self.data[self.lnr+self.console.cy]
end = buf[self.console.cx:]
self.data[self.lnr+self.console.cy] = buf[:self.console.cx] + entries[0]
ct = len(entries)
if ct > 1:
for i in xrange(1, ct):
self.lnr += 1
self.data.insert(self.lnr+self.console.cy, entries[i])
self.console.max = len(entries[ct-1])
else:
self.console.max += len(entries[0])
self.data[self.lnr+self.console.cy] += end
self.console.CX = self.console.cx = min(self.console.max, len(self.line))
cx, cy, CX, CY, none_selected = self._ordered_cursor_coordinates()
sx, sy, ex, ey = self._cursor2buf_coords(cx, cy, CX, CY)
start = self.data[sy][:sx]
end = self.data[ey][ex:]
while sy != ey:
del self.data[sy+1]
ey -= 1
self.data[sy] = start + entries[0]
for l in entries[1:]:
ey += 1
self.data.insert(ey, l)
self.data[ey] += end
self.console.cy = self.console.CY = cy
self.console.max = self.console.cx = self.console.CX = cx
renpy.redraw(self.console, 0)
self.parse()

Expand Down

0 comments on commit ee32e18

Please sign in to comment.