initial commit
This commit is contained in:
commit
4b7b02a3ae
4 changed files with 4174 additions and 0 deletions
76
src/main.rs
Normal file
76
src/main.rs
Normal file
|
@ -0,0 +1,76 @@
|
|||
use std::process::exit;
|
||||
|
||||
// This is very heavily based off the iced getting started thing
|
||||
// If you're reading this trying to learn how to use iced with this as an example, don't. Just read the docs.
|
||||
use iced::widget::{Column, button, column, text};
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref message_to_viewer: Vec<String> = vec![
|
||||
"Hey you. Click the button.".to_string(),
|
||||
"Good, I have your attention. Now...".to_string(),
|
||||
"*Why* would you possibly allow me to run arbitrary code on your computers.".to_string(),
|
||||
"Do you not see what an absurd security risk this is?".to_string(),
|
||||
"You'd better be running this in a VM with no internet connection or something.".to_string(),
|
||||
"Even if you were, I could spin something about it using a hosted instance of Postgres for your ease-of-use, and you might believe it.".to_string(),
|
||||
"Regardless, we should not, under any circumstances, be allowed to submit binaries for this assignment.".to_string(),
|
||||
"I could be stealing your browser cookies right now, it's not hard. Here's a small script that does exactly that: https://gist.github.com/mildsunrise/ac2bcb473c098a5dc3b2bdcc7b8eea51".to_string(),
|
||||
"(Decrypts your cookies, that is, it doesn't steal them.)".to_string(),
|
||||
"So please, for the love of god, don't let me run this program.".to_string(),
|
||||
"Anyways, if you want to take a look, its code is at https://git.askiiart.net/askiiart/this-program-shouldnt-need-to-exist".to_string()
|
||||
];
|
||||
}
|
||||
#[derive(Default)]
|
||||
struct TextDisplay {
|
||||
value: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Message {
|
||||
Increment,
|
||||
}
|
||||
|
||||
impl TextDisplay {
|
||||
pub fn view(&self) -> Column<Message> {
|
||||
// Creates a column containing these things
|
||||
column![
|
||||
// The next button. We tell it to produce an
|
||||
// `Increment` message when pressed
|
||||
button("Next").on_press(Message::Increment),
|
||||
// We show the text here
|
||||
text(self.value.clone()).size(50),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
impl TextDisplay {
|
||||
// ...
|
||||
|
||||
pub fn update(&mut self, message: Message) {
|
||||
match message {
|
||||
Message::Increment => {
|
||||
if let Some(pos) = message_to_viewer
|
||||
.iter()
|
||||
.position(|x| x == self.value.as_str())
|
||||
{
|
||||
if let Some(next_message) = message_to_viewer.get(pos + 1) {
|
||||
self.value = next_message.clone();
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
} else {
|
||||
// If the current value is not found, reset to the first message
|
||||
self.value = message_to_viewer[0].clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> iced::Result {
|
||||
iced::run(
|
||||
"A thingy (definitely won't steal your cookies)",
|
||||
TextDisplay::update,
|
||||
TextDisplay::view,
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue