-
Notifications
You must be signed in to change notification settings - Fork 29
/
Notepad++_2_Julia.ahk
184 lines (171 loc) · 4.38 KB
/
Notepad++_2_Julia.ahk
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
;=====================================
; npp_julia.ahk
; Connect Julia and notepad++
; AutoHotkey: 1.x
; Language: English
; Platform: Windows7
; Author: ViralBShah - 2013
; Modified by: cameyo - 2015
; License: MIT license
;=====================================
; Hotkeys:
; Win-F12 -> Start Julia
; Left_Shift-Enter -> Evaluate current line
; Right_Shift-Enter -> Evaluate selected block
;=====================================
; Basic hotkeys symbol
;=====================================
; # Win key
; ! Alt key
; ^ Control key
; + Shift key
;=====================================
; General statements
;=====================================
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force ; Allow reload script
#WinActivateForce ; activate window with forceful method
;=====================================
; Global variables
;=====================================
#EscapeChar \
global hasRunJulia = 0
global JuliaPID = 0
global NppPID = 0
;---------------------------
OpenJulia()
{
if %hasRunJulia% = 0
{
Run julia.exe,,,JuliaPID
hasRunJulia = 1
ReturnToNpp()
return
}
Process, Exist, %JuliaPID%
if %ErrorLevel% = 0
{
Run julia.exe,,,JuliaPID
hasRunJulia = 1
ReturnToNpp()
return
}
}
;---------------------------
ReOpenJulia()
{
WinClose, ahk_pid %JuliaPID%
OpenJulia()
}
;---------------------------
SendToJulia()
{
OpenJulia()
WinWait, ahk_pid %JuliaPID%
WinActivate, ahk_pid %JuliaPID%
WinWaitActive, ahk_pid %JuliaPID%
; Past via menu (must disable SendMode Input)
;Send {Alt Down}{Space}{Alt up}ep{Enter}
; Past with send clipboard
StringReplace clipboard2, clipboard, \r\n, \n, All
SendInput {Raw}%clipboard2%\n
}
;---------------------------
ReturnToNpp()
{
WinActivate, ahk_pid %NppPID%
}
;---------------------------
PassLine()
{
WinGetCLASS, currentClass, A
If currentClass = Notepad++
{
WinGet, NppPID, PID, A
SendInput {Home}{Shift Down}{End}{Shift Up}{Ctrl Down}c{Ctrl Up}{End}
SendToJulia()
ReturnToNpp()
}
}
;---------------------------
PassBlock()
{
WinGetCLASS, currentClass, A
If currentClass = Notepad++
{
WinGet, NppPID, PID, A
SendInput {Ctrl Down}c{Ctrl Up}
SendToJulia()
ReturnToNpp()
}
}
;---------------------------
; Eval current line (Left Shift - Enter)
LShift & Enter:: PassLine()
;---------------------------
; Eval selected block (Right Shift - Enter)
RShift & Enter:: PassBlock()
;---------------------------
; Run Julia (Win-F12)
#$F12:: ReOpenJulia()
;================================================
; REPL enhancements
; Work only on console window
#IfWinActive ahk_class ConsoleWindowClass
;=============================
; Scroll command window back and forward
; Ctrl+PageUp / PageDown
;=============================
^PgUp:: SendInput {WheelUp}
^PgDn:: SendInput {WheelDown}
;=============================
; Paste in REPL
; Ctrl-V
; Better version
;=============================
^V::
StringReplace clipboard2, clipboard, \r\n, \n, All
SendInput {Raw}%clipboard2%
return
;=============================
; Paste in REPL
; Ctrl-V
; Old version (must disable SendMode Input)
;=============================
;^V::
; English menu (Edit->Paste)
;Send !{Space}ep
;return
#IfWinActive
;================================================
;=============================
; Greek Letters (lowercase)
; Control-Win-<char>
; char 'j' is free...
;=============================
^#a:: SendInput {U+03B1} ; alpha
^#b:: SendInput {U+03B2} ; beta
^#g:: SendInput {U+03B3} ; gamma
^#d:: SendInput {U+03B4} ; delta
^#y:: SendInput {U+03B5} ; epsilon (y)
^#z:: SendInput {U+03B6} ; zeta
^#e:: SendInput {U+03B7} ; eta
^#h:: SendInput {U+03B8} ; theta (h)
^#i:: SendInput {U+03B9} ; iota
^#k:: SendInput {U+03BA} ; kappa
^#l:: SendInput {U+03BB} ; lambda
^#m:: SendInput {U+03BC} ; mu
^#n:: SendInput {U+03BD} ; nu
^#x:: SendInput {U+03BE} ; xi
^#o:: SendInput {U+03BF} ; omicron
^#p:: SendInput {U+03C0} ; pi
^#r:: SendInput {U+03C1} ; rho
^#s:: SendInput {U+03C3} ; sigma
^#t:: SendInput {U+03C4} ; tau
^#u:: SendInput {U+03C5} ; upsilon
^#f:: SendInput {U+03C6} ; phi (f)
^#c:: SendInput {U+03C7} ; chi
^#v:: SendInput {U+03C8} ; psi (v)
^#w:: SendInput {U+03C9} ; omega (w)