WIP: parsing `pijul channels` text blob into individual components
Dependencies
- [2]
G2CHQAOPparsed `pijul log` text blob into individual entries & fields - [3]
NSE6BLWAinit slint project from https://github.com/slint-ui/slint-rust-template - [4]
4RPYR65Cconnect GUI to pijul to display simple channel list - [5]
IQY5LHENadd GUI element to display simple `pijul log` results - [*]
NCRTU7M4cargo init
Change contents
- edit in ui/app-window.slint at line 45
}}}component ChannelsList {in-out property <[string]> channels;in-out property <int> active;VerticalBox {alignment: start;spacing: 0;preferred-width: 150px;Text {text: "channels"; - edit in ui/app-window.slint at line 61
for ch in channels: Text {text: "\{ch}";} - replacement in ui/app-window.slint at line 69
in-out property <string> channel_list: "";in-out property <[string]> channels <=> chs.channels;in-out property <int> active-channel <=> chs.active; - edit in ui/app-window.slint at line 74
width: 600px;height: 400px; - replacement in ui/app-window.slint at line 87
VerticalBox {alignment: start;preferred-width: 150px;Text {text: "channels";}Text {text: "\{root.channel_list}";}chs := ChannelsList {channels: [];active: 0; - edit in ui/app-window.slint at line 93
preferred-width: 500px; - edit in ui/app-window.slint at line 96
preferred-width: 500px; - replacement in src/main.rs at line 33
ui.set_channel_list(SharedString::from(&channel_list));let channel_strs = channel_list.entries.into_iter().map(SharedString::from).collect::<Vec<_>>();ui.set_channels((&channel_strs[..]).into());ui.set_active_channel(i32::try_from(channel_list.active).unwrap_or(-1)); - replacement in src/cmds.rs at line 4
pub fn channel(exe: &std::path::Path, repo: &std::path::Path) -> Result<String, Error> {pub fn channel(exe: &std::path::Path, repo: &std::path::Path) -> Result<ChannelsList, Error> { - replacement in src/cmds.rs at line 13
Ok(String::from_utf8(output.stdout)?)parse_channel_output(output.stdout)}fn parse_channel_output(output: Vec<u8>) -> Result<ChannelsList, Error> {let channels_str = String::from_utf8(output)?;let channels_list = channels_str.split('\n').map(|substr| substr.trim()).fold(ChannelsList::new(),|mut channels_list, ch_str| {if ch_str.starts_with("* ") {channels_list.active = channels_list.entries.len();channels_list.entries.push(ch_str[2..].to_string());} else {channels_list.entries.push(ch_str.to_string());}channels_list},);Ok(channels_list) - edit in src/cmds.rs at line 64
}#[derive(Debug)]pub struct ChannelsList {pub(crate) entries: Vec<String>,pub(crate) active: usize, - edit in src/cmds.rs at line 72
impl ChannelsList {pub(crate) fn new() -> Self {Self {entries: Vec::new(),active: usize::MAX,}}}