kinda working?

This commit is contained in:
stjet
2026-08-02 07:41:09 +00:00
parent 0b7b2baa3e
commit 4ebe212090
6 changed files with 109 additions and 22 deletions

View File

@@ -1,20 +1,13 @@
(source-directories '("./" "./ming-flashcards"))
(load "ipc.scm")
(load "storage.scm")
(define-record-type flashcards (fields
(mutable dimensions)
(mutable input)
;questions to ask, to be removed when correctly answered
(mutable questions)
;current question
(mutable current)
;correct answer(s)
(mutable answers)
;total questions correctly asked
(mutable correct)
;total questions asked
(mutable total)
;if false, command mode
(mutable answer-mode)
))
@@ -43,6 +36,7 @@
[
(is-escape arg)
(let* (
[questions (flashcards-questions self)]
[answer-mode (flashcards-answer-mode self)]
[change (if answer-mode
#t
@@ -51,7 +45,9 @@
) (if change
(begin
(flashcards-answer-mode-set! self (not answer-mode))
(cons self '("JustRedraw"))
;and reset input
(flashcards-input-set! self "")
(list self "JustRedraw")
)
(list self "DoNothing")
))
@@ -61,19 +57,47 @@
;process flashcards.input
(if (flashcards-answer-mode self)
;check to see if answer is correct
(display "placeholder")
;
;process command
(display "placeholder")
;
(let ([ans (cadar (flashcards-questions self))])
(if (string=? (flashcards-input self) ans)
(begin
(flashcards-input-set! self "")
(flashcards-questions-set! self (cdr (flashcards-questions self)))
(list self "JustRedraw")
)
(begin
(flashcards-input-set! self ans)
(list self "JustRedraw")
)
)
)
(cond
[
(string-starts-with? (flashcards-input self) "load ")
(let* (
[parts (split-string (flashcards-input self) #\space 2)]
[name (list-ref parts 1)]
[questions (load-questions name)]
) (begin
(flashcards-questions-set! self questions)
;set answer mode to true, reset input
(flashcards-answer-mode-set! self #t)
(flashcards-input-set! self "")
(list self "JustRedraw")
))
]
[
else
(list self "DoNothing")
]
)
)
]
[
(is-backspace arg)
(if (= (length (flashcards-input self)) 0)
'(self '("DoNothing"))
(if (= (string-length (flashcards-input self)) 0)
(list self "DoNothing")
(let ([input (flashcards-input self)])
(flashcards-input-set! self (substring input 0 (- (length input) 1)))
(flashcards-input-set! self (substring input 0 (- (string-length input) 1)))
(list self "JustRedraw")
)
)
@@ -102,12 +126,16 @@
[coords (flashcards-dimensions self)]
[width (car coords)]
[height (car (cdr coords))]
[questions (flashcards-questions self)]
) (list
(draw-instructions-text (list 5 5) '("nimbus-roman") (if (> (length questions) 0)
(caar questions)
"No questions loaded"
) (theme-info-text ti) (theme-info-background ti) #f #f)
(draw-instructions-text (list 5 (- height 15)) '("nimbus-roman") (string-append (if (flashcards-answer-mode self)
"ANS: "
"CMD: "
) (flashcards-input self)) (theme-info-text ti) (theme-info-background ti) #f #f)
"b"
)
)
))
@@ -124,4 +152,12 @@
'(420 300)
))
(listen (make-flashcards '(0 0) "" '() "" '() 0 0 #f) handle-message draw title resizable "Window" ideal-dimensions)
(if (file-exists? "~/.local/share/ming-wm/logs.txt")
;rude, yeah. later, fix to append
(delete-file "~/.local/share/ming-wm/logs.txt")
)
(display (guard
(x [else (condition-message x)])
(listen (make-flashcards '(0 0) "" '() #f) handle-message draw title resizable "Window" ideal-dimensions)
) (open-output-file "~/.local/share/ming-wm/logs.txt"))