Compare commits
3 Commits
875eb9ced9
...
747f76a584
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
747f76a584 | ||
|
|
a6ac9eb5f7 | ||
|
|
4d935a2e29 |
@@ -38,7 +38,9 @@ pub fn from_list(l: List(String)) -> Key {
|
||||
[ci] | [ci, _] if ci == input_introducer -> Continue(l)
|
||||
[ii, cmd, tail] if ii == input_introducer -> {
|
||||
case tail {
|
||||
// Return
|
||||
"\r" -> Input(cmd)
|
||||
// Backspace
|
||||
"\u{007F}" -> Continue([ii, string.drop_end(cmd, 1)])
|
||||
_ -> Continue([ii, cmd <> tail])
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@ import tcp/tcp.{type Socket}
|
||||
pub type Control {
|
||||
TogglePlayPause
|
||||
|
||||
Search
|
||||
|
||||
Exit
|
||||
}
|
||||
|
||||
@@ -19,12 +17,7 @@ pub type ControlError {
|
||||
ControlError(details: String)
|
||||
}
|
||||
|
||||
// TODO this should also have a context:
|
||||
// `/` in "artist list" "context will should be`control.Search`
|
||||
// `<some char>` 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)
|
||||
@@ -35,7 +28,6 @@ fn char_control(char: String) -> Result(Control, Nil) {
|
||||
case char {
|
||||
" " -> Ok(TogglePlayPause)
|
||||
"q" -> Ok(Exit)
|
||||
"/" -> Ok(Search)
|
||||
_ -> Error(Nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,10 +64,6 @@ 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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user