WIP: even more crazy linux optimizations
Some checks failed
Deploy Website / deploy (push) Failing after 4m46s
Some checks failed
Deploy Website / deploy (push) Failing after 4m46s
This commit is contained in:
@@ -9,4 +9,4 @@ pub use types::{
|
|||||||
CcAccess, Dictionary, ExecutionTrace, Rng, SourceSpan, StepContext, Value, Variables,
|
CcAccess, Dictionary, ExecutionTrace, Rng, SourceSpan, StepContext, Value, Variables,
|
||||||
};
|
};
|
||||||
pub use vm::Forth;
|
pub use vm::Forth;
|
||||||
pub use words::{Word, WordCompile, WORDS};
|
pub use words::{lookup_word, Word, WordCompile, WORDS};
|
||||||
|
|||||||
@@ -2806,7 +2806,7 @@ static WORD_MAP: LazyLock<HashMap<&'static str, &'static Word>> = LazyLock::new(
|
|||||||
map
|
map
|
||||||
});
|
});
|
||||||
|
|
||||||
fn lookup_word(name: &str) -> Option<&'static Word> {
|
pub fn lookup_word(name: &str) -> Option<&'static Word> {
|
||||||
WORD_MAP.get(name).copied()
|
WORD_MAP.get(name).copied()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
18
src/main.rs
18
src/main.rs
@@ -329,14 +329,11 @@ fn main() -> io::Result<()> {
|
|||||||
app.flush_queued_changes(&sequencer.cmd_tx);
|
app.flush_queued_changes(&sequencer.cmd_tx);
|
||||||
app.flush_dirty_patterns(&sequencer.cmd_tx);
|
app.flush_dirty_patterns(&sequencer.cmd_tx);
|
||||||
|
|
||||||
if app.ui.show_title {
|
let had_event = event::poll(Duration::from_millis(
|
||||||
app.ui.sparkles.tick(terminal.get_frame().area());
|
|
||||||
}
|
|
||||||
terminal.draw(|frame| views::render(frame, &app, &link, &seq_snapshot))?;
|
|
||||||
|
|
||||||
if event::poll(Duration::from_millis(
|
|
||||||
app.audio.config.refresh_rate.millis(),
|
app.audio.config.refresh_rate.millis(),
|
||||||
))? {
|
))?;
|
||||||
|
|
||||||
|
if had_event {
|
||||||
match event::read()? {
|
match event::read()? {
|
||||||
Event::Key(key) => {
|
Event::Key(key) => {
|
||||||
let mut ctx = InputContext {
|
let mut ctx = InputContext {
|
||||||
@@ -362,6 +359,13 @@ fn main() -> io::Result<()> {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if app.playback.playing || had_event || app.ui.show_title {
|
||||||
|
if app.ui.show_title {
|
||||||
|
app.ui.sparkles.tick(terminal.get_frame().area());
|
||||||
|
}
|
||||||
|
terminal.draw(|frame| views::render(frame, &app, &link, &seq_snapshot))?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disable_raw_mode()?;
|
disable_raw_mode()?;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
mod script;
|
mod script;
|
||||||
|
|
||||||
pub use cagire_forth::{Word, WordCompile, WORDS};
|
pub use cagire_forth::{lookup_word, Word, WordCompile, WORDS};
|
||||||
pub use cagire_project::{
|
pub use cagire_project::{
|
||||||
load, save, Bank, LaunchQuantization, Pattern, PatternSpeed, Project, SyncMode, MAX_BANKS,
|
load, save, Bank, LaunchQuantization, Pattern, PatternSpeed, Project, SyncMode, MAX_BANKS,
|
||||||
MAX_PATTERNS,
|
MAX_PATTERNS,
|
||||||
|
|||||||
@@ -22,21 +22,25 @@ pub enum RefreshRate {
|
|||||||
#[default]
|
#[default]
|
||||||
Fps60,
|
Fps60,
|
||||||
Fps30,
|
Fps30,
|
||||||
|
Fps15,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RefreshRate {
|
impl RefreshRate {
|
||||||
pub fn from_fps(fps: u32) -> Self {
|
pub fn from_fps(fps: u32) -> Self {
|
||||||
if fps >= 60 {
|
if fps >= 60 {
|
||||||
RefreshRate::Fps60
|
RefreshRate::Fps60
|
||||||
} else {
|
} else if fps >= 30 {
|
||||||
RefreshRate::Fps30
|
RefreshRate::Fps30
|
||||||
|
} else {
|
||||||
|
RefreshRate::Fps15
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle(self) -> Self {
|
pub fn toggle(self) -> Self {
|
||||||
match self {
|
match self {
|
||||||
RefreshRate::Fps60 => RefreshRate::Fps30,
|
RefreshRate::Fps60 => RefreshRate::Fps30,
|
||||||
RefreshRate::Fps30 => RefreshRate::Fps60,
|
RefreshRate::Fps30 => RefreshRate::Fps15,
|
||||||
|
RefreshRate::Fps15 => RefreshRate::Fps60,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,6 +48,7 @@ impl RefreshRate {
|
|||||||
match self {
|
match self {
|
||||||
RefreshRate::Fps60 => 16,
|
RefreshRate::Fps60 => 16,
|
||||||
RefreshRate::Fps30 => 33,
|
RefreshRate::Fps30 => 33,
|
||||||
|
RefreshRate::Fps15 => 66,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +56,7 @@ impl RefreshRate {
|
|||||||
match self {
|
match self {
|
||||||
RefreshRate::Fps60 => "60",
|
RefreshRate::Fps60 => "60",
|
||||||
RefreshRate::Fps30 => "30",
|
RefreshRate::Fps30 => "30",
|
||||||
|
RefreshRate::Fps15 => "15",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +64,7 @@ impl RefreshRate {
|
|||||||
match self {
|
match self {
|
||||||
RefreshRate::Fps60 => 60,
|
RefreshRate::Fps60 => 60,
|
||||||
RefreshRate::Fps30 => 30,
|
RefreshRate::Fps30 => 30,
|
||||||
|
RefreshRate::Fps15 => 15,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use ratatui::style::{Modifier, Style};
|
use ratatui::style::{Modifier, Style};
|
||||||
|
|
||||||
use crate::model::{SourceSpan, WordCompile, WORDS};
|
use crate::model::{lookup_word, SourceSpan, WordCompile};
|
||||||
use crate::theme;
|
use crate::theme;
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
@@ -73,27 +73,23 @@ fn lookup_word_kind(word: &str) -> Option<(TokenKind, bool)> {
|
|||||||
return Some((TokenKind::Emit, true));
|
return Some((TokenKind::Emit, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
for w in WORDS {
|
let w = lookup_word(word)?;
|
||||||
if w.name == word || w.aliases.contains(&word) {
|
let kind = match &w.compile {
|
||||||
let kind = match &w.compile {
|
WordCompile::Param => TokenKind::Param,
|
||||||
WordCompile::Param => TokenKind::Param,
|
WordCompile::Context(_) => TokenKind::Context,
|
||||||
WordCompile::Context(_) => TokenKind::Context,
|
_ => match w.category {
|
||||||
_ => match w.category {
|
"Stack" => TokenKind::StackOp,
|
||||||
"Stack" => TokenKind::StackOp,
|
"Arithmetic" | "Comparison" | "Music" => TokenKind::Operator,
|
||||||
"Arithmetic" | "Comparison" | "Music" => TokenKind::Operator,
|
"Logic" if matches!(w.name, "and" | "or" | "not" | "xor" | "nand" | "nor") => {
|
||||||
"Logic" if matches!(w.name, "and" | "or" | "not" | "xor" | "nand" | "nor") => {
|
TokenKind::Operator
|
||||||
TokenKind::Operator
|
}
|
||||||
}
|
"Sound" => TokenKind::Sound,
|
||||||
"Sound" => TokenKind::Sound,
|
"Randomness" | "Probability" | "Selection" => TokenKind::Vary,
|
||||||
"Randomness" | "Probability" | "Selection" => TokenKind::Vary,
|
"Generator" => TokenKind::Generator,
|
||||||
"Generator" => TokenKind::Generator,
|
_ => TokenKind::Keyword,
|
||||||
_ => TokenKind::Keyword,
|
},
|
||||||
},
|
};
|
||||||
};
|
Some((kind, w.varargs))
|
||||||
return Some((kind, w.varargs));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_note(word: &str) -> bool {
|
fn is_note(word: &str) -> bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user