Skip to content

Commit

Permalink
feat: skip entry
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 54fd50ce1a02c37558ae4318c5e9af496a39e6a2
Author: terkwood <[email protected]>
Date:   Wed Jun 8 12:47:09 2022 -0400

    fmt

commit eeb58c1bb13405638c70e91c2e15bdf890a3ac83
Author: terkwood <[email protected]>
Date:   Wed Jun 8 12:47:04 2022 -0400

    skip

commit d772f3244d11d911b9205f6a1a0f7fe41e336395
Author: terkwood <[email protected]>
Date:   Wed Jun 8 12:37:55 2022 -0400

    feat: impl anything
  • Loading branch information
Terkwood committed Jun 8, 2022
1 parent 8a322e8 commit 4828d52
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zeditor"
version = "0.1.0-e"
version = "0.1.0-f"
edition = "2021"

[dependencies]
Expand Down
16 changes: 11 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() {

let fake_stuff = ListView::new().with_name("fake_stuff");

let buttons = Panel::new(
let perm_buttons = Panel::new(
LinearLayout::vertical()
.child(Button::new("Replace All", |s| bogus(s)))
.child(Button::new("Fake", |s| {
Expand All @@ -50,8 +50,8 @@ fn main() {
LinearLayout::horizontal()
.child(fake_stuff)
.child(DummyView)
.child(buttons), //.child(DummyView)
//.child(dead_example),
.child(perm_buttons), //.child(DummyView)
//.child(dead_example),
)
.title("zeditor"),
);
Expand All @@ -65,13 +65,13 @@ fn refresh_fake_list(siv: &mut Cursive) {
if let Some(mut fake_stuff) = siv.find_name::<ListView>("fake_stuff") {
let _ = siv.with_user_data(|blurbs: &mut Vec<ReplacementCandidate>| {
fake_stuff.clear();
for b in blurbs {
for (pos, b) in blurbs.iter().enumerate() {
let linear = LinearLayout::horizontal()
.child(TextView::new(b.preview_blurb.clone()))
.child(DummyView)
.child(Button::new("OK", bogus))
.child(DummyView)
.child(Button::new("Skip", bogus));
.child(Button::new("Skip", move |s| skip_candidate(s, pos)));

fake_stuff.add_child(&b.search, linear)
}
Expand All @@ -84,6 +84,12 @@ fn update_fake_db(siv: &mut Cursive, input: ReplacementCandidate) {
refresh_fake_list(siv);
}

fn skip_candidate(siv: &mut Cursive, user_data_pos: usize) {
siv.with_user_data(|blurbs: &mut Vec<ReplacementCandidate>| {
blurbs.remove(user_data_pos);
});
refresh_fake_list(siv);
}
fn bogus(_siv: &mut Cursive) {}

fn on_name_click(s: &mut Cursive, name: &str) {
Expand Down

0 comments on commit 4828d52

Please sign in to comment.