-
Notifications
You must be signed in to change notification settings - Fork 0
/
LaTeX.py
67 lines (57 loc) · 2.12 KB
/
LaTeX.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from Folder import Folder
from pynput.keyboard import Key, Controller
import pyperclip
class LaTeX_Folder(Folder):
def __init__(self, maxkey):
super().__init__("LaTeX", maxkey)
self.keyboard = Controller()
self.set_key(0, "Bold", "bold.png", self.bold)
self.set_key(1, "Italic", "italic.png", self.italic)
self.set_key(2, "Underline", "underline.png", self.underline)
self.set_key(3, "Strikethrough", "strikethrough.png", self.strikethrough)
self.set_key(4, "Equation", "eq.png", self.insert_eq)
self.set_key(5, "Equation Nr", "eq.png", self.insert_eq_nr)
def bold(self):
self.keyboard.press(Key.ctrl)
self.keyboard.press('x')
text = pyperclip.paste()
text = "\\textbf{" + text + "}"
pyperclip.copy(text)
self.keyboard.press(Key.ctrl)
self.keyboard.press('v')
def italic(self):
self.keyboard.press(Key.ctrl)
self.keyboard.press('x')
text = pyperclip.paste()
text = "\\textit{" + text + "}"
pyperclip.copy(text)
self.keyboard.press(Key.ctrl)
self.keyboard.press('v')
def underline(self):
self.keyboard.press(Key.ctrl)
self.keyboard.press('x')
text = pyperclip.paste()
text = "\\underline{" + text + "}"
pyperclip.copy(text)
self.keyboard.press(Key.ctrl)
self.keyboard.press('v')
def strikethrough(self):
self.keyboard.press(Key.ctrl)
self.keyboard.press('x')
text = pyperclip.paste()
text = "\\sout{" + text + "}"
pyperclip.copy(text)
self.keyboard.press(Key.ctrl)
self.keyboard.press('v')
def insert_eq(self):
text = "\\begin{align*}\n\n\\end{align*}"
pyperclip.copy(text)
self.keyboard.press(Key.ctrl)
self.keyboard.press('v')
def insert_eq_nr(self):
text = "\\begin{align}\n\n\\end{align}"
pyperclip.copy(text)
self.keyboard.press(Key.ctrl)
self.keyboard.press('v')
def insert_image(self):
print("insert image")