empty window
This commit is contained in:
5
install
Normal file
5
install
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
mkdir /usr/local/bin/ming-flashcards
|
||||||
|
cp *.scm /usr/local/bin/ming-flashcards/
|
||||||
|
cp mingMisc_Flashcards /usr/local/bin/mingMisc_Flashcards
|
||||||
|
chmod +x /usr/local/bin/mingMisc_Flashcards
|
||||||
47
ipc.scm
Normal file
47
ipc.scm
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
(load "utils.scm")
|
||||||
|
|
||||||
|
;since it will be the wm talking to us, invalid inputs won't happen
|
||||||
|
(define listen (lambda (handle-message draw title resizable subtype ideal-dimensions)
|
||||||
|
(display (let* (
|
||||||
|
[_input (get-line (current-input-port))]
|
||||||
|
[parts (split-string _input #\space 2)]
|
||||||
|
[command (car parts)]
|
||||||
|
[rest (if (= (length parts) 2)
|
||||||
|
(car (cdr parts))
|
||||||
|
"" ;if this is the case `rest` won't be used
|
||||||
|
)]
|
||||||
|
) (cond;
|
||||||
|
[
|
||||||
|
(string=? command "handle_message")
|
||||||
|
(symbol->string (car (handle-message ""))) ;doesn't handle clipboard copy request yet... or parse the message, for that matter
|
||||||
|
]
|
||||||
|
;draw
|
||||||
|
[
|
||||||
|
(string=? command "draw")
|
||||||
|
(draw "") ;placeholder, doesn't parse theme info or serialise
|
||||||
|
]
|
||||||
|
[
|
||||||
|
(string=? command "title")
|
||||||
|
(title)
|
||||||
|
]
|
||||||
|
[
|
||||||
|
(string=? command "resizable")
|
||||||
|
(s-bool->string (resizable))
|
||||||
|
]
|
||||||
|
[
|
||||||
|
(string=? command "subtype")
|
||||||
|
subtype
|
||||||
|
]
|
||||||
|
[
|
||||||
|
(string=? command "ideal_dimensions")
|
||||||
|
;placeholder
|
||||||
|
(s-list->string (ideal-dimensions (s-string->list rest)))
|
||||||
|
]
|
||||||
|
[
|
||||||
|
else
|
||||||
|
"invalid"
|
||||||
|
]
|
||||||
|
)))
|
||||||
|
(newline)
|
||||||
|
(listen handle-message draw title resizable subtype ideal-dimensions)
|
||||||
|
))
|
||||||
5
local-install
Executable file
5
local-install
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
mkdir ~/.local/bin/ming-flashcards
|
||||||
|
cp *.scm ~/.local/bin/ming-flashcards/
|
||||||
|
cp mingMisc_Flashcards ~/.local/bin/mingMisc_Flashcards
|
||||||
|
chmod +x ~/.local/bin/mingMisc_Flashcards
|
||||||
28
main.scm
Normal file
28
main.scm
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
(source-directories '("./" "./ming-flashcards"))
|
||||||
|
|
||||||
|
(load "ipc.scm")
|
||||||
|
|
||||||
|
(define handle-message (lambda (message)
|
||||||
|
;placeholder
|
||||||
|
;return either ('DoNothing) ('JustRedraw) or ('Request "string") clipboard copy request
|
||||||
|
(cons (string->symbol "JustRedraw") '())
|
||||||
|
))
|
||||||
|
|
||||||
|
(define draw (lambda (theme-info)
|
||||||
|
;placeholder
|
||||||
|
""
|
||||||
|
))
|
||||||
|
|
||||||
|
(define title (lambda ()
|
||||||
|
"Flashcards"
|
||||||
|
))
|
||||||
|
|
||||||
|
(define resizable (lambda ()
|
||||||
|
#t
|
||||||
|
))
|
||||||
|
|
||||||
|
(define ideal-dimensions (lambda (_)
|
||||||
|
'(300 300)
|
||||||
|
))
|
||||||
|
|
||||||
|
(listen handle-message draw title resizable "Window" ideal-dimensions)
|
||||||
3
mingMisc_Flashcards
Executable file
3
mingMisc_Flashcards
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
cd "$(dirname "${BASH_SOURCE[0]}")" #thanks stackoverflow
|
||||||
|
scheme --script ./ming-flashcards/main.scm
|
||||||
46
utils.scm
Normal file
46
utils.scm
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
(define-record-type theme-info (fields top background border-left-top border-right-bottom text top-text alt-background alt-text alt-secondary))
|
||||||
|
|
||||||
|
;s-string->theme-info
|
||||||
|
(define s-string->theme-info (lambda (str)
|
||||||
|
;split by : and then \x1F
|
||||||
|
(display "placeholder")
|
||||||
|
))
|
||||||
|
|
||||||
|
(define s-bool->string (lambda (b)
|
||||||
|
(if b "true" "false")
|
||||||
|
))
|
||||||
|
|
||||||
|
(define join-string (lambda (li j-str)
|
||||||
|
(string-append (car li)
|
||||||
|
(fold-left (lambda (a x)
|
||||||
|
(string-append a x)
|
||||||
|
)
|
||||||
|
""
|
||||||
|
(map (lambda (e) (string-append j-str e)) (cdr li))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
))
|
||||||
|
|
||||||
|
(define s-list->string (lambda (li)
|
||||||
|
(join-string (map number->string li) "\x1F;")
|
||||||
|
))
|
||||||
|
|
||||||
|
;max should be 0 if no max is desired
|
||||||
|
(define split-string (lambda (str split-char max)
|
||||||
|
(define split-string-tail (lambda (chars current splitted)
|
||||||
|
(if (or (= (length chars) 0) (= (+ (length splitted) 1) max))
|
||||||
|
(reverse (cons current splitted))
|
||||||
|
(let (
|
||||||
|
[c (car chars)]
|
||||||
|
) (if (char=? c split-char)
|
||||||
|
(split-string-tail (cdr chars) "" (cons current splitted))
|
||||||
|
(split-string-tail (cdr chars) (string-append current (string c)) splitted)
|
||||||
|
))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
(split-string-tail (string->list str) "" '())
|
||||||
|
))
|
||||||
|
|
||||||
|
(define s-string->list (lambda (str)
|
||||||
|
(split-string str #\x1F 0)
|
||||||
|
))
|
||||||
Reference in New Issue
Block a user