mirror of
https://github.com/tanrax/lirve.el.git
synced 2024-11-10 07:45:41 +01:00
Add improviments
This commit is contained in:
parent
8feed7070f
commit
34f49c5333
@ -56,8 +56,11 @@
|
|||||||
("have" "had" "had")
|
("have" "had" "had")
|
||||||
("hear" "heard" "heard")
|
("hear" "heard" "heard")
|
||||||
("hide" "hid" "hidden")
|
("hide" "hid" "hidden")
|
||||||
("hit" "hit" "hit")))
|
("hit" "hit" "hit")
|
||||||
|
|
||||||
|
))
|
||||||
(buffer-name "*Learning irregular verbs in English*")
|
(buffer-name "*Learning irregular verbs in English*")
|
||||||
|
(state 1) ;; 1: start, 2: check, 3: success
|
||||||
(verb-to-learn-infinitive nil)
|
(verb-to-learn-infinitive nil)
|
||||||
(verb-to-learn-simple-past nil)
|
(verb-to-learn-simple-past nil)
|
||||||
(verb-to-learn-past-participle nil)
|
(verb-to-learn-past-participle nil)
|
||||||
@ -67,11 +70,13 @@
|
|||||||
(text-title " 🧑🎓 Learning irregular verbs in English 🇬🇧")
|
(text-title " 🧑🎓 Learning irregular verbs in English 🇬🇧")
|
||||||
(widget-item-verb nil)
|
(widget-item-verb nil)
|
||||||
(widget-field-simple-past nil)
|
(widget-field-simple-past nil)
|
||||||
|
(widget-label-check-simple-past nil)
|
||||||
(widget-field-past-participle nil)
|
(widget-field-past-participle nil)
|
||||||
|
(widget-label-check-past-participle nil)
|
||||||
(text-button-check "Check")
|
(text-button-check "Check")
|
||||||
(widget-button nil)
|
(widget-button nil)
|
||||||
(widget-message-success nil)
|
(widget-message-success nil)
|
||||||
(text-success "Congratulations!")
|
(text-success "Nice!")
|
||||||
(widget-button-quit nil)
|
(widget-button-quit nil)
|
||||||
(text-button-quit "Quit")
|
(text-button-quit "Quit")
|
||||||
(widget-button-replay nil)
|
(widget-button-replay nil)
|
||||||
@ -91,32 +96,93 @@
|
|||||||
(setq verb-to-learn-simple-past (nth 1 verbs-random))
|
(setq verb-to-learn-simple-past (nth 1 verbs-random))
|
||||||
(setq verb-to-learn-past-participle (nth 2 verbs-random))))
|
(setq verb-to-learn-past-participle (nth 2 verbs-random))))
|
||||||
|
|
||||||
(defun format-value-infinitive (value)
|
(defun format-value-infinitive ()
|
||||||
"Format the value of the infinitive."
|
"Format the value of the infinitive."
|
||||||
(format "Infinitive ➡️ %s" value))
|
(format "Infinitive ➡️ %s" verb-to-learn-infinitive))
|
||||||
|
|
||||||
(defun format-value-simple-past (value)
|
(defun format-check-simple-past ()
|
||||||
"Format the value of the simple past."
|
"Format the value of the simple past."
|
||||||
(format "Simple past ➡️ %s %s" value (if
|
(if (eq state 1)
|
||||||
(and
|
""
|
||||||
(string= value verb-to-learn-simple-past)
|
(format " %s" (if
|
||||||
(not (string= value "")))
|
(and
|
||||||
emoji-valid emoji-error)))
|
(string= (widget-value widget-field-simple-past) verb-to-learn-simple-past)
|
||||||
|
(not (string= (widget-value widget-field-simple-past) "")))
|
||||||
|
emoji-valid emoji-error))))
|
||||||
|
|
||||||
(defun start-or-replay ()
|
(defun format-check-past-participle ()
|
||||||
|
"Format the value of the past participle."
|
||||||
|
(if (eq state 1)
|
||||||
|
""
|
||||||
|
(format " %s" (if
|
||||||
|
(and
|
||||||
|
(string= (widget-value widget-field-past-participle) verb-to-learn-past-participle)
|
||||||
|
(not (string= (widget-value widget-field-past-participle) "")))
|
||||||
|
emoji-valid emoji-error))))
|
||||||
|
|
||||||
|
(defun toggle-layout-success ()
|
||||||
|
"Toggle the layout to success."
|
||||||
|
;; Cursor to end
|
||||||
|
(goto-char (point-max))
|
||||||
|
;; Text success
|
||||||
|
(setq widget-message-success (widget-create 'item
|
||||||
|
text-success
|
||||||
|
))
|
||||||
|
;; Replay button
|
||||||
|
(setq widget-button-replay (widget-create 'push-button
|
||||||
|
:size 20
|
||||||
|
:widget-push-button-prefix "\n\n%["
|
||||||
|
:widget-push-button-suffix "%]\n\n"
|
||||||
|
:notify (lambda (&rest ignore)
|
||||||
|
(start))
|
||||||
|
text-button-replay))
|
||||||
|
;; Quit button
|
||||||
|
(setq widget-button-quit (widget-create 'push-button
|
||||||
|
:size 20
|
||||||
|
:notify (lambda (&rest ignore))
|
||||||
|
text-button-quit)))
|
||||||
|
|
||||||
|
|
||||||
|
(defun start ()
|
||||||
"Start o replay challenge."
|
"Start o replay challenge."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
;; Set the state
|
||||||
|
(setq state 1)
|
||||||
;; Get a new verb
|
;; Get a new verb
|
||||||
(set-verb-to-learn)
|
(set-verb-to-learn)
|
||||||
;; Show the verb in infinitive
|
;; Show the verb in infinitive
|
||||||
(widget-value-set widget-item-verb (format-value-infinitive verb-to-learn-infinitive))
|
(widget-value-set widget-item-verb (format-value-infinitive))
|
||||||
|
;; Update labels
|
||||||
;; Clear the fields
|
(update)
|
||||||
(widget-value-set widget-field-simple-past "")
|
|
||||||
(widget-value-set widget-field-past-participle "")
|
|
||||||
;; Focus on the first field
|
;; Focus on the first field
|
||||||
(widget-forward 2))
|
(widget-forward 2))
|
||||||
|
|
||||||
|
(defun update ()
|
||||||
|
"Check the answers."
|
||||||
|
(interactive)
|
||||||
|
;; Is playing?
|
||||||
|
(when (and (eq state 1)
|
||||||
|
(or
|
||||||
|
(not (string= (widget-value widget-field-simple-past) ""))
|
||||||
|
(not (string= (widget-value widget-field-past-participle) "")))
|
||||||
|
)
|
||||||
|
(setq state 2))
|
||||||
|
;; Check the answers
|
||||||
|
(when (eq state 2)
|
||||||
|
;; Is win?
|
||||||
|
(when (and
|
||||||
|
(string= (widget-value widget-field-simple-past) verb-to-learn-simple-past)
|
||||||
|
(string= (widget-value widget-field-past-participle) verb-to-learn-past-participle))
|
||||||
|
;; Set the state
|
||||||
|
(setq state 3))
|
||||||
|
;; Update the check labels
|
||||||
|
(widget-value-set widget-label-check-simple-past (format-check-simple-past))
|
||||||
|
(widget-value-set widget-label-check-past-participle (format-check-past-participle))
|
||||||
|
)
|
||||||
|
;; Win
|
||||||
|
(when (eq state 3)
|
||||||
|
(toggle-layout-success)))
|
||||||
|
|
||||||
(defun kill-app ()
|
(defun kill-app ()
|
||||||
"Kill the application."
|
"Kill the application."
|
||||||
(interactive)
|
(interactive)
|
||||||
@ -145,38 +211,34 @@
|
|||||||
:size 8
|
:size 8
|
||||||
:help-echo "Type a Simple past"
|
:help-echo "Type a Simple past"
|
||||||
))
|
))
|
||||||
|
;; Label check
|
||||||
|
(insert " ")
|
||||||
|
(setq widget-label-check-simple-past (widget-create 'item
|
||||||
|
(format-check-simple-past)))
|
||||||
;; Separator
|
;; Separator
|
||||||
(insert "\n\nPast participle ➡️ ")
|
(insert "\nPast participle ➡️ ")
|
||||||
;; Past participle
|
;; Past participle
|
||||||
(setq widget-field-past-participle (widget-create 'editable-field
|
(setq widget-field-past-participle (widget-create 'editable-field
|
||||||
:size 8
|
:size 8
|
||||||
:help-echo "Type a Past participle"))
|
:help-echo "Type a Past participle"))
|
||||||
|
;; Label check
|
||||||
|
(insert " ")
|
||||||
|
(setq widget-label-check-past-participle (widget-create 'item
|
||||||
|
(format-check-past-participle)))
|
||||||
;; Separator
|
;; Separator
|
||||||
(insert "\n\n")
|
(insert "\n\n")
|
||||||
;; Check button
|
;; Check button
|
||||||
(setq widget-button (widget-create 'push-button
|
(setq widget-button (widget-create 'push-button
|
||||||
|
:notify (lambda (&rest ignore)
|
||||||
|
(update))
|
||||||
text-button-check))
|
text-button-check))
|
||||||
;; Separator
|
;; Separator
|
||||||
(insert "\n\n")
|
(insert "\n\n")
|
||||||
;; Success message
|
(setq widget-message-success nil)
|
||||||
(setq widget-message-success (widget-create 'item
|
|
||||||
text-success
|
|
||||||
))
|
|
||||||
;; Separator
|
|
||||||
(insert "\n ")
|
|
||||||
;; Replay button
|
;; Replay button
|
||||||
(setq widget-button-replay (widget-create 'push-button
|
(setq widget-button-replay nil)
|
||||||
:size 20
|
|
||||||
:notify (lambda (&rest ignore)
|
|
||||||
(start-or-replay))
|
|
||||||
text-button-replay))
|
|
||||||
;; Separator
|
|
||||||
(insert " ")
|
|
||||||
;; Quit button
|
;; Quit button
|
||||||
(setq widget-button-quit (widget-create 'push-button
|
(setq widget-button-quit nil)
|
||||||
:size 20
|
|
||||||
:notify (lambda (&rest ignore))
|
|
||||||
text-button-quit))
|
|
||||||
|
|
||||||
;; Display the buffer
|
;; Display the buffer
|
||||||
(use-local-map widget-keymap)
|
(use-local-map widget-keymap)
|
||||||
@ -187,7 +249,7 @@
|
|||||||
|
|
||||||
;; Init
|
;; Init
|
||||||
(main-layout)
|
(main-layout)
|
||||||
(start-or-replay)
|
(start)
|
||||||
))
|
))
|
||||||
|
|
||||||
(provide 'learning-irregular-verbs-in-English)
|
(provide 'learning-irregular-verbs-in-English)
|
||||||
|
Loading…
Reference in New Issue
Block a user