Skip to content

Commit

Permalink
Merge pull request #77 from Jonak-Adipta-Kalita/main
Browse files Browse the repository at this point in the history
working skip
  • Loading branch information
moiSentineL authored Sep 5, 2024
2 parents dcbe21d + be0fc73 commit ca234e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
4 changes: 4 additions & 0 deletions flomo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def start(tag: str, name: str):
"""
try:
tag = tag.lower()
if tag not in conf.Config().get_config(conf.TAG_COLORS):
conf.Config().set_config(
conf.TAG_COLORS, f"{tag} aquamarine3", nested_value=True
)
db = tracker.Tracker()
db.create_table()
session_id = db.create_session(tag, name, datetime.datetime.now())
Expand Down
33 changes: 13 additions & 20 deletions flomo/ui.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import datetime
import threading
import time

Expand All @@ -8,7 +7,6 @@
from rich.panel import Panel
from rich.text import Text

import flomo.config as config
import flomo.helpers as helpers
import flomo.tracker as tracker

Expand All @@ -31,7 +29,6 @@ def __init__(
f"bold {self.tag_color}" if self.status == 0 else "bold red"
)


self.terminal = blessed.Terminal()

def generate_panel(self):
Expand Down Expand Up @@ -66,7 +63,7 @@ def show_live_panel(self):

def get_input(self):
with self.terminal.cbreak(), self.terminal.hidden_cursor():
return self.terminal.inkey().lower()
return self.terminal.inkey(timeout=0.1).lower()


def main(tag: str, name: str, session_id: str):
Expand Down Expand Up @@ -97,22 +94,18 @@ def main(tag: str, name: str, session_id: str):
del flowing_ui

chilling_ui = UI(1, tag, name, int(chilling_time))
chilling_ui.show_live_panel()
# TODO: Fix skipping break issue
# chilling_panel_thread = threading.Thread(
# target=chilling_ui.show_live_panel, daemon=True)
# chilling_panel_thread.start()

# while True:
# if chilling_ui.chilling_time == 1:
# break
# helpers.message_log(str(chilling_ui.chilling_time))
# inp = chilling_ui.get_input()
# if inp == "q":
# break

chilling_panel_thread = threading.Thread(
target=chilling_ui.show_live_panel, daemon=True)
chilling_panel_thread.start()

while chilling_ui.chilling_time > 1: # type: ignore
inp = chilling_ui.get_input()
if inp == "q":
break

chilling_ui.close_live_panel = True
# chilling_panel_thread.join()
chilling_panel_thread.join()

del chilling_ui
except KeyboardInterrupt:
Expand All @@ -124,7 +117,7 @@ def main(tag: str, name: str, session_id: str):
flowing_panel_thread.join()
if "play_sound_thread" in locals() and play_sound_thread.is_alive():
play_sound_thread.join()
# if 'chilling_panel_thread' in locals() and chilling_panel_thread.is_alive():
# chilling_panel_thread.join()
if 'chilling_panel_thread' in locals() and chilling_panel_thread.is_alive():
chilling_panel_thread.join()
finally:
tracker.end_session(session_id)

0 comments on commit ca234e2

Please sign in to comment.