Compare commits

..

No commits in common. "7ccc3b0e77071f8b6a13b4f3ac3daf12d02b3ad2" and "f07ce8a5dd132ea6291f94fa6817101af0edc179" have entirely different histories.

2 changed files with 7 additions and 13 deletions

View File

@ -8,7 +8,7 @@ license = "AGPL-3.0"
name = "annoying_journal" name = "annoying_journal"
readme = "README.md" readme = "README.md"
repository = "https://six-five-six-four.com/git/reactor/annoying_journal" repository = "https://six-five-six-four.com/git/reactor/annoying_journal"
version = "0.1.1" version = "0.1.0"
exclude = [ exclude = [
"COPYING", "COPYING",

View File

@ -3,7 +3,6 @@ use std::{
}; };
use chrono::{ use chrono::{
DateTime,
Local, Local,
SecondsFormat, SecondsFormat,
}; };
@ -124,12 +123,11 @@ enum Error {
#[derive (serde::Serialize)] #[derive (serde::Serialize)]
struct JournalLine { struct JournalLine {
text: String, text: String,
time_popped_up: Option <String>,
time_submitted: String, time_submitted: String,
} }
struct Gui { struct Gui {
time_popped_up: Option <DateTime <Local>>, armed: bool,
editor: text::TextEditor, editor: text::TextEditor,
wind: Window, wind: Window,
} }
@ -152,25 +150,23 @@ impl Gui {
let mut but = button::ReturnButton::new (640 - 100, 480 - 50, 100, 50, "Submit"); let mut but = button::ReturnButton::new (640 - 100, 480 - 50, 100, 50, "Submit");
but.emit (fltk_tx, Message::Submit); but.emit (fltk_tx, Message::Submit);
wind.set_label ("ANNOYING JOURNAL");
wind.end (); wind.end ();
wind.show (); wind.show ();
Self { Self {
time_popped_up: Some (Local::now ()), armed: true,
editor, editor,
wind, wind,
} }
} }
fn pop_up (&mut self) -> Result <(), Error> { fn pop_up (&mut self) -> Result <(), Error> {
if self.time_popped_up.is_some () { if ! self.armed {
eprintln! ("O4U6E36V Ignoring pop-up, already popped up"); eprintln! ("O4U6E36V Ignoring pop-up, not armed");
return Ok (()); return Ok (());
} }
self.time_popped_up = Some (Local::now ()); self.armed = false;
self.wind.set_label ("ANNOYING JOURNAL");
self.wind.show (); self.wind.show ();
self.editor.take_focus ()?; self.editor.take_focus ()?;
@ -185,7 +181,6 @@ impl Gui {
let jl = JournalLine { let jl = JournalLine {
text: buffer.text (), text: buffer.text (),
time_popped_up: self.time_popped_up.map (|x| x.to_rfc3339_opts (SecondsFormat::Secs, true)),
time_submitted: Local::now ().to_rfc3339_opts (SecondsFormat::Secs, true), time_submitted: Local::now ().to_rfc3339_opts (SecondsFormat::Secs, true),
}; };
@ -203,8 +198,7 @@ impl Gui {
println! ("{}", s); println! ("{}", s);
self.editor.set_buffer (text::TextBuffer::default ()); self.editor.set_buffer (text::TextBuffer::default ());
self.wind.iconize (); self.wind.iconize ();
self.time_popped_up = None; self.armed = true;
self.wind.set_label ("annoying journal");
Ok (()) Ok (())
} }