about summary refs log tree commit diff stats
path: root/forth/pomo.fs
blob: aaed3f7cbb0d8b0b5e1e05f41c9772d4c5d44f4c (plain) (blame)
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
( POMO POMO POMO )

VARIABLE POMO-TIME
1500000 POMO-TIME !

VARIABLE REST-TIME
600000 REST-TIME !

( TODO: Consider using VALUE instead of VARIABLE )

: 1SEC  1000  MS ;
: 30SEC 30000 MS ;
: 60SEC 60000 MS ;

: PRETTY-TIME
	1000 / 
	60 / 
; 

( DECREMENTS POMO-TIME if it is greater than 0 )
: CHECK-POMO-TIME? 
	0> IF
		POMO-TIME @ 1000 - POMO-TIME ! ." 🍅" SPACE POMO-TIME @ PRETTY-TIME . ." minutes" CR
		." ....." SPACE POMO-TIME ? CR
	ELSE 
		REST-TIME @ 1000 - REST-TIME ! ." 😴" SPACE REST-TIME @ PRETTY-TIME . ." minutes" CR
		." ....." SPACE REST-TIME ? CR
	THEN
;

( POMO-LOOP exits when POMO-TIME reaches 0 )
( FIXME: reset POMO-TIME and REST-TIME once they've reached 0 )
: POMO-LOOP
	BEGIN
		PAGE
      POMO-TIME @ CHECK-POMO-TIME? 1SEC 
		PAGE
		POMO-TIME @ REST-TIME @ + 0=
	UNTIL
;

POMO-LOOP

BYE