chore: initialize repository and staged implementation plan
This commit is contained in:
commit
cb0e9d156f
48 files changed
+7343
No files matched your search
@@ -0,0 +1,58 @@
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
|
||||
class RunApp:
|
||||
kind = 'run'
|
||||
title = 'Выполнить'
|
||||
icon = 'R'
|
||||
cmd = None
|
||||
|
||||
def __init__(self):
|
||||
self.input = ""
|
||||
|
||||
def render(self, fonts, bg, now):
|
||||
img = bg.copy()
|
||||
d = ImageDraw.Draw(img)
|
||||
|
||||
# Белое окно с чёрной рамкой
|
||||
d.rectangle((4, 17, 123, 46), fill=1, outline=0)
|
||||
|
||||
# Чёрный текст "Открыть:" (поднят на 3 пикселя вверх)
|
||||
d.text((7, 18), "Открыть:", font=fonts['small'], fill=0)
|
||||
|
||||
# Чёрная рамка поля ввода
|
||||
d.rectangle((7, 29, 120, 42), outline=0)
|
||||
|
||||
# Чёрный вводимый текст
|
||||
shown = self.input[:16]
|
||||
d.text((9, 30), shown, font=fonts['small'], fill=0)
|
||||
|
||||
# Чёрный курсор
|
||||
cx = min(118, 9 + int(d.textlength(shown, font=fonts['small'])) + 1)
|
||||
d.rectangle((cx, 32, cx + 1, 40), fill=0)
|
||||
|
||||
return img
|
||||
|
||||
def handle_key(self, code, mods, system):
|
||||
if code in (28, 96):
|
||||
self._execute(system)
|
||||
return True
|
||||
if code == 14:
|
||||
self.input = self.input[:-1]
|
||||
return True
|
||||
ch = system._char_for(code, mods.get('shift', False))
|
||||
if ch and len(ch) == 1:
|
||||
self.input = (self.input + ch)[-32:]
|
||||
return True
|
||||
return False
|
||||
|
||||
def _execute(self, system):
|
||||
from OKNA96.apps import find_by_cmd
|
||||
cmd = self.input.strip().lower()
|
||||
self.input = ""
|
||||
kind = find_by_cmd(cmd)
|
||||
system._close_app('run')
|
||||
if kind:
|
||||
system._open_app(kind)
|
||||
else:
|
||||
system.show_error("Несуществующая программа")
|
||||
Reference in new issue
Block a user