The seam loses its hue and the chords become reachable
Browse files at this commit9e2bfd6ee13719011957b2b5880bce15e4c1e784Parent: 14bd4a6- fix
- the seam loses its hue and the chords become reachable
8 changed files +180 -123
- crates/app/src/keymap.rs +96 -98
- crates/app/src/main.rs +0 -8
- crates/app/src/oracle.rs +2 -0
- crates/app/src/player/actions.rs +15 -6
- crates/app/src/tests/layout.rs +34 -0
- crates/app/src/tests/view.rs +0 -1
- crates/app/src/ui/overlays.rs +0 -1
- crates/app/src/ui/stance.rs +33 -9
crates/app/src/keymap.rsmodified+96 -98
| @@ -81,10 +81,20 @@ actions! { | |||
| 81 | PrevSyncPoint, | 81 | PrevSyncPoint, |
| 82 | NextSyncPoint, | 82 | NextSyncPoint, |
| 83 | /// Walks to the next cut (DESIGN.md §6): the odometer the cut readout | 83 | /// Walks to the next cut (DESIGN.md §6): the odometer the cut readout |
| 84 | - /// counts against. Shift strides ten cuts instead of one. | 84 | + /// counts against. |
| 85 | WalkCutNext, | 85 | WalkCutNext, |
| 86 | - /// The pair's other half, one cut earlier. Shift strides ten. | 86 | + /// The pair's other half, one cut earlier. |
| 87 | WalkCutPrev, | 87 | WalkCutPrev, |
| 88 | + /// [`ActionId::WalkCutNext`]'s stride-ten (DESIGN.md §6's "shift"): its | ||
| 89 | + /// own action, not a modifier read off `WalkCutNext`, because gpui 0.2.2 | ||
| 90 | + /// never delivers a shift modifier alongside `.`/`,` (see [`Chord`]'s | ||
| 91 | + /// doc) -- the *only* channel a stroke has back to [`Player::act`] is | ||
| 92 | + /// which [`ActionId`] the keymap resolved it to, so the stride the | ||
| 93 | + /// platform can't spell as a modifier is spelled as its own bound key | ||
| 94 | + /// (`>`, what shift+. actually types) instead. | ||
| 95 | + WalkCutNext10, | ||
| 96 | + /// The pair's other half (`<`, what shift+, actually types). | ||
| 97 | + WalkCutPrev10, | ||
| 88 | /// Marks the playhead as an export's in point. The out point wraps around | 98 | /// Marks the playhead as an export's in point. The out point wraps around |
| 89 | /// it if the mark lands past the current out ([`ordered_range`]). | 99 | /// it if the mark lands past the current out ([`ordered_range`]). |
| 90 | SetIn, | 100 | SetIn, |
| @@ -145,11 +155,12 @@ actions! { | |||
| 145 | Crossfade, | 155 | Crossfade, |
| 146 | /// No-aim trim of the subject cut's in point, frame detents, at any zoom | 156 | /// No-aim trim of the subject cut's in point, frame detents, at any zoom |
| 147 | /// (DESIGN.md §6), on its designed bare `[`. [`ActionId::SelectPrev`] | 157 | /// (DESIGN.md §6), on its designed bare `[`. [`ActionId::SelectPrev`] |
| 148 | - /// moved to shift+[ to free it -- see keymap.rs's own defaults. | 158 | + /// moved to `{` (what shift+[ actually types) to free it -- see |
| 159 | + /// keymap.rs's own defaults. | ||
| 149 | TrimIn, | 160 | TrimIn, |
| 150 | /// The pair's other half, the subject cut's out point, on its designed | 161 | /// The pair's other half, the subject cut's out point, on its designed |
| 151 | - /// bare `]` -- [`ActionId::SelectNext`] moved to shift+] for the same | 162 | + /// bare `]` -- [`ActionId::SelectNext`] moved to `}` (what shift+] |
| 152 | - /// reason. | 163 | + /// actually types) for the same reason. |
| 153 | TrimOut, | 164 | TrimOut, |
| 154 | /// Loop-trim: loops around the subject cut while trimming it (DESIGN.md | 165 | /// Loop-trim: loops around the subject cut while trimming it (DESIGN.md |
| 155 | /// §6, "the modernized Avid trim mode"). | 166 | /// §6, "the modernized Avid trim mode"). |
| @@ -208,8 +219,10 @@ impl ActionId { | |||
| 208 | ActionId::GoEnd => "Go to the last frame", | 219 | ActionId::GoEnd => "Go to the last frame", |
| 209 | ActionId::PrevSyncPoint => "Previous sync point (a cut here is copied, not re-encoded)", | 220 | ActionId::PrevSyncPoint => "Previous sync point (a cut here is copied, not re-encoded)", |
| 210 | ActionId::NextSyncPoint => "Next sync point (a cut here is copied, not re-encoded)", | 221 | ActionId::NextSyncPoint => "Next sync point (a cut here is copied, not re-encoded)", |
| 211 | - ActionId::WalkCutNext => "Walk to the next cut (shift: ten cuts)", | 222 | + ActionId::WalkCutNext => "Walk to the next cut", |
| 212 | - ActionId::WalkCutPrev => "Walk to the previous cut (shift: ten cuts)", | 223 | + ActionId::WalkCutPrev => "Walk to the previous cut", |
| 224 | + ActionId::WalkCutNext10 => "Walk ten cuts forward", | ||
| 225 | + ActionId::WalkCutPrev10 => "Walk ten cuts back", | ||
| 213 | ActionId::SetIn => "Mark in (export range)", | 226 | ActionId::SetIn => "Mark in (export range)", |
| 214 | ActionId::SetOut => "Mark out (export range)", | 227 | ActionId::SetOut => "Mark out (export range)", |
| 215 | ActionId::ClearRange => "Clear the export range", | 228 | ActionId::ClearRange => "Clear the export range", |
| @@ -287,6 +300,8 @@ impl ActionId { | |||
| 287 | ActionId::NextSyncPoint => "next-sync-point", | 300 | ActionId::NextSyncPoint => "next-sync-point", |
| 288 | ActionId::WalkCutNext => "walk-cut-next", | 301 | ActionId::WalkCutNext => "walk-cut-next", |
| 289 | ActionId::WalkCutPrev => "walk-cut-prev", | 302 | ActionId::WalkCutPrev => "walk-cut-prev", |
| 303 | + ActionId::WalkCutNext10 => "walk-cut-next-10", | ||
| 304 | + ActionId::WalkCutPrev10 => "walk-cut-prev-10", | ||
| 290 | ActionId::SetIn => "set-in", | 305 | ActionId::SetIn => "set-in", |
| 291 | ActionId::SetOut => "set-out", | 306 | ActionId::SetOut => "set-out", |
| 292 | ActionId::ClearRange => "clear-range", | 307 | ActionId::ClearRange => "clear-range", |
| @@ -366,6 +381,8 @@ impl ActionId { | |||
| 366 | | ActionId::NextSyncPoint | 381 | | ActionId::NextSyncPoint |
| 367 | | ActionId::WalkCutNext | 382 | | ActionId::WalkCutNext |
| 368 | | ActionId::WalkCutPrev | 383 | | ActionId::WalkCutPrev |
| 384 | + | ActionId::WalkCutNext10 | ||
| 385 | + | ActionId::WalkCutPrev10 | ||
| 369 | | ActionId::SetIn | 386 | | ActionId::SetIn |
| 370 | | ActionId::SetOut | 387 | | ActionId::SetOut |
| 371 | | ActionId::ClearRange => Category::Playback, | 388 | | ActionId::ClearRange => Category::Playback, |
| @@ -796,27 +813,35 @@ pub static FIXED: std::sync::LazyLock<[Fixed; 35]> = std::sync::LazyLock::new(|| | |||
| 796 | ] | 813 | ] |
| 797 | }); | 814 | }); |
| 798 | 815 | ||
| 799 | -/// A stroke as the key handler sees it: gpui's key name plus the two | 816 | +/// A stroke as the key handler sees it: gpui's key name plus the one |
| 800 | -/// modifiers this editor binds. Nothing else is a chord here -- alt is part | 817 | +/// modifier this editor binds. Nothing else is a chord here -- alt is part |
| 801 | -/// of the key name gpui reports, and a third modifier would need the file | 818 | +/// of the key name gpui reports, and a second modifier would need the file |
| 802 | /// format to grow before it could be spelled. | 819 | /// format to grow before it could be spelled. |
| 820 | +/// | ||
| 821 | +/// There is no `shift` field. gpui 0.2.2 (linux/platform.rs:909-917) clears | ||
| 822 | +/// the shift modifier for any single-char key whose upper and lower case are | ||
| 823 | +/// the same -- every symbol key (`,` `.` `[` `]` `/` `=` ...) -- so a chord | ||
| 824 | +/// carrying `shift` could never be struck for any of them; the shifted | ||
| 825 | +/// stroke arrives instead as the key it types (`shift+.` is the key `>`). | ||
| 826 | +/// The one place this editor wanted shift on a symbol (the odometer's | ||
| 827 | +/// stride-ten, DESIGN.md §6) is bound on that literal key instead | ||
| 828 | +/// (`keymap.rs`'s own `defaults`), and a non-symbol key that wants shift | ||
| 829 | +/// (the EQ card's arrows) reads `event.keystroke.modifiers.shift` straight | ||
| 830 | +/// off the keystroke, upstream of this struct entirely -- so the field had | ||
| 831 | +/// zero production callers and is gone rather than kept dead. | ||
| 803 | #[derive(Clone, PartialEq, Eq, Debug)] | 832 | #[derive(Clone, PartialEq, Eq, Debug)] |
| 804 | pub struct Chord { | 833 | pub struct Chord { |
| 805 | pub key: String, | 834 | pub key: String, |
| 806 | pub ctrl: bool, | 835 | pub ctrl: bool, |
| 807 | - pub shift: bool, | ||
| 808 | } | 836 | } |
| 809 | 837 | ||
| 810 | impl Chord { | 838 | impl Chord { |
| 811 | - /// The file's spelling, and the only one [`parse`] accepts back. Ctrl | 839 | + /// The file's spelling, and the only one [`parse`] accepts back. |
| 812 | - /// always comes before shift, so a chord round-trips through one spelling | ||
| 813 | - /// and not two. | ||
| 814 | fn text(&self) -> String { | 840 | fn text(&self) -> String { |
| 815 | - match (self.ctrl, self.shift) { | 841 | + if self.ctrl { |
| 816 | - (true, true) => format!("ctrl+shift+{}", self.key), | 842 | + format!("ctrl+{}", self.key) |
| 817 | - (true, false) => format!("ctrl+{}", self.key), | 843 | + } else { |
| 818 | - (false, true) => format!("shift+{}", self.key), | 844 | + self.key.clone() |
| 819 | - (false, false) => self.key.clone(), | ||
| 820 | } | 845 | } |
| 821 | } | 846 | } |
| 822 | 847 | ||
| @@ -830,11 +855,10 @@ impl Chord { | |||
| 830 | } else { | 855 | } else { |
| 831 | &self.key | 856 | &self.key |
| 832 | }; | 857 | }; |
| 833 | - match (self.ctrl, self.shift) { | 858 | + if self.ctrl { |
| 834 | - (true, true) => format!("ctrl+shift+{key}"), | 859 | + format!("ctrl+{key}") |
| 835 | - (true, false) => format!("ctrl+{key}"), | 860 | + } else { |
| 836 | - (false, true) => format!("shift+{key}"), | 861 | + key.to_string() |
| 837 | - (false, false) => key.to_string(), | ||
| 838 | } | 862 | } |
| 839 | } | 863 | } |
| 840 | 864 | ||
| @@ -848,19 +872,15 @@ impl Chord { | |||
| 848 | Chord::parse(&self.text(), 0).is_ok_and(|round_trip| round_trip == *self) | 872 | Chord::parse(&self.text(), 0).is_ok_and(|round_trip| round_trip == *self) |
| 849 | } | 873 | } |
| 850 | 874 | ||
| 851 | - /// Strict: exactly one optional `ctrl+`, then one optional `shift+`, then | 875 | + /// Strict: exactly one optional `ctrl+`, then a key gpui could have |
| 852 | - /// a key gpui could have reported. A spelling this cannot emit back | 876 | + /// reported. A spelling this cannot emit back unchanged is refused |
| 853 | - /// unchanged is refused rather than normalised, because the round-trip is | 877 | + /// rather than normalised, because the round-trip is what makes the file |
| 854 | - /// what makes the file editable by hand at all. | 878 | + /// editable by hand at all. |
| 855 | fn parse(text: &str, n: usize) -> Result<Self, String> { | 879 | fn parse(text: &str, n: usize) -> Result<Self, String> { |
| 856 | - let (ctrl, rest) = match text.strip_prefix("ctrl+") { | 880 | + let (ctrl, key) = match text.strip_prefix("ctrl+") { |
| 857 | Some(rest) => (true, rest), | 881 | Some(rest) => (true, rest), |
| 858 | None => (false, text), | 882 | None => (false, text), |
| 859 | }; | 883 | }; |
| 860 | - let (shift, key) = match rest.strip_prefix("shift+") { | ||
| 861 | - Some(key) => (true, key), | ||
| 862 | - None => (false, rest), | ||
| 863 | - }; | ||
| 864 | if key.is_empty() | 884 | if key.is_empty() |
| 865 | || key.contains(' ') | 885 | || key.contains(' ') |
| 866 | || key.contains('+') | 886 | || key.contains('+') |
| @@ -871,7 +891,6 @@ impl Chord { | |||
| 871 | Ok(Chord { | 891 | Ok(Chord { |
| 872 | key: key.to_string(), | 892 | key: key.to_string(), |
| 873 | ctrl, | 893 | ctrl, |
| 874 | - shift, | ||
| 875 | }) | 894 | }) |
| 876 | } | 895 | } |
| 877 | } | 896 | } |
| @@ -901,15 +920,6 @@ impl Keymap { | |||
| 901 | chord: Chord { | 920 | chord: Chord { |
| 902 | key: key.to_string(), | 921 | key: key.to_string(), |
| 903 | ctrl, | 922 | ctrl, |
| 904 | - shift: false, | ||
| 905 | - }, | ||
| 906 | - }; | ||
| 907 | - let bshift = |action, key: &str| Binding { | ||
| 908 | - action, | ||
| 909 | - chord: Chord { | ||
| 910 | - key: key.to_string(), | ||
| 911 | - ctrl: false, | ||
| 912 | - shift: true, | ||
| 913 | }, | 923 | }, |
| 914 | }; | 924 | }; |
| 915 | Keymap { | 925 | Keymap { |
| @@ -938,11 +948,17 @@ impl Keymap { | |||
| 938 | b(ActionId::PrevSyncPoint, "[", true), | 948 | b(ActionId::PrevSyncPoint, "[", true), |
| 939 | b(ActionId::NextSyncPoint, "]", true), | 949 | b(ActionId::NextSyncPoint, "]", true), |
| 940 | // The cut odometer (DESIGN.md §6): bare walks one cut, shift | 950 | // The cut odometer (DESIGN.md §6): bare walks one cut, shift |
| 941 | - // strides ten. Both were free. | 951 | + // strides ten. gpui 0.2.2 (linux/platform.rs:909-917) clears |
| 952 | + // the shift modifier for any single-char key whose upper and | ||
| 953 | + // lower case are the same -- every one of these symbols -- | ||
| 954 | + // so `shift+.` never arrives; what arrives instead is the | ||
| 955 | + // key the shifted stroke actually types, `>`/`<`. Bound | ||
| 956 | + // directly, on the same physical chord, since that is what | ||
| 957 | + // the platform hands the key handler. | ||
| 942 | b(ActionId::WalkCutNext, ".", false), | 958 | b(ActionId::WalkCutNext, ".", false), |
| 943 | - bshift(ActionId::WalkCutNext, "."), | ||
| 944 | b(ActionId::WalkCutPrev, ",", false), | 959 | b(ActionId::WalkCutPrev, ",", false), |
| 945 | - bshift(ActionId::WalkCutPrev, ","), | 960 | + b(ActionId::WalkCutNext10, ">", false), |
| 961 | + b(ActionId::WalkCutPrev10, "<", false), | ||
| 946 | // The mark pair, on the letters every editor already means them | 962 | // The mark pair, on the letters every editor already means them |
| 947 | // by: bare, since a mark is set as often as a step and nothing | 963 | // by: bare, since a mark is set as often as a step and nothing |
| 948 | // else in this table answers to either. | 964 | // else in this table answers to either. |
| @@ -968,16 +984,19 @@ impl Keymap { | |||
| 968 | b(ActionId::Detach, "d", false), | 984 | b(ActionId::Detach, "d", false), |
| 969 | b(ActionId::Group, "g", true), | 985 | b(ActionId::Group, "g", true), |
| 970 | // Selection without a pointer. Tab is what a keyboard already | 986 | // Selection without a pointer. Tab is what a keyboard already |
| 971 | - // means by "move on to the next thing", and the two brackets | 987 | + // means by "move on to the next thing", and the two braces |
| 972 | // are the pair either side of it in the lane -- shift+tab is | 988 | // are the pair either side of it in the lane -- shift+tab is |
| 973 | // the obvious partner and is unspellable here, since a chord | 989 | // the obvious partner and is unspellable here, since a chord |
| 974 | // carries only ctrl and `parse` refuses an uppercase key. Bare | 990 | // carries only ctrl and `parse` refuses an uppercase key. Bare |
| 975 | // brackets are DESIGN.md §6's own trim pair now, so selection | 991 | // brackets are DESIGN.md §6's own trim pair now, so selection |
| 976 | - // takes the shifted chord: same two keys, the modifier telling | 992 | + // takes the braces the shifted brackets actually type: same |
| 977 | - // "walk the lane" apart from "trim the cut". | 993 | + // two keys, telling "walk the lane" apart from "trim the cut". |
| 978 | b(ActionId::Select, "tab", false), | 994 | b(ActionId::Select, "tab", false), |
| 979 | - bshift(ActionId::SelectNext, "]"), | 995 | + // Same platform fact as the odometer above: shift+] never |
| 980 | - bshift(ActionId::SelectPrev, "["), | 996 | + // arrives as shift+], it arrives as the key `}` (and shift+[ |
| 997 | + // as `{`) -- bound on the literal the platform delivers. | ||
| 998 | + b(ActionId::SelectNext, "}", false), | ||
| 999 | + b(ActionId::SelectPrev, "{", false), | ||
| 981 | // Select-all, on the chord every editor and every text field | 1000 | // Select-all, on the chord every editor and every text field |
| 982 | // already means it by -- which is why the audio-lane removal | 1001 | // already means it by -- which is why the audio-lane removal |
| 983 | // below had to move off ctrl+a: a stroke that universal was | 1002 | // below had to move off ctrl+a: a stroke that universal was |
| @@ -1064,10 +1083,11 @@ impl Keymap { | |||
| 1064 | // (below) -- the same letter, the modifier telling them apart. | 1083 | // (below) -- the same letter, the modifier telling them apart. |
| 1065 | b(ActionId::Crossfade, "f", true), | 1084 | b(ActionId::Crossfade, "f", true), |
| 1066 | // DESIGN.md §6's own chords: bare `[` `]` are the no-aim trim | 1085 | // DESIGN.md §6's own chords: bare `[` `]` are the no-aim trim |
| 1067 | - // pair. SelectPrev/SelectNext moved to shift+[ shift+] above | 1086 | + // pair. SelectPrev/SelectNext moved to `{` `}` above to make |
| 1068 | - // to make room -- the bare bracket trims the subject cut, | 1087 | + // room -- the bare bracket trims the subject cut, the brace |
| 1069 | - // the shifted one walks the selection past it, so the family | 1088 | + // (what the shifted bracket actually types) walks the |
| 1070 | - // reads as one idea under one pair of keys. | 1089 | + // selection past it, so the family reads as one idea under |
| 1090 | + // one pair of keys. | ||
| 1071 | b(ActionId::TrimIn, "[", false), | 1091 | b(ActionId::TrimIn, "[", false), |
| 1072 | b(ActionId::TrimOut, "]", false), | 1092 | b(ActionId::TrimOut, "]", false), |
| 1073 | // Loop-trim (DESIGN.md §6, "the modernized Avid trim mode"): | 1093 | // Loop-trim (DESIGN.md §6, "the modernized Avid trim mode"): |
| @@ -1133,20 +1153,12 @@ impl Keymap { | |||
| 1133 | } | 1153 | } |
| 1134 | 1154 | ||
| 1135 | /// What a stroke means, if anything. `key` is gpui's key name and `ctrl` its | 1155 | /// What a stroke means, if anything. `key` is gpui's key name and `ctrl` its |
| 1136 | - /// control modifier -- the pair the key handler already matches on. | 1156 | + /// control modifier -- the pair the key handler already matches on. There |
| 1157 | + /// is no shift parameter: see [`Chord`]'s own doc for why. | ||
| 1137 | pub fn lookup(&self, key: &str, ctrl: bool) -> Option<ActionId> { | 1158 | pub fn lookup(&self, key: &str, ctrl: bool) -> Option<ActionId> { |
| 1138 | - self.lookup_shifted(key, ctrl, false) | ||
| 1139 | - } | ||
| 1140 | - | ||
| 1141 | - /// [`Keymap::lookup`] plus the shift modifier, for a stroke like | ||
| 1142 | - /// `shift+.` (the cut odometer's stride-ten). The key handler does not | ||
| 1143 | - /// pass shift yet -- that is the dispatch task's wiring, not this one's -- | ||
| 1144 | - /// so every current caller goes through the two-argument [`Keymap::lookup`] | ||
| 1145 | - /// above and only ever reaches an unshifted chord. | ||
| 1146 | - pub fn lookup_shifted(&self, key: &str, ctrl: bool, shift: bool) -> Option<ActionId> { | ||
| 1147 | self.bindings | 1159 | self.bindings |
| 1148 | .iter() | 1160 | .iter() |
| 1149 | - .find(|b| b.chord.ctrl == ctrl && b.chord.shift == shift && b.chord.key == key) | 1161 | + .find(|b| b.chord.ctrl == ctrl && b.chord.key == key) |
| 1150 | .map(|b| b.action) | 1162 | .map(|b| b.action) |
| 1151 | } | 1163 | } |
| 1152 | 1164 | ||
| @@ -1386,7 +1398,6 @@ mod tests { | |||
| 1386 | Chord { | 1398 | Chord { |
| 1387 | key: key.to_string(), | 1399 | key: key.to_string(), |
| 1388 | ctrl, | 1400 | ctrl, |
| 1389 | - shift: false, | ||
| 1390 | } | 1401 | } |
| 1391 | } | 1402 | } |
| 1392 | 1403 | ||
| @@ -1402,18 +1413,13 @@ mod tests { | |||
| 1402 | fn every_default_stroke_reaches_its_action() { | 1413 | fn every_default_stroke_reaches_its_action() { |
| 1403 | let k = Keymap::defaults(); | 1414 | let k = Keymap::defaults(); |
| 1404 | assert_eq!(k.entries().len(), 71); | 1415 | assert_eq!(k.entries().len(), 71); |
| 1405 | - // The cut odometer: bare walks one, shift strides ten. | 1416 | + // The cut odometer: bare walks one, `<`/`>` (what shift+,/shift+. |
| 1417 | + // actually type) strides ten. | ||
| 1406 | assert_eq!(k.lookup(".", false), Some(ActionId::WalkCutNext)); | 1418 | assert_eq!(k.lookup(".", false), Some(ActionId::WalkCutNext)); |
| 1407 | assert_eq!(k.lookup(",", false), Some(ActionId::WalkCutPrev)); | 1419 | assert_eq!(k.lookup(",", false), Some(ActionId::WalkCutPrev)); |
| 1408 | assert_eq!(k.lookup("/", false), Some(ActionId::LoopTrim)); | 1420 | assert_eq!(k.lookup("/", false), Some(ActionId::LoopTrim)); |
| 1409 | - assert_eq!( | 1421 | + assert_eq!(k.lookup(">", false), Some(ActionId::WalkCutNext10)); |
| 1410 | - k.lookup_shifted(".", false, true), | 1422 | + assert_eq!(k.lookup("<", false), Some(ActionId::WalkCutPrev10)); |
| 1411 | - Some(ActionId::WalkCutNext) | ||
| 1412 | - ); | ||
| 1413 | - assert_eq!( | ||
| 1414 | - k.lookup_shifted(",", false, true), | ||
| 1415 | - Some(ActionId::WalkCutPrev) | ||
| 1416 | - ); | ||
| 1417 | // The trim pair, on its designed bare brackets (DESIGN.md §6). | 1423 | // The trim pair, on its designed bare brackets (DESIGN.md §6). |
| 1418 | assert_eq!(k.lookup("[", false), Some(ActionId::TrimIn)); | 1424 | assert_eq!(k.lookup("[", false), Some(ActionId::TrimIn)); |
| 1419 | assert_eq!(k.lookup("]", false), Some(ActionId::TrimOut)); | 1425 | assert_eq!(k.lookup("]", false), Some(ActionId::TrimOut)); |
| @@ -1438,14 +1444,8 @@ mod tests { | |||
| 1438 | // the sync points a cut has to land on to be copied. | 1444 | // the sync points a cut has to land on to be copied. |
| 1439 | assert_eq!(k.lookup("[", true), Some(ActionId::PrevSyncPoint)); | 1445 | assert_eq!(k.lookup("[", true), Some(ActionId::PrevSyncPoint)); |
| 1440 | assert_eq!(k.lookup("]", true), Some(ActionId::NextSyncPoint)); | 1446 | assert_eq!(k.lookup("]", true), Some(ActionId::NextSyncPoint)); |
| 1441 | - assert_eq!( | 1447 | + assert_eq!(k.lookup("}", false), Some(ActionId::SelectNext)); |
| 1442 | - k.lookup_shifted("]", false, true), | 1448 | + assert_eq!(k.lookup("{", false), Some(ActionId::SelectPrev)); |
| 1443 | - Some(ActionId::SelectNext) | ||
| 1444 | - ); | ||
| 1445 | - assert_eq!( | ||
| 1446 | - k.lookup_shifted("[", false, true), | ||
| 1447 | - Some(ActionId::SelectPrev) | ||
| 1448 | - ); | ||
| 1449 | assert_eq!(k.lookup("i", false), Some(ActionId::SetIn)); | 1449 | assert_eq!(k.lookup("i", false), Some(ActionId::SetIn)); |
| 1450 | assert_eq!(k.lookup("o", false), Some(ActionId::SetOut)); | 1450 | assert_eq!(k.lookup("o", false), Some(ActionId::SetOut)); |
| 1451 | assert_eq!(k.lookup("u", true), Some(ActionId::ClearRange)); | 1451 | assert_eq!(k.lookup("u", true), Some(ActionId::ClearRange)); |
| @@ -1460,14 +1460,8 @@ mod tests { | |||
| 1460 | assert_eq!(k.lookup("g", true), Some(ActionId::Group)); | 1460 | assert_eq!(k.lookup("g", true), Some(ActionId::Group)); |
| 1461 | // The keyboard's way onto a clip, and the pair that walks the lane. | 1461 | // The keyboard's way onto a clip, and the pair that walks the lane. |
| 1462 | assert_eq!(k.lookup("tab", false), Some(ActionId::Select)); | 1462 | assert_eq!(k.lookup("tab", false), Some(ActionId::Select)); |
| 1463 | - assert_eq!( | 1463 | + assert_eq!(k.lookup("}", false), Some(ActionId::SelectNext)); |
| 1464 | - k.lookup_shifted("]", false, true), | 1464 | + assert_eq!(k.lookup("{", false), Some(ActionId::SelectPrev)); |
| 1465 | - Some(ActionId::SelectNext) | ||
| 1466 | - ); | ||
| 1467 | - assert_eq!( | ||
| 1468 | - k.lookup_shifted("[", false, true), | ||
| 1469 | - Some(ActionId::SelectPrev) | ||
| 1470 | - ); | ||
| 1471 | assert_eq!(k.lookup("x", false), Some(ActionId::Delete)); | 1465 | assert_eq!(k.lookup("x", false), Some(ActionId::Delete)); |
| 1472 | assert_eq!(k.lookup("delete", false), Some(ActionId::Delete)); | 1466 | assert_eq!(k.lookup("delete", false), Some(ActionId::Delete)); |
| 1473 | assert_eq!(k.lookup("l", false), Some(ActionId::Lift)); | 1467 | assert_eq!(k.lookup("l", false), Some(ActionId::Lift)); |
| @@ -1675,16 +1669,20 @@ mod tests { | |||
| 1675 | assert_eq!(k.display(ActionId::Undo), "ctrl+z"); | 1669 | assert_eq!(k.display(ActionId::Undo), "ctrl+z"); |
| 1676 | assert_eq!(k.lookup("z", false), None); | 1670 | assert_eq!(k.lookup("z", false), None); |
| 1677 | // The action keeps its place in the display order, and the file keeps | 1671 | // The action keeps its place in the display order, and the file keeps |
| 1678 | - // reading in that order too. Deduped, because WalkCutNext/WalkCutPrev | 1672 | + // reading in that order too. Deduped only for safety -- both actions |
| 1679 | - // still carry their own two default chords each (untouched by this | 1673 | + // this test rebinds (Delete and Undo) started with two default |
| 1680 | - // test's rebinds) and so appear twice running. | 1674 | + // chords each, but both rebinds above collapse them to one, so no |
| 1675 | + // action here still appears twice. | ||
| 1681 | let mut order: Vec<_> = k.entries().iter().map(|b| b.action).collect(); | 1676 | let mut order: Vec<_> = k.entries().iter().map(|b| b.action).collect(); |
| 1682 | order.dedup(); | 1677 | order.dedup(); |
| 1683 | assert_eq!(order, ActionId::ALL); | 1678 | assert_eq!(order, ActionId::ALL); |
| 1684 | assert_eq!(emit(&k), emit(&whole(&emit(&k)))); | 1679 | assert_eq!(emit(&k), emit(&whole(&emit(&k)))); |
| 1685 | - // Every action is single-bound except WalkCutNext/WalkCutPrev, still | 1680 | + // With Delete and Undo both collapsed to one chord, every action is |
| 1686 | - // two chords each -- one line per action, plus those two extras. | 1681 | + // single-bound: one line each. The stride-10 walk |
| 1687 | - assert_eq!(k.entries().len(), ActionId::ALL.len() + 2); | 1682 | + // (WalkCutNext10/WalkCutPrev10) is its own action now, each bound to |
| 1683 | + // exactly one literal chord (`>`/`<`), not a second chord on | ||
| 1684 | + // WalkCutNext/WalkCutPrev. | ||
| 1685 | + assert_eq!(k.entries().len(), ActionId::ALL.len()); | ||
| 1688 | } | 1686 | } |
| 1689 | 1687 | ||
| 1690 | #[test] | 1688 | #[test] |
crates/app/src/main.rsmodified+0 -8
| @@ -129,13 +129,6 @@ struct Player { | |||
| 129 | /// [`should_loop_restart`] with one field instead of asking whether the | 129 | /// [`should_loop_restart`] with one field instead of asking whether the |
| 130 | /// mode is on and then separately what the window is. | 130 | /// mode is on and then separately what the window is. |
| 131 | loop_trim: Option<(u32, u32)>, | 131 | loop_trim: Option<(u32, u32)>, |
| 132 | - /// Whether the stroke [`Player::act`] is running for was held with shift | ||
| 133 | - /// -- the odometer's stride (DESIGN.md §6: bare walks one cut, shift | ||
| 134 | - /// strides ten). Set by the key handler right before `act`, since | ||
| 135 | - /// [`ActionId`] carries no modifier of its own (`.` and `shift+.` are the | ||
| 136 | - /// same [`ActionId::WalkCutNext`], by design -- see keymap.rs's own | ||
| 137 | - /// `bshift`) and nothing else here reads it. | ||
| 138 | - walk_shift: bool, | ||
| 139 | /// Timeline seconds -> frame index, so the clock can be compared to what | 132 | /// Timeline seconds -> frame index, so the clock can be compared to what |
| 140 | /// the decoder hands over. | 133 | /// the decoder hands over. |
| 141 | fps: f64, | 134 | fps: f64, |
| @@ -829,7 +822,6 @@ fn main() { | |||
| 829 | loop_on: false, | 822 | loop_on: false, |
| 830 | range: None, | 823 | range: None, |
| 831 | loop_trim: None, | 824 | loop_trim: None, |
| 832 | - walk_shift: false, | ||
| 833 | // Full and unmuted, which is what the session it was just | 825 | // Full and unmuted, which is what the session it was just |
| 834 | // handed is already set to: nothing to push at startup. | 826 | // handed is already set to: nothing to push at startup. |
| 835 | volume: Volume::default(), | 827 | volume: Volume::default(), |
crates/app/src/oracle.rsmodified+2 -0
| @@ -263,6 +263,8 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { | |||
| 263 | // three above it refuse an empty mark. | 263 | // three above it refuse an empty mark. |
| 264 | ActionId::WalkCutNext | 264 | ActionId::WalkCutNext |
| 265 | | ActionId::WalkCutPrev | 265 | | ActionId::WalkCutPrev |
| 266 | + | ActionId::WalkCutNext10 | ||
| 267 | + | ActionId::WalkCutPrev10 | ||
| 266 | | ActionId::TrimIn | 268 | | ActionId::TrimIn |
| 267 | | ActionId::TrimOut | 269 | | ActionId::TrimOut |
| 268 | | ActionId::LoopTrim | 270 | | ActionId::LoopTrim |
crates/app/src/player/actions.rsmodified+15 -6
| @@ -168,6 +168,8 @@ impl Player { | |||
| 168 | // to read. | 168 | // to read. |
| 169 | ActionId::WalkCutNext => self.walk_cut(true, cx), | 169 | ActionId::WalkCutNext => self.walk_cut(true, cx), |
| 170 | ActionId::WalkCutPrev => self.walk_cut(false, cx), | 170 | ActionId::WalkCutPrev => self.walk_cut(false, cx), |
| 171 | + ActionId::WalkCutNext10 => self.walk_cut_stride(true, 10, cx), | ||
| 172 | + ActionId::WalkCutPrev10 => self.walk_cut_stride(false, 10, cx), | ||
| 171 | // `[` `]` close in on the clip like the brackets they are: `[` | 173 | // `[` `]` close in on the clip like the brackets they are: `[` |
| 172 | // trims a frame off the head, `]` a frame off the tail -- no-aim, | 174 | // trims a frame off the head, `]` a frame off the tail -- no-aim, |
| 173 | // frame detents, clamped to the room the engine already answers | 175 | // frame detents, clamped to the room the engine already answers |
| @@ -460,11 +462,20 @@ impl Player { | |||
| 460 | } | 462 | } |
| 461 | 463 | ||
| 462 | /// The odometer (DESIGN.md §6, `,` `.`): the subject cut steps to its | 464 | /// The odometer (DESIGN.md §6, `,` `.`): the subject cut steps to its |
| 463 | - /// neighbour along its own lane, [`walk_shift`](Player) striding ten | 465 | + /// neighbour along its own lane, one at a time, clamped rather than |
| 464 | - /// instead of one, clamped rather than wrapping at either end | 466 | + /// wrapping at either end ([`walk_cut`]). The playhead follows it there, |
| 465 | - /// ([`walk_cut`]). The playhead follows it there, which is what puts the | 467 | + /// which is what puts the screen at rest on the new cut for the two-up |
| 466 | - /// screen at rest on the new cut for the two-up to draw. | 468 | + /// to draw. |
| 467 | pub(crate) fn walk_cut(&mut self, forward: bool, cx: &mut Context<Self>) { | 469 | pub(crate) fn walk_cut(&mut self, forward: bool, cx: &mut Context<Self>) { |
| 470 | + self.walk_cut_stride(forward, 1, cx); | ||
| 471 | + } | ||
| 472 | + | ||
| 473 | + /// [`Player::walk_cut`] with an explicit stride -- ten for | ||
| 474 | + /// [`ActionId::WalkCutNext10`]/[`ActionId::WalkCutPrev10`], its own | ||
| 475 | + /// bound key (DESIGN.md §6's "shift") rather than a modifier read off | ||
| 476 | + /// the bare walk, since gpui never delivers shift alongside `.`/`,` | ||
| 477 | + /// (see [`crate::keymap::Chord`]'s doc). | ||
| 478 | + pub(crate) fn walk_cut_stride(&mut self, forward: bool, stride: usize, cx: &mut Context<Self>) { | ||
| 468 | let Some((lane, idx)) = self.selected.anchor() else { | 479 | let Some((lane, idx)) = self.selected.anchor() else { |
| 469 | return; | 480 | return; |
| 470 | }; | 481 | }; |
| @@ -472,7 +483,6 @@ impl Player { | |||
| 472 | return; | 483 | return; |
| 473 | }; | 484 | }; |
| 474 | let clips = session.lane_clips(lane); | 485 | let clips = session.lane_clips(lane); |
| 475 | - let stride = if self.walk_shift { 10 } else { 1 }; | ||
| 476 | let next = walk_cut(idx, clips.len(), forward, stride); | 486 | let next = walk_cut(idx, clips.len(), forward, stride); |
| 477 | let at = clips.get(next).map(|c| f64::from(c.start) / self.fps); | 487 | let at = clips.get(next).map(|c| f64::from(c.start) / self.fps); |
| 478 | self.select((lane, next), cx); | 488 | self.select((lane, next), cx); |
| @@ -578,7 +588,6 @@ impl Player { | |||
| 578 | let chord = keymap::Chord { | 588 | let chord = keymap::Chord { |
| 579 | key: key.to_string(), | 589 | key: key.to_string(), |
| 580 | ctrl, | 590 | ctrl, |
| 581 | - shift: false, | ||
| 582 | }; | 591 | }; |
| 583 | // Only a stroke the file can spell and read back as itself: gpui reports | 592 | // Only a stroke the file can spell and read back as itself: gpui reports |
| 584 | // "+" for shift+=, which is the chord grammar's separator, so binding it | 593 | // "+" for shift+=, which is the chord grammar's separator, so binding it |
crates/app/src/tests/layout.rsmodified+34 -0
| @@ -57,6 +57,40 @@ fn no_colour_is_written_outside_the_theme() { | |||
| 57 | assert!(stray.is_empty(), "colour written outside the theme: {stray:?}"); | 57 | assert!(stray.is_empty(), "colour written outside the theme: {stray:?}"); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | +/// The literal-grep above is blind to a hue arriving through a theme | ||
| 61 | +/// *constant*: `DARK_SEAM` carried `rgba(0,0,0,.7)` (`0xRRGGBBAA`) into | ||
| 62 | +/// `rgb()`, which reads the alpha byte as blue -- 2436 blue pixels in a | ||
| 63 | +/// darkroom screenshot, on a call site that never once wrote `0x` itself. | ||
| 64 | +/// So this scan reads the theme's own encoding: every constant whose low | ||
| 65 | +/// byte is not `ff` (i.e. `0xRRGGBBAA` with a real alpha) is alpha-carrying, | ||
| 66 | +/// and an alpha-carrying role may only ever be handed to `rgba(`, never | ||
| 67 | +/// `rgb(`. | ||
| 68 | +#[test] | ||
| 69 | +fn an_alpha_carrying_role_never_reaches_rgb() { | ||
| 70 | + let theme = src_text("ui/theme.rs"); | ||
| 71 | + let alpha_roles: Vec<&str> = theme | ||
| 72 | + .lines() | ||
| 73 | + .filter_map(|l| { | ||
| 74 | + let l = l.trim(); | ||
| 75 | + let l = l.strip_prefix("pub const ")?; | ||
| 76 | + let (name, rest) = l.split_once(':')?; | ||
| 77 | + let hex = rest.trim().strip_prefix("u32 = 0x")?; | ||
| 78 | + let hex = hex.trim_end_matches(';'); | ||
| 79 | + (hex.len() == 8 && !hex.ends_with("ff")).then_some(name.trim()) | ||
| 80 | + }) | ||
| 81 | + .collect(); | ||
| 82 | + assert!(alpha_roles.len() >= 8, "the theme's alpha-carrying roles moved; this scan is blind"); | ||
| 83 | + | ||
| 84 | + let source = ui_source(); | ||
| 85 | + let mut misuses = Vec::new(); | ||
| 86 | + for role in &alpha_roles { | ||
| 87 | + if source.contains(&format!("rgb({role}(")) { | ||
| 88 | + misuses.push(*role); | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + assert!(misuses.is_empty(), "alpha-carrying role(s) reaching rgb() instead of rgba(): {misuses:?}"); | ||
| 92 | +} | ||
| 93 | + | ||
| 60 | /// "It scrolls" is not "it can be found": at the 640x360 floor the timeline | 94 | /// "It scrolls" is not "it can be found": at the 640x360 floor the timeline |
| 61 | /// takes its share and no more, so a third track is behind a scroll -- and | 95 | /// takes its share and no more, so a third track is behind a scroll -- and |
| 62 | /// the line that says so has to keep telling the truth *while* the column is | 96 | /// the line that says so has to keep telling the truth *while* the column is |
crates/app/src/tests/view.rsmodified+0 -1
| @@ -410,7 +410,6 @@ fn no_stroke_is_missing_from_the_keys_menu() { | |||
| 410 | let pretty = keymap::Chord { | 410 | let pretty = keymap::Chord { |
| 411 | key: key.to_string(), | 411 | key: key.to_string(), |
| 412 | ctrl: false, | 412 | ctrl: false, |
| 413 | - shift: false, | ||
| 414 | } | 413 | } |
| 415 | .pretty(); | 414 | .pretty(); |
| 416 | keymap.lookup(key, false).is_some() || keymap::FIXED.iter().any(|f| f.chord == pretty) | 415 | keymap.lookup(key, false).is_some() || keymap::FIXED.iter().any(|f| f.chord == pretty) |
crates/app/src/ui/overlays.rsmodified+0 -1
| @@ -213,7 +213,6 @@ impl Player { | |||
| 213 | let out = keymap::Chord { | 213 | let out = keymap::Chord { |
| 214 | key: ESCAPE.to_string(), | 214 | key: ESCAPE.to_string(), |
| 215 | ctrl: false, | 215 | ctrl: false, |
| 216 | - shift: false, | ||
| 217 | } | 216 | } |
| 218 | .pretty(); | 217 | .pretty(); |
| 219 | // Every action there is, under its heading, and the strokes the modal | 218 | // Every action there is, under its heading, and the strokes the modal |
crates/app/src/ui/stance.rsmodified+33 -9
| @@ -69,7 +69,7 @@ fn spine(player: &Player) -> impl IntoElement { | |||
| 69 | .h_full() | 69 | .h_full() |
| 70 | .bg(rgb(DARK_PANEL())) | 70 | .bg(rgb(DARK_PANEL())) |
| 71 | .border_r_1() | 71 | .border_r_1() |
| 72 | - .border_color(rgb(DARK_SEAM())) | 72 | + .border_color(rgba(DARK_SEAM())) |
| 73 | .flex() | 73 | .flex() |
| 74 | .flex_col() | 74 | .flex_col() |
| 75 | .items_center() | 75 | .items_center() |
| @@ -127,7 +127,7 @@ fn time_band(player: &Player) -> impl IntoElement { | |||
| 127 | .h(px(TIME_BAND_H)) | 127 | .h(px(TIME_BAND_H)) |
| 128 | .bg(rgb(DARK_PANEL())) | 128 | .bg(rgb(DARK_PANEL())) |
| 129 | .border_t_1() | 129 | .border_t_1() |
| 130 | - .border_color(rgb(DARK_SEAM())) | 130 | + .border_color(rgba(DARK_SEAM())) |
| 131 | .flex() | 131 | .flex() |
| 132 | .items_center() | 132 | .items_center() |
| 133 | .gap(px(16.)) | 133 | .gap(px(16.)) |
| @@ -183,7 +183,7 @@ fn bench() -> impl IntoElement { | |||
| 183 | .rounded(px(0.)) | 183 | .rounded(px(0.)) |
| 184 | .bg(rgb(DARK_CANVAS())) | 184 | .bg(rgb(DARK_CANVAS())) |
| 185 | .border_t_1() | 185 | .border_t_1() |
| 186 | - .border_color(rgb(DARK_SEAM())) | 186 | + .border_color(rgba(DARK_SEAM())) |
| 187 | .flex() | 187 | .flex() |
| 188 | .items_center() | 188 | .items_center() |
| 189 | .px(px(12.)) | 189 | .px(px(12.)) |
| @@ -200,7 +200,7 @@ fn ledger() -> impl IntoElement { | |||
| 200 | .h(px(LEDGER_H)) | 200 | .h(px(LEDGER_H)) |
| 201 | .bg(rgb(DARK_PANEL())) | 201 | .bg(rgb(DARK_PANEL())) |
| 202 | .border_t_1() | 202 | .border_t_1() |
| 203 | - .border_color(rgb(DARK_SEAM())) | 203 | + .border_color(rgba(DARK_SEAM())) |
| 204 | .flex() | 204 | .flex() |
| 205 | .items_center() | 205 | .items_center() |
| 206 | .px(px(12.)) | 206 | .px(px(12.)) |
| @@ -219,7 +219,7 @@ fn dock(player: &Player, window_h: Pixels, cx: &mut Context<Player>) -> impl Int | |||
| 219 | .h_full() | 219 | .h_full() |
| 220 | .bg(rgb(DARK_PANEL())) | 220 | .bg(rgb(DARK_PANEL())) |
| 221 | .border_l_1() | 221 | .border_l_1() |
| 222 | - .border_color(rgb(DARK_SEAM())) | 222 | + .border_color(rgba(DARK_SEAM())) |
| 223 | .flex() | 223 | .flex() |
| 224 | .flex_col() | 224 | .flex_col() |
| 225 | .child(dock_stance::render(player, DOCK_W, window_h, cx)) | 225 | .child(dock_stance::render(player, DOCK_W, window_h, cx)) |
| @@ -228,9 +228,7 @@ fn dock(player: &Player, window_h: Pixels, cx: &mut Context<Player>) -> impl Int | |||
| 228 | /// The whole stance: spine, screen, time band, bench, ledger, dock, in the | 228 | /// The whole stance: spine, screen, time band, bench, ledger, dock, in the |
| 229 | /// order DESIGN §5 draws them, over the same key handler the legacy tree | 229 | /// order DESIGN §5 draws them, over the same key handler the legacy tree |
| 230 | /// uses (DESIGN §12 step 3): the darkroom draws its own regions but answers | 230 | /// uses (DESIGN §12 step 3): the darkroom draws its own regions but answers |
| 231 | -/// to the one keymap, `shift` threaded through for the odometer's stride | 231 | +/// to the one keymap. |
| 232 | -/// ([`Player::walk_shift`]) since [`ActionId`] carries no modifier of its | ||
| 233 | -/// own. | ||
| 234 | pub(crate) fn render( | 232 | pub(crate) fn render( |
| 235 | player: &mut Player, | 233 | player: &mut Player, |
| 236 | window: &mut Window, | 234 | window: &mut Window, |
| @@ -250,8 +248,34 @@ pub(crate) fn render( | |||
| 250 | if this.dismiss_notice() { | 248 | if this.dismiss_notice() { |
| 251 | cx.notify(); | 249 | cx.notify(); |
| 252 | } | 250 | } |
| 253 | - this.walk_shift = event.keystroke.modifiers.shift; | 251 | + // Same modal guard the legacy handler's rebinding/keys_open/ |
| 252 | + // export_open/exporting/colour/transform/speed/EQ/silence/mix/ | ||
| 253 | + // subtitle-style/menu chain (`render.rs`) amounts to, read as | ||
| 254 | + // one bool instead of re-copied field by field: while a card, a | ||
| 255 | + // rebind capture, or a menu owns the keyboard, the darkroom | ||
| 256 | + // stance yields to it exactly as the legacy tree does. This is | ||
| 257 | + // the fix for the stance's `Home`-inside-the-Colour-card | ||
| 258 | + // misfire. | ||
| 259 | + if this.rebinding.is_some() || this.overlaid() { | ||
| 260 | + // Escape is every card's own way out (`Player::close_card`, | ||
| 261 | + // the same list `overlaid`/`modal` read) -- blocking every | ||
| 262 | + // key while a card is open must not also lock the card open. | ||
| 263 | + if key == ESCAPE { | ||
| 264 | + this.rebinding = None; | ||
| 265 | + this.close_card(); | ||
| 266 | + } | ||
| 267 | + cx.notify(); | ||
| 268 | + return; | ||
| 269 | + } | ||
| 254 | if let Some(action) = this.keymap.lookup(key, ctrl) { | 270 | if let Some(action) = this.keymap.lookup(key, ctrl) { |
| 271 | + // hook: §12 step 7 -- the keys overlay and the export card | ||
| 272 | + // (and the notice plates that would announce an export's | ||
| 273 | + // progress) have no stance surface yet, so the two actions | ||
| 274 | + // that only ever show up there are suppressed here rather | ||
| 275 | + // than left to open a card nothing on screen can draw. | ||
| 276 | + if matches!(action, ActionId::ShowActions | ActionId::Export) { | ||
| 277 | + return; | ||
| 278 | + } | ||
| 255 | this.act(action, window, cx); | 279 | this.act(action, window, cx); |
| 256 | } | 280 | } |
| 257 | })) | 281 | })) |