-
Notifications
You must be signed in to change notification settings - Fork 1
/
kanmap.py
310 lines (288 loc) · 21.1 KB
/
kanmap.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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division,print_function,absolute_import,unicode_literals
import sys
import os
import math
os.chdir(sys.path[0])
sys.path.append("LTsv")
from LTsv_printf import *
from LTsv_file import *
#from LTsv_time import *
#from LTsv_calc import *
#from LTsv_joy import *
#from LTsv_kbd import *
from LTsv_gui import *
from LTsv_glyph import *
def LTsv_kanmap_drawline(kanmap_linecount):
LTsv_draw_selcanvas(kanmap_canvas); LTsv_draw_color("black"); LTsv_draw_bgcolor("white")
drawline_y=kanmap_linecount*LTsv_glyph_kbdF
for map_xy in range(kanmap_charsW):
LTsv_global_canvasTAG(TkinterTAG="kanmap{0:04}{1:04}".format(map_xy,kanmap_linecount))
LTsv_draw_glyphskbd(draw_t=kanmap_chars[kanmap_linecount][map_xy][:1],draw_x=map_xy*LTsv_glyph_kbdF,draw_y=drawline_y)
LTsv_draw_queue()
kanmap_drawwait=20
kanmap_linecount=0
kanmap_linefix=False
def kanmap_KBDstart(drawwait):
global kanmap_drawwait
kanmap_drawwait=min(max(drawwait,5),1000)
LTsv_widget_settext(kanmap_window,"kanmap:pickling {0}".format(LTsv_global_kanmappath()))
for map_xy in range(len(LTsv_global_irohaalpha())):
map_x,map_y=kanmap_irohaalphaNX[map_xy]//LTsv_glyph_kbdF,kanmap_irohaalphaNY[map_xy]//LTsv_glyph_kbdF-2
for kbd_xy in range(len(LTsv_global_irohatype())):
kbd_x,kbd_y=map_x+(kbd_xy%12),map_y+(kbd_xy//12)
kanmap_chars[kbd_y][kbd_x]=LTsv_glyph_kanmapN[LTsv_global_irohaalpha()[map_xy]][kbd_xy]
map_x,map_y=kanmap_irohaalphaXX[map_xy]//LTsv_glyph_kbdF,kanmap_irohaalphaXY[map_xy]//LTsv_glyph_kbdF-2
for kbd_xy in range(len(LTsv_global_irohatype())):
kbd_x,kbd_y=map_x+(kbd_xy%12),map_y+(kbd_xy//12)
kanmap_chars[kbd_y][kbd_x]=LTsv_glyph_kanmapX[LTsv_global_irohaalpha()[map_xy]][kbd_xy]
global kanmap_linecount
kanmap_linecount=0
LTsv_window_after(kanmap_window,event_b=kanmap_KBDcount,event_i="kanmap_KBDcount",event_w=kanmap_drawwait)
def kanmap_KBDcount(window_objvoid=None,window_objptr=None):
global kanmap_linecount
LTsv_kanmap_drawline(kanmap_linecount); kanmap_linecount+=1
if kanmap_linecount < kanmap_charsH:
LTsv_window_after(kanmap_window,event_b=kanmap_KBDcount,event_i="kanmap_KBDcount",event_w=kanmap_drawwait)
else:
kanmap_KBDfinishDICstart()
def kanmap_checkboxdraw():
for map_xy in range(len(kanmap_checkboxL)):
draw_x,draw_y=kanmap_checkboxX[map_xy],kanmap_checkboxY[map_xy]
LTsv_draw_color("white"); LTsv_draw_bgcolor("white")
LTsv_draw_glyphsfill(draw_t=kanmap_checkboxT[map_xy][1],draw_x=draw_x+LTsv_glyph_kbdF,draw_y=draw_y+LTsv_glyph_kbdF,draw_f=10,draw_g="漫")
LTsv_draw_color("black"); LTsv_draw_bgcolor("white")
LTsv_draw_glyphsfill(draw_t=kanmap_checkboxT[map_xy][kanmap_checkboxC[map_xy]],draw_x=draw_x+LTsv_glyph_kbdF,draw_y=draw_y+LTsv_glyph_kbdF,draw_f=10,draw_g="漫")
LTsv_draw_color("gray"); LTsv_draw_bgcolor("gray")
LTsv_draw_polygon(*tuple([draw_x,draw_y,draw_x+LTsv_glyph_kbdW-1,draw_y,draw_x+LTsv_glyph_kbdW-1,draw_y+LTsv_glyph_kbdH-1,draw_x,draw_y+LTsv_glyph_kbdH-1]))
draw_x,draw_y=LTsv_glyph_kbdW*6,LTsv_glyph_kbdH*6
LTsv_draw_color("black"); LTsv_draw_bgcolor("white")
LTsv_draw_glyphsfill(draw_t="clipfind",draw_x=draw_x+LTsv_glyph_kbdF*3,draw_y=draw_y+LTsv_glyph_kbdF,draw_f=10,draw_g="漫")
LTsv_draw_color("gray"); LTsv_draw_bgcolor("gray")
LTsv_draw_polygon(*tuple([draw_x+LTsv_glyph_kbdF*2,draw_y,draw_x+LTsv_glyph_kbdW-1,draw_y,draw_x+LTsv_glyph_kbdW-1,draw_y+LTsv_glyph_kbdH-1,draw_x+LTsv_glyph_kbdF*2,draw_y+LTsv_glyph_kbdH-1]))
LTsv_draw_queue()
def kanmap_KBDfinishDICstart():
for map_xy in range(len(LTsv_global_irohaalpha())):
LTsv_draw_glyphskbd(draw_t=LTsv_global_irohaalphaN()[map_xy],draw_x=kanmap_irohaalphaNX[map_xy]-LTsv_glyph_kbdF*2,draw_y=kanmap_irohaalphaNY[map_xy],draw_f=10,draw_g="漫")
LTsv_draw_glyphskbd(draw_t=LTsv_global_irohaalphaX()[map_xy],draw_x=kanmap_irohaalphaXX[map_xy]-LTsv_glyph_kbdF*2,draw_y=kanmap_irohaalphaXY[map_xy],draw_f=10,draw_g="漫")
LTsv_draw_polygonfill(LTsv_glyph_kbdF//2,kanmap_dicY-LTsv_glyph_kbdF//2,kanmap_canvasW-LTsv_glyph_kbdF//2,kanmap_dicY-LTsv_glyph_kbdF//2,kanmap_canvasW-LTsv_glyph_kbdF//2,kanmap_dicY-LTsv_glyph_kbdF//2-1,LTsv_glyph_kbdF//2,kanmap_dicY-LTsv_glyph_kbdF//2-1)
LTsv_draw_queue()
LTsv_widget_settext(kanmap_window,"kanmap:pickling {0}".format(LTsv_global_kandicpath()))
for dic_xy in range(kandic_charsH):
for map_xy in range(kanmap_charsW):
dicpos=dic_xy*kanmap_charsW+map_xy
if dicpos >= len(kanmap_dicsplits): break;
kanmap_chars[kanmap_charsY+dic_xy][map_xy]=kanmap_dicsplits[dicpos][0:1]
global kanmap_linecount
kanmap_linecount=kanmap_charsH+1
LTsv_window_after(kanmap_window,event_b=kanmap_DICcount,event_i="kanmap_DICcount",event_w=kanmap_drawwait)
def kanmap_DICcount(window_objvoid=None,window_objptr=None):
global kanmap_linecount
LTsv_kanmap_drawline(kanmap_linecount); kanmap_linecount+=1
if kanmap_linecount < kandic_charsdicH:
LTsv_window_after(kanmap_window,event_b=kanmap_DICcount,event_i="kanmap_DICcount",event_w=kanmap_drawwait)
else:
kanmap_DICfinish()
def kanmap_DICfinish():
global kanmap_linefix
LTsv_widget_settext(kanmap_window,"kanmap")
kanmap_checkboxdraw()
kanmap_linefix=True
kanmap_cursorAX,kanmap_cursorAY=0,0; kanmap_cursorBX,kanmap_cursorBY=kanmap_cursorAX,kanmap_cursorAY
kanmap_cursorMX,kanmap_cursorMY=0,0; kanmap_cursorDX,kanmap_cursorDY=0,0;
def LTsv_kanmap_mousecursorXY():
global kanmap_cursorAX,kanmap_cursorAY,kanmap_cursorBX,kanmap_cursorBY
kanmap_cursorBX,kanmap_cursorBY=kanmap_cursorAX,kanmap_cursorAY
LTsv_draw_selcanvas(kanmap_canvas)
mouseX,mouseY=LTsv_global_canvasmotionX(),LTsv_global_canvasmotionY()
kanmap_cursorAX,kanmap_cursorAY=min(max(mouseX//LTsv_glyph_kbdF,0),kanmap_charsW),min(max(mouseY//LTsv_glyph_kbdF,0),kandic_charsdicH)
def LTsv_kanmap_mousecursordraw(cursorAX,cursorAY,cursorBX,cursorBY):
if len(kanmap_chars[cursorBY][cursorBX]) > 0:
if LTsv_GUI == LTsv_GUI_GTK2:
LTsv_draw_color("white"); LTsv_draw_bgcolor("white")
draw_x,draw_y=cursorBX*LTsv_glyph_kbdF,cursorBY*LTsv_glyph_kbdF
LTsv_draw_polygonfill(*tuple([draw_x,draw_y,draw_x+LTsv_glyph_kbdF,draw_y,draw_x+LTsv_glyph_kbdF,draw_y+LTsv_glyph_kbdF,draw_x,draw_y+LTsv_glyph_kbdF]))
elif LTsv_GUI == LTsv_GUI_Tkinter:
LTsv_deleteTAG("kanmap{0:04}{1:04}".format(cursorBX,cursorBY))
if ( cursorBX == kanmap_cursorMX and cursorBY == kanmap_cursorMY ) or ( cursorBX == kanmap_cursorDX and cursorBY == kanmap_cursorDY ):
LTsv_draw_color("IndianRed"); LTsv_draw_bgcolor("IndianRed")
LTsv_draw_polygonfill(*tuple([draw_x,draw_y,draw_x+LTsv_glyph_kbdF,draw_y,draw_x+LTsv_glyph_kbdF,draw_y+LTsv_glyph_kbdF,draw_x,draw_y+LTsv_glyph_kbdF]))
LTsv_draw_color("white"); LTsv_draw_bgcolor("IndianRed")
LTsv_draw_glyphskbd(draw_t=kanmap_chars[cursorBY][cursorBX][:1],draw_x=cursorBX*LTsv_glyph_kbdF,draw_y=cursorBY*LTsv_glyph_kbdF)
else:
LTsv_draw_color("black"); LTsv_draw_bgcolor("white")
LTsv_draw_glyphskbd(draw_t=kanmap_chars[cursorBY][cursorBX][:1],draw_x=cursorBX*LTsv_glyph_kbdF,draw_y=cursorBY*LTsv_glyph_kbdF)
if len(kanmap_chars[cursorAY][cursorAX]) > 0:
LTsv_global_canvasTAG(TkinterTAG="kanmap{0:04}{1:04}".format(cursorAX,cursorAY))
draw_x,draw_y=cursorAX*LTsv_glyph_kbdF,cursorAY*LTsv_glyph_kbdF
LTsv_draw_color("black"); LTsv_draw_bgcolor("black")
LTsv_draw_polygonfill(*tuple([draw_x,draw_y,draw_x+LTsv_glyph_kbdF,draw_y,draw_x+LTsv_glyph_kbdF,draw_y+LTsv_glyph_kbdF,draw_x,draw_y+LTsv_glyph_kbdF]))
LTsv_draw_color("white"); LTsv_draw_bgcolor("white")
LTsv_draw_glyphskbd(draw_t=kanmap_chars[cursorAY][cursorAX][:1],draw_x=cursorAX*LTsv_glyph_kbdF,draw_y=cursorAY*LTsv_glyph_kbdF)
LTsv_draw_queue()
def LTsv_kanmap_mousepress(window_objvoid=None,window_objptr=None):
if LTsv_glyph_mousepress(kanmap_canvas,kanmap_kbdX,kanmap_kbdY) == LTsv_global_kbdcursorNone():
if kanmap_linefix:
LTsv_kanmap_mousecursorXY()
LTsv_kanmap_mousecursordraw(kanmap_cursorAX,kanmap_cursorAY,kanmap_cursorBX,kanmap_cursorBY)
def LTsv_kanmap_mousemotion(window_objvoid=None,window_objptr=None):
if LTsv_glyph_mousemotion(kanmap_canvas,kanmap_kbdX,kanmap_kbdY) == LTsv_global_kbdcursorNone():
LTsv_kanmap_mousecursorXY()
if kanmap_linefix == True and (kanmap_cursorBX != kanmap_cursorAX or kanmap_cursorBY != kanmap_cursorAY):
LTsv_kanmap_mousecursordraw(kanmap_cursorAX,kanmap_cursorAY,kanmap_cursorBX,kanmap_cursorBY)
def LTsv_kanmap_mouserelease(window_objvoid=None,window_objptr=None):
global kanmap_cursorMX,kanmap_cursorMY,kanmap_cursorDX,kanmap_cursorDY
global kanmap_chars
if LTsv_glyph_mouserelease(kanmap_canvas,kanmap_kbdX,kanmap_kbdY) == LTsv_global_kbdcursorNone():
if kanmap_linefix:
LTsv_kanmap_mousecursorXY()
LTsv_kanmap_mousecursordraw(kanmap_cursorAX,kanmap_cursorAY,kanmap_cursorBX,kanmap_cursorBY)
check_x,check_y=(kanmap_cursorAX*LTsv_glyph_kbdF)//LTsv_glyph_kbdW,(kanmap_cursorAY*LTsv_glyph_kbdF)//LTsv_glyph_kbdH
if len(kanmap_chars[kanmap_cursorAY][kanmap_cursorAX]) > 0:
LTsv_widget_settext(kanmap_clipboard,kanmap_chars[kanmap_cursorAY][kanmap_cursorAX][:1])
if kanmap_cursorAY < kanmap_charsH:
cursorMX,cursorMY=kanmap_cursorMX,kanmap_cursorMY
kanmap_cursorMX,kanmap_cursorMY=kanmap_cursorAX,kanmap_cursorAY
LTsv_kanmap_mousecursordraw(kanmap_cursorMX,kanmap_cursorMY,cursorMX,cursorMY)
if kanmap_checkboxC[kanmap_checkboxN["swap"]] != 0:
if len(kanmap_chars[kanmap_cursorMY][kanmap_cursorMX]) > 0 and len(kanmap_chars[cursorMY][cursorMX]) > 0:
kanmap_chars[kanmap_cursorMY][kanmap_cursorMX],kanmap_chars[cursorMY][cursorMX]=kanmap_chars[cursorMY][cursorMX],kanmap_chars[kanmap_cursorMY][kanmap_cursorMX]
LTsv_kanmap_mousecursordraw(kanmap_cursorMX,kanmap_cursorMY,cursorMX,cursorMY)
kanmap_cursorMX,kanmap_cursorMY=0,0
LTsv_kanmap_mousecursordraw(kanmap_cursorMX,kanmap_cursorMY,cursorMX,cursorMY)
LTsv_kanmap_kbdchange(cursorMX,cursorMY); LTsv_kanmap_kbdchange(kanmap_cursorMY,kanmap_cursorDY)
if kanmap_cursorAY >= kanmap_charsH:
cursorDX,cursorDY=kanmap_cursorDX,kanmap_cursorDY
kanmap_cursorDX,kanmap_cursorDY=kanmap_cursorAX,kanmap_cursorAY
LTsv_kanmap_mousecursordraw(kanmap_cursorDX,kanmap_cursorDY,cursorDX,cursorDY)
if kanmap_checkboxC[kanmap_checkboxN["rewrite"]] != 0:
if len(kanmap_chars[kanmap_cursorMY][kanmap_cursorMX]) > 0 and len(kanmap_chars[kanmap_cursorDY][kanmap_cursorDX]) > 0:
kanmap_chars[kanmap_cursorMY][kanmap_cursorMX]=kanmap_chars[kanmap_cursorDY][kanmap_cursorDX]
LTsv_kanmap_mousecursordraw(kanmap_cursorDX,kanmap_cursorDY,kanmap_cursorMX,kanmap_cursorMY)
LTsv_kanmap_kbdchange(kanmap_cursorMX,kanmap_cursorMY)
else:
if ( check_x in kanmap_checkboxL ) and check_y == 6:
for map_xy in kanmap_checkboxL:
if map_xy == check_x:
kanmap_checkboxC[kanmap_checkboxL.index(map_xy)]=1 if kanmap_checkboxC[kanmap_checkboxL.index(map_xy)] == 0 else 0
else:
kanmap_checkboxC[kanmap_checkboxL.index(map_xy)]=0
kanmap_checkboxdraw()
if check_x ==6 and check_y == 6:
LTsv_kanmap_find()
def LTsv_kanmap_kbdchange(changeX,changeY):
global LTsv_glyph_kanmapN,LTsv_glyph_kanmapX
for map_xy in range(len(LTsv_global_irohaalpha())):
map_x,map_y=kanmap_irohaalphaNX[map_xy]//LTsv_glyph_kbdF,kanmap_irohaalphaNY[map_xy]//LTsv_glyph_kbdF-2
if map_x <= changeX < map_x+12 and map_y <= changeY < map_y+4:
kbd_x,kbd_y=changeX-map_x,changeY-map_y; kbd_xy=kbd_x+kbd_y*12
LTsv_glyph_kanmapN[LTsv_global_irohaalpha()[map_xy]][kbd_xy]=kanmap_chars[changeY][changeX]
map_x,map_y=kanmap_irohaalphaXX[map_xy]//LTsv_glyph_kbdF,kanmap_irohaalphaXY[map_xy]//LTsv_glyph_kbdF-2
if map_x <= changeX < map_x+12 and map_y <= changeY < map_y+4:
kbd_x,kbd_y=changeX-map_x,changeY-map_y; kbd_xy=kbd_x+kbd_y*12
LTsv_glyph_kanmapX[LTsv_global_irohaalpha()[map_xy]][kbd_xy]=kanmap_chars[changeY][changeX]
def LTsv_kanmap_keypress(window_objvoid=None,window_objptr=None):
LTsv_kanmap_kbdinput(LTsv_glyph_calctypelimited(kanmap_canvas,kanmap_kbdX,kanmap_kbdY))
def LTsv_kanmap_keyrelease(window_objvoid=None,window_objptr=None):
LTsv_kanmap_keypress()
def LTsv_kanmap_kbdinput(kbdinput):
kanmap_clipfind=kbdinput[:1]
LTsv_widget_settext(kanmap_clipboard,kanmap_clipfind)
if kanmap_checkboxC[kanmap_checkboxN["kbdfind"]] != 0:
LTsv_kanmap_find()
if kanmap_checkboxC[kanmap_checkboxN["update"]] != 0:
if kanmap_clipfind == '': kanmap_mapsave()
def LTsv_kanmap_find():
global kanmap_cursorMX,kanmap_cursorMY,kanmap_cursorDX,kanmap_cursorDY
kanmap_clipfind=LTsv_widget_gettext(kanmap_clipboard)[:1]
if len(kanmap_clipfind) > 0:
cursorDX,cursorDY=kanmap_cursorDX,kanmap_cursorDY; cursorMX,cursorMY=kanmap_cursorMX,kanmap_cursorMY
kanmap_cursorMX,kanmap_cursorMY=0,0; kanmap_cursorDX,kanmap_cursorDY=0,0;
for drawline_y in range(kandic_charsdicH):
if kanmap_clipfind in kanmap_chars[drawline_y]:
if drawline_y < kanmap_charsH:
if kanmap_cursorMX == 0:
kanmap_cursorMX,kanmap_cursorMY=kanmap_chars[drawline_y].index(kanmap_clipfind),drawline_y
LTsv_kanmap_mousecursordraw(kanmap_cursorMX,kanmap_cursorMY,cursorMX,cursorMY)
LTsv_kanmap_mousecursordraw(kanmap_cursorAX,kanmap_cursorAY,kanmap_cursorMX,kanmap_cursorMY)
if drawline_y > kanmap_charsH:
if kanmap_cursorDY == 0:
kanmap_cursorDX,kanmap_cursorDY=kanmap_chars[drawline_y].index(kanmap_clipfind),drawline_y
LTsv_kanmap_mousecursordraw(kanmap_cursorDX,kanmap_cursorDY,cursorDX,cursorDY)
LTsv_kanmap_mousecursordraw(kanmap_cursorAX,kanmap_cursorAY,kanmap_cursorDX,kanmap_cursorDY)
LTsv_glyph_kbdfind(kanmap_clipfind)
LTsv_glyph_kbddelete(kanmap_canvas); LTsv_glyph_kbddraw(kanmap_canvas,kanmap_kbdX,kanmap_kbdY); LTsv_draw_queue();
def kanmap_configsave_exit(window_objvoid=None,window_objptr=None):
# LTsv_widget_showhide(kanmap_window,False)
LTsv_glyph_picklesave()
LTsv_draw_canvas_save(kanmap_canvas,"kanmap.png")
if kanmap_checkboxC[kanmap_checkboxN["update"]] != 0:
kanmap_mapsave()
LTsv_window_exit()
def kanmap_mapsave():
kanmap_kanmapname=LTsv_global_kanmappath(); #kanmap_kanmapname="testkanmap.tsv"
kanmap_kanmap=""
for map_iroha in LTsv_global_irohaalpha():
# kanmap_irohaline="{0}\t{1}".format("\t".join(LTsv_glyph_kanmapN[map_iroha]),"\t".join(LTsv_glyph_kanmapX[map_iroha]))
if map_iroha == "¥": continue;
kanmap_irohaline="{0}\t{1}".format("\t".join(LTsv_glyph_kanmapN[map_iroha][0:(48-1)]),"\t".join(LTsv_glyph_kanmapX[map_iroha][0:(48-1)]))
kanmap_kanmap=LTsv_pushlinerest(kanmap_kanmap,map_iroha,kanmap_irohaline)
kanmap_kanmap=LTsv_pushlinerest(kanmap_kanmap," ","ぬ\tふ\tあ\tう\tえ\tお\tや\tゆ\tよ\tわ\tほ\tへ\tた\tて\tい\tす\tか\tん\tな\tに\tら\tせ\t゛\t゜\tち\tと\tし\tは\tき\tく\tま\tの\tり\tれ\tけ\tむ\tつ\tさ\tそ\tひ\tこ\tみ\tも\tね\tる\tめ\tろ"
"\t名\t音\t訓\t送\t異\t俗\t簡\t繁\t越\t地\t逆\t非\t英\t顔\tε\tρ\tτ\tυ\tθ\tι\tο\tπ\t゛\t゜\tα\tσ\tδ\tφ\tγ\tη\tξ\tκ\tλ\t代\t鍵\tぬ\tζ\tχ\tψ\tω\tβ\tν\tμ\t照\t○\t△\t□")
kanmap_kanmap=LTsv_pushlinerest(kanmap_kanmap,"©","# Copyright (c) 2016 ooblog # License: MIT # https://github.com/ooblog/LTsv10kanedit/blob/master/LICENSE")
LTsv_saveplain(kanmap_kanmapname,kanmap_kanmap)
LTsv_GUI=LTsv_guiinit()
if len(LTsv_GUI) > 0:
LTsv_kbdinit(LTsv_tsvpath="LTsv/LTsv_kbd.tsv",LTsv_initmouse=True)
LTsv_glyph_kbdinit(LTsv_tsvpath="LTsv/LTsv_glyph.tsv",LTsv_glyph_GUI=LTsv_GUI,LTsv_glyph_kbddefsize=1)
LTsv_glyph_kanmapN,LTsv_glyph_kanmapX=LTsv_global_kanmapN(),LTsv_global_kanmapX()
LTsv_glyph_kbdF=6*LTsv_glyph_kbdsize; LTsv_glyph_kbdW=LTsv_glyph_kbdF*(12+2); LTsv_glyph_kbdH=LTsv_glyph_kbdF*4
kanmap_charsW,kanmap_charsH=LTsv_glyph_kbdW*12//LTsv_glyph_kbdF,LTsv_glyph_kbdH*(6*2+1)//LTsv_glyph_kbdF
kanmap_charsY=kanmap_charsH+1; kanmap_dicY=kanmap_charsY*LTsv_glyph_kbdF
LTsv_glyph_kandic=LTsv_global_kandic(); kanmap_dicsplits=LTsv_glyph_kandic.rstrip('\n').split('\n')
kandic_charsH=int(math.ceil(len(kanmap_dicsplits)/kanmap_charsW))
kandic_charsdicH=kanmap_charsH+1+kandic_charsH
kanmap_chars=[["" for x in range(kanmap_charsW)] for y in range(kandic_charsdicH)]
# print(kanmap_charsW,kanmap_charsH,kandic_charsH,kanmap_charsW*(kandic_charsdicH))
kanmap_canvasW,kanmap_canvasH=LTsv_glyph_kbdF*kanmap_charsW,LTsv_glyph_kbdF*(kandic_charsdicH)
kanmap_kbdX,kanmap_kbdY=LTsv_glyph_kbdW*5,LTsv_glyph_kbdH*6
kanmap_irohaalphaNX,kanmap_irohaalphaNY=[0]*len(LTsv_global_irohaalpha()),[0]*len(LTsv_global_irohaalpha())
kanmap_irohaalphaXX,kanmap_irohaalphaXY=[0]*len(LTsv_global_irohaalpha()),[0]*len(LTsv_global_irohaalpha())
for map_xy in range(len(LTsv_global_irohaalpha())):
if map_xy < len(LTsv_global_irohaalpha())-3:
kanmap_irohaalphaNX[map_xy],kanmap_irohaalphaNY[map_xy]=LTsv_glyph_kbdW*(map_xy%12)+LTsv_glyph_kbdF*2,LTsv_glyph_kbdH*(map_xy//12)+LTsv_glyph_kbdF*2
kanmap_irohaalphaXX[map_xy],kanmap_irohaalphaXY[map_xy]=kanmap_irohaalphaNX[map_xy],kanmap_irohaalphaNY[map_xy]+LTsv_glyph_kbdH*7
else:
kanmap_irohaalphaNX[map_xy],kanmap_irohaalphaNY[map_xy]=LTsv_glyph_kbdW*(map_xy%12)+LTsv_glyph_kbdF*2,LTsv_glyph_kbdH*(map_xy//12)+LTsv_glyph_kbdF*2
kanmap_irohaalphaXX[map_xy],kanmap_irohaalphaXY[map_xy]=kanmap_irohaalphaNX[map_xy]+LTsv_glyph_kbdW*9,kanmap_irohaalphaNY[map_xy]+LTsv_glyph_kbdH*0
kanmap_checkboxL=[3,4,7,8]; kanmap_checkboxT=[["update☐","update☑"],["kbdfind☐","kbdfind☑"],["rewrite☐","rewrite☑"],["swap☐","swap☑"]]; kanmap_checkboxN={"update":0,"kbdfind":1,"rewrite":2,"swap":3}
kanmap_checkboxX,kanmap_checkboxY,kanmap_checkboxC=[0]*len(kanmap_checkboxL),[0]*len(kanmap_checkboxL),[0]*len(kanmap_checkboxL)
kanmap_checkboxC[kanmap_checkboxN["kbdfind"]]=1
for map_xy in range(len(kanmap_checkboxL)):
kanmap_checkboxX[map_xy],kanmap_checkboxY[map_xy]=kanmap_checkboxL[map_xy]*LTsv_glyph_kbdW,LTsv_glyph_kbdH*6
kanmap_window=LTsv_window_new(widget_t="kanmap",event_b=kanmap_configsave_exit,widget_w=kanmap_canvasW,widget_h=kanmap_canvasH,event_k=LTsv_kanmap_keypress,event_y=LTsv_kanmap_keyrelease)
kanmap_canvas=LTsv_canvas_new(kanmap_window,widget_x=0,widget_y=0,widget_w=kanmap_canvasW,widget_h=kanmap_canvasH,
event_p=LTsv_kanmap_mousepress,event_m=LTsv_kanmap_mousemotion,event_r=LTsv_kanmap_mouserelease,event_e=None,event_l=None,event_w=50)
kanmap_clipboard=LTsv_clipboard_new(kanmap_window)
LTsv_widget_showhide(kanmap_window,True)
LTsv_draw_selcanvas,LTsv_draw_delete,LTsv_draw_queue,LTsv_draw_picture=LTsv_draw_selcanvas_shell(LTsv_GUI),LTsv_draw_delete_shell(LTsv_GUI),LTsv_draw_queue_shell(LTsv_GUI),LTsv_draw_picture_shell(LTsv_GUI)
LTsv_draw_color,LTsv_draw_bgcolor,LTsv_draw_font,LTsv_draw_text=LTsv_draw_color_shell(LTsv_GUI),LTsv_draw_bgcolor_shell(LTsv_GUI),LTsv_draw_font_shell(LTsv_GUI),LTsv_draw_text_shell(LTsv_GUI)
LTsv_draw_polygon,LTsv_draw_polygonfill=LTsv_draw_polygon_shell(LTsv_GUI),LTsv_draw_polygonfill_shell(LTsv_GUI)
LTsv_draw_squares,LTsv_draw_squaresfill=LTsv_draw_squares_shell(LTsv_GUI),LTsv_draw_squaresfill_shell(LTsv_GUI)
LTsv_draw_circles,LTsv_draw_circlesfill=LTsv_draw_circles_shell(LTsv_GUI),LTsv_draw_circlesfill_shell(LTsv_GUI)
LTsv_draw_points=LTsv_draw_points_shell(LTsv_GUI)
LTsv_draw_arc,LTsv_draw_arcfill=LTsv_draw_arc_shell(LTsv_GUI),LTsv_draw_arcfill_shell(LTsv_GUI)
LTsv_deleteTAG=LTsv_draw_deleteTAG_shell(LTsv_GUI)
LTsv_glyph_tapcallback_shell(kanmap_canvas,LTsv_kanmap_kbdinput)
LTsv_draw_selcanvas(kanmap_canvas); LTsv_draw_delete(); LTsv_draw_queue();
LTsv_glyph_kbddelete(kanmap_canvas); LTsv_glyph_kbddraw(kanmap_canvas,kanmap_kbdX,kanmap_kbdY); LTsv_draw_queue();
# kanmap_KBDstart(5 if os.path.isfile(LTsv_global_picklepath()) else 50)
kanmap_KBDstart(50)
LTsv_window_main(kanmap_window)
else:
LTsv_libc_printf("GUIの設定に失敗しました。")
print("")
# Copyright (c) 2016 ooblog
# License: MIT
# https://github.com/ooblog/LTsv10kanedit/blob/master/LICENSE