Skip to content

Commit

Permalink
Add copy and paste operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
MatanZ committed May 28, 2021
1 parent 876d197 commit 97b3760
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pympress/scribble.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import os
import sympy
import io
import copy

import gi
import cairo
Expand Down Expand Up @@ -181,6 +182,7 @@ class Scribbler(builder.Builder):

selected = []
select_rect = [[],[]]
clipboard = None

min_distance = 0

Expand Down Expand Up @@ -323,6 +325,10 @@ def nav_scribble(self, name, ctrl_pressed, command=None):
self.set_pen(name)
elif command == 'fill_copy':
self.fill_color = self.scribble_color
elif command == 'copy':
self.copy()
elif command == 'paste':
self.paste()
elif command == 'move':
self.enable_move()
elif command == 'del_selected':
Expand Down Expand Up @@ -537,6 +543,16 @@ def set_pen(self, name):
except ValueError:
pass

def copy(self):
self.clipboard = copy.deepcopy(self.selected)

def paste(self):
if self.clipboard:
# Allows for pasting multiple times
s = copy.deepcopy(self.clipboard)
self.scribble_list.extend(s)
self.add_undo(('a', s))

def select_all(self):
self.selected = self.scribble_list[:]
self.redraw_current_slide()
Expand Down
2 changes: 2 additions & 0 deletions pympress/share/defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,5 @@ next_tool = Tab
next_stamp = w
ellipse = F5
latex = F6
copy = <ctrl>c
paste = <ctrl>v

0 comments on commit 97b3760

Please sign in to comment.