Skip to content

Commit

Permalink
Position cursor correctly after paste. Insert, rewrap and move cursor
Browse files Browse the repository at this point in the history
along the inserted entries to get to the end. Line wraps have to be taken
into account.

Signed-off-by: picobyte <[email protected]>
  • Loading branch information
picobyte authored and picobyte committed Nov 14, 2017
1 parent ee32e18 commit 6d67fd4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion game/edit_button.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,25 @@ init -1500 python in _editor:
ey += 1
self.data.insert(ey, l)
self.data[ey] += end
self.parse()
# Move cursor to end of insertion. This is tricky.
i = 0
cx += len(entries[-1])
while cy + 1 != self.nolines:
bx, by = self.wrap2buf[cy+1]
if i == len(entries) - 1 and (bx == 0 or bx >= len(entries[i])):
if i == 0:
cx -= self.wrap2buf[cy][0]
elif cx == 0:
cx = len(entries[i]) - self.wrap2buf[cy][0]
break
cy += 1
if self.wrap2buf[cy][0] == 0:
i += 1
cx = 0
self.console.cy = self.console.CY = cy
self.console.max = self.console.cx = self.console.CX = cx
renpy.redraw(self.console, 0)
self.parse()

def handlekey(self, keystr):
""" repeat keys are handled as normal keys; unless shift is provided selection is discarded and cursor is redrawn """
Expand Down

0 comments on commit 6d67fd4

Please sign in to comment.