From 89a6f09a90192f9b9a14923832a923b2c704ce67 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Wed, 19 Nov 2025 17:58:00 +0100 Subject: [PATCH] wip --- src/mpv/control.gleam | 8 ++++++++ src/mpv/mpv.gleam | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/mpv/control.gleam b/src/mpv/control.gleam index 690beaf..ee188d9 100644 --- a/src/mpv/control.gleam +++ b/src/mpv/control.gleam @@ -10,6 +10,8 @@ import tcp/tcp.{type Socket} pub type Control { TogglePlayPause + Search + Exit } @@ -17,7 +19,12 @@ pub type ControlError { ControlError(details: String) } +// TODO this should also have a context: +// `/` in "artist list" "context will should be`control.Search` +// `` in "create new playlist" context should be `control.Input` +// `q` in most contexts should be `Exit`, but in a popup it should be `Close` pub fn from_key(key: Key) -> Result(Control, Nil) { + echo key case key { key.Char(char) -> char_control(char) _ -> Error(Nil) @@ -28,6 +35,7 @@ fn char_control(char: String) -> Result(Control, Nil) { case char { " " -> Ok(TogglePlayPause) "q" -> Ok(Exit) + "/" -> Ok(Search) _ -> Error(Nil) } } diff --git a/src/mpv/mpv.gleam b/src/mpv/mpv.gleam index b12e950..967b7ef 100644 --- a/src/mpv/mpv.gleam +++ b/src/mpv/mpv.gleam @@ -70,6 +70,10 @@ fn handle_message( control: Control, ) -> actor.Next(State(socket, inject, input_output, exit), Control) { case control { + control.Search -> { + process.send(state.inject_input, key.Continue([key.input_introducer])) + actor.continue(state) + } control.TogglePlayPause -> { echo "toggling play/pause"