Add term support #19

Merged
ThePerfectComputer merged 7 commits from add_term_support into main 2024-12-30 23:10:28 +00:00
3 changed files with 11 additions and 5 deletions
Showing only changes of commit 4fd4b6eb17 - Show all commits

View file

@ -72,7 +72,6 @@ fn send_char(
MartinKavik commented 2024-12-25 15:41:10 +00:00 (Migrated from github.com)
Review

please add more context so we both know what should be implemented here without trying to read all related code

please add more context so we both know what should be implemented here without trying to read all related code
MartinKavik commented 2024-12-25 15:55:51 +00:00 (Migrated from github.com)
Review

.chars basically brakes non-ASCII chars. It means when you try to format path like C:\nová složka\můj nový soubor (C:\new folder\my new file in Czech) then if fails. You should be able to use https://crates.io/crates/unicode-segmentation

(only applies if the term can be a user-defined text)

[.chars](https://doc.rust-lang.org/std/primitive.str.html#method.chars) basically brakes non-ASCII chars. It means when you try to format path like `C:\nová složka\můj nový soubor` (`C:\new folder\my new file` in Czech) then if fails. You should be able to use https://crates.io/crates/unicode-segmentation (only applies if the `term` can be a user-defined text)
MartinKavik commented 2024-12-25 16:12:03 +00:00 (Migrated from github.com)
Review

if .chars().count() is really what you want (see the previous review comment) then you can replace the if's body with something like:

return Some(process_for_ctrl_char(s[0], has_ctrl))
if `.chars().count()` is really what you want (see the previous review comment) then you can replace the `if`'s body with something like: ```rust return Some(process_for_ctrl_char(s[0], has_ctrl)) ```
MartinKavik commented 2024-12-25 16:18:54 +00:00 (Migrated from github.com)
Review

Perhaps you can use methods like is_ascii_alphabetic or is_ascii_lowercase or even is_ascii_control

Perhaps you can use methods like [is_ascii_alphabetic](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_alphabetic) or [is_ascii_lowercase](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_lowercase) or even [is_ascii_control](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_control)
ThePerfectComputer commented 2024-12-27 15:22:35 +00:00 (Migrated from github.com)
Review

Fully addressing NFC vs NFD unicode behavior will open a can of worms that is non-trivial to resolve. Hopefully, most users have keyboards that input a single unicode point instead of base followed by diacritic.

Fully addressing NFC vs NFD unicode behavior will open a can of worms that is non-trivial to resolve. Hopefully, most users have keyboards that input a single unicode point instead of base followed by diacritic.
MartinKavik commented 2024-12-25 15:41:10 +00:00 (Migrated from github.com)
Review

please add more context so we both know what should be implemented here without trying to read all related code

please add more context so we both know what should be implemented here without trying to read all related code
MartinKavik commented 2024-12-25 15:55:51 +00:00 (Migrated from github.com)
Review

.chars basically brakes non-ASCII chars. It means when you try to format path like C:\nová složka\můj nový soubor (C:\new folder\my new file in Czech) then if fails. You should be able to use https://crates.io/crates/unicode-segmentation

(only applies if the term can be a user-defined text)

[.chars](https://doc.rust-lang.org/std/primitive.str.html#method.chars) basically brakes non-ASCII chars. It means when you try to format path like `C:\nová složka\můj nový soubor` (`C:\new folder\my new file` in Czech) then if fails. You should be able to use https://crates.io/crates/unicode-segmentation (only applies if the `term` can be a user-defined text)
MartinKavik commented 2024-12-25 16:12:03 +00:00 (Migrated from github.com)
Review

if .chars().count() is really what you want (see the previous review comment) then you can replace the if's body with something like:

return Some(process_for_ctrl_char(s[0], has_ctrl))
if `.chars().count()` is really what you want (see the previous review comment) then you can replace the `if`'s body with something like: ```rust return Some(process_for_ctrl_char(s[0], has_ctrl)) ```
MartinKavik commented 2024-12-25 16:18:54 +00:00 (Migrated from github.com)
Review

Perhaps you can use methods like is_ascii_alphabetic or is_ascii_lowercase or even is_ascii_control

Perhaps you can use methods like [is_ascii_alphabetic](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_alphabetic) or [is_ascii_lowercase](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_lowercase) or even [is_ascii_control](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_control)
ThePerfectComputer commented 2024-12-27 15:22:35 +00:00 (Migrated from github.com)
Review

Fully addressing NFC vs NFD unicode behavior will open a can of worms that is non-trivial to resolve. Hopefully, most users have keyboards that input a single unicode point instead of base followed by diacritic.

Fully addressing NFC vs NFD unicode behavior will open a can of worms that is non-trivial to resolve. Hopefully, most users have keyboards that input a single unicode point instead of base followed by diacritic.
Task::start(async move {
println!("Sending char: {}", &c);
crate::platform::send_char(send_c.to_string()).await;
// crate::platform::unload_signal().await;
MartinKavik commented 2024-12-25 15:41:10 +00:00 (Migrated from github.com)
Review

please add more context so we both know what should be implemented here without trying to read all related code

please add more context so we both know what should be implemented here without trying to read all related code
MartinKavik commented 2024-12-25 15:55:51 +00:00 (Migrated from github.com)
Review

.chars basically brakes non-ASCII chars. It means when you try to format path like C:\nová složka\můj nový soubor (C:\new folder\my new file in Czech) then if fails. You should be able to use https://crates.io/crates/unicode-segmentation

(only applies if the term can be a user-defined text)

[.chars](https://doc.rust-lang.org/std/primitive.str.html#method.chars) basically brakes non-ASCII chars. It means when you try to format path like `C:\nová složka\můj nový soubor` (`C:\new folder\my new file` in Czech) then if fails. You should be able to use https://crates.io/crates/unicode-segmentation (only applies if the `term` can be a user-defined text)
MartinKavik commented 2024-12-25 16:12:03 +00:00 (Migrated from github.com)
Review

if .chars().count() is really what you want (see the previous review comment) then you can replace the if's body with something like:

return Some(process_for_ctrl_char(s[0], has_ctrl))
if `.chars().count()` is really what you want (see the previous review comment) then you can replace the `if`'s body with something like: ```rust return Some(process_for_ctrl_char(s[0], has_ctrl)) ```
MartinKavik commented 2024-12-25 16:18:54 +00:00 (Migrated from github.com)
Review

Perhaps you can use methods like is_ascii_alphabetic or is_ascii_lowercase or even is_ascii_control

Perhaps you can use methods like [is_ascii_alphabetic](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_alphabetic) or [is_ascii_lowercase](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_lowercase) or even [is_ascii_control](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_control)
ThePerfectComputer commented 2024-12-27 15:22:35 +00:00 (Migrated from github.com)
Review

Fully addressing NFC vs NFD unicode behavior will open a can of worms that is non-trivial to resolve. Hopefully, most users have keyboards that input a single unicode point instead of base followed by diacritic.

Fully addressing NFC vs NFD unicode behavior will open a can of worms that is non-trivial to resolve. Hopefully, most users have keyboards that input a single unicode point instead of base followed by diacritic.
println!("Sent char: {}", &c);
});
}

MartinKavik commented 2024-12-25 15:41:10 +00:00 (Migrated from github.com)
Review

please add more context so we both know what should be implemented here without trying to read all related code

please add more context so we both know what should be implemented here without trying to read all related code
MartinKavik commented 2024-12-25 15:55:51 +00:00 (Migrated from github.com)
Review

.chars basically brakes non-ASCII chars. It means when you try to format path like C:\nová složka\můj nový soubor (C:\new folder\my new file in Czech) then if fails. You should be able to use https://crates.io/crates/unicode-segmentation

(only applies if the term can be a user-defined text)

[.chars](https://doc.rust-lang.org/std/primitive.str.html#method.chars) basically brakes non-ASCII chars. It means when you try to format path like `C:\nová složka\můj nový soubor` (`C:\new folder\my new file` in Czech) then if fails. You should be able to use https://crates.io/crates/unicode-segmentation (only applies if the `term` can be a user-defined text)
MartinKavik commented 2024-12-25 16:12:03 +00:00 (Migrated from github.com)
Review

if .chars().count() is really what you want (see the previous review comment) then you can replace the if's body with something like:

return Some(process_for_ctrl_char(s[0], has_ctrl))
if `.chars().count()` is really what you want (see the previous review comment) then you can replace the `if`'s body with something like: ```rust return Some(process_for_ctrl_char(s[0], has_ctrl)) ```
MartinKavik commented 2024-12-25 16:18:54 +00:00 (Migrated from github.com)
Review

Perhaps you can use methods like is_ascii_alphabetic or is_ascii_lowercase or even is_ascii_control

Perhaps you can use methods like [is_ascii_alphabetic](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_alphabetic) or [is_ascii_lowercase](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_lowercase) or even [is_ascii_control](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_control)
ThePerfectComputer commented 2024-12-27 15:22:35 +00:00 (Migrated from github.com)
Review

Fully addressing NFC vs NFD unicode behavior will open a can of worms that is non-trivial to resolve. Hopefully, most users have keyboards that input a single unicode point instead of base followed by diacritic.

Fully addressing NFC vs NFD unicode behavior will open a can of worms that is non-trivial to resolve. Hopefully, most users have keyboards that input a single unicode point instead of base followed by diacritic.
MartinKavik commented 2024-12-25 15:41:10 +00:00 (Migrated from github.com)
Review

please add more context so we both know what should be implemented here without trying to read all related code

please add more context so we both know what should be implemented here without trying to read all related code
MartinKavik commented 2024-12-25 15:55:51 +00:00 (Migrated from github.com)
Review

.chars basically brakes non-ASCII chars. It means when you try to format path like C:\nová složka\můj nový soubor (C:\new folder\my new file in Czech) then if fails. You should be able to use https://crates.io/crates/unicode-segmentation

(only applies if the term can be a user-defined text)

[.chars](https://doc.rust-lang.org/std/primitive.str.html#method.chars) basically brakes non-ASCII chars. It means when you try to format path like `C:\nová složka\můj nový soubor` (`C:\new folder\my new file` in Czech) then if fails. You should be able to use https://crates.io/crates/unicode-segmentation (only applies if the `term` can be a user-defined text)
MartinKavik commented 2024-12-25 16:12:03 +00:00 (Migrated from github.com)
Review

if .chars().count() is really what you want (see the previous review comment) then you can replace the if's body with something like:

return Some(process_for_ctrl_char(s[0], has_ctrl))
if `.chars().count()` is really what you want (see the previous review comment) then you can replace the `if`'s body with something like: ```rust return Some(process_for_ctrl_char(s[0], has_ctrl)) ```
MartinKavik commented 2024-12-25 16:18:54 +00:00 (Migrated from github.com)
Review

Perhaps you can use methods like is_ascii_alphabetic or is_ascii_lowercase or even is_ascii_control

Perhaps you can use methods like [is_ascii_alphabetic](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_alphabetic) or [is_ascii_lowercase](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_lowercase) or even [is_ascii_control](https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii_control)
ThePerfectComputer commented 2024-12-27 15:22:35 +00:00 (Migrated from github.com)
Review

Fully addressing NFC vs NFD unicode behavior will open a can of worms that is non-trivial to resolve. Hopefully, most users have keyboards that input a single unicode point instead of base followed by diacritic.

Fully addressing NFC vs NFD unicode behavior will open a can of worms that is non-trivial to resolve. Hopefully, most users have keyboards that input a single unicode point instead of base followed by diacritic.

View file

@ -38,7 +38,7 @@ pub struct ATerm {
impl ATerm {
pub fn new() -> result::Result<ATerm, std::io::Error> {
let (rows, cols) = (21, 158);
let (rows, cols) = (21, 90);
let id = 1;
let pty_config = tty::Options {
shell: Some(tty::Shell::new("/bin/bash".to_string(), vec![])),

View file

@ -22,6 +22,7 @@ type RemovedDiagramConnectorsCount = usize;
type DiagramConnectorPath = String;
type DiagramConnectorName = String;
type ComponentId = String;
use alacritty_terminal::event::Notify;
mod component_manager;
mod aterm;
@ -154,9 +155,15 @@ async fn unload_signal(signal_ref_index: usize, store: tauri::State<'_, Store>)
}
#[tauri::command(rename_all = "snake_case")]
async fn send_char() -> Result<(), ()> {
println!("Sending char: {}", "a");
Ok(())
async fn send_char(c : String) -> Result<(), ()> {
// see if length of c is 1
if c.len() == 1 {
let term = TERM.lock().unwrap();
term.tx.notify(c.into_bytes());
Ok(())
} else {
Err(())
}
}
#[tauri::command(rename_all = "snake_case")]