aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/timer.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2023-03-10 00:20:47 +0900
committernsfisis <nsfisis@gmail.com>2023-03-10 00:20:47 +0900
commitbf5a7df4608a0cdf5b1c145fcf2002560f3ecf44 (patch)
tree7fdb6a4782ffd8a748316b2b6f322459cd8005c0 /cmd/timer.go
parent67c1fcf7467e59edea1d50358dc35bb5dcde3224 (diff)
downloadterm-clock-bf5a7df4608a0cdf5b1c145fcf2002560f3ecf44.tar.gz
term-clock-bf5a7df4608a0cdf5b1c145fcf2002560f3ecf44.tar.zst
term-clock-bf5a7df4608a0cdf5b1c145fcf2002560f3ecf44.zip
refactor: move common snippet to util.go
Diffstat (limited to 'cmd/timer.go')
-rw-r--r--cmd/timer.go20
1 files changed, 1 insertions, 19 deletions
diff --git a/cmd/timer.go b/cmd/timer.go
index b4f9857..0e0ff48 100644
--- a/cmd/timer.go
+++ b/cmd/timer.go
@@ -18,25 +18,7 @@ func drawTimer(scr *term.Screen, leftTime time.Duration, bgStyle, fgStyle term.S
// Clear the entire screen.
scr.Clear(bgStyle)
- // Calculate square width/height and offset.
- scrW, scrH := scr.Size()
- // 17
- // <--------------->
- // ### ### ### ### ^
- // # # # # # # # # # |
- // # # # # # # # # | 5
- // # # # # # # # # # |
- // ### ### ### ### v
- squareW := scrW / (17 + 2)
- squareH := scrH / (5 + 2)
- if squareH > squareW {
- squareH = squareW
- }
- if squareW > squareH*3/2 {
- squareW = squareH * 3 / 2
- }
- xOffset := (scrW - squareW*17) / 2
- yOffset := (scrH - squareH*5) / 2
+ squareW, squareH, xOffset, yOffset := calcSquareSize(scr)
// Minute
minute := leftTime.Minutes()