initial commit

This commit is contained in:
Charlie Root 2025-04-16 21:47:30 +02:00
commit c032629bae
7 changed files with 4253 additions and 0 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/.direnv
/target

4080
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

7
Cargo.toml Normal file
View file

@ -0,0 +1,7 @@
[package]
name = "todo"
version = "0.1.0"
edition = "2024"
[dependencies]
iced = "0.13.1"

43
flake.lock generated Normal file
View file

@ -0,0 +1,43 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1742889210,
"narHash": "sha256-hw63HnwnqU3ZQfsMclLhMvOezpM7RSB0dMAtD5/sOiw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "698214a32beb4f4c8e3942372c694f40848b360d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"systems": "systems"
}
},
"systems": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

53
flake.nix Normal file
View file

@ -0,0 +1,53 @@
{
description = "ralc, a rust calculator";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default-linux";
};
outputs = inputs: let
pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
eachSystem = inputs.nixpkgs.lib.genAttrs (import inputs.systems);
pkgsFor = inputs.nixpkgs.legacyPackages;
in {
packages = eachSystem (system: {
default = inputs.self.packages.${system}.ralc;
ralc = pkgsFor.${system}.callPackage ./nix/package.nix {};
});
devShells = eachSystem (system: {
default = pkgsFor.${system}.mkShell rec {
packages = builtins.attrValues {
inherit
(pkgsFor.${system})
cargo
rustc
rustfmt
bacon
;
inherit
(pkgsFor.${system}.rustPackages)
clippy
;
inherit
(pkgsFor.${system})
libxkbcommon
vulkan-loader
wayland
;
inherit
(pkgsFor.${system}.xorg)
libX11
libXcursor
libXrandr
libXi
libxcb
;
};
shellHook = ''
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${builtins.toString (pkgs.lib.makeLibraryPath packages)}";
'';
};
});
};
}

67
src/main.rs Normal file
View file

@ -0,0 +1,67 @@
// use iced::pure::Sandbox;
use iced::{
Element, Settings,
widget::{self, Column, Row, button, column, row, text},
};
#[derive(Debug, Clone, Copy)]
enum Message {
Increment,
Decrement,
}
#[derive(Default)]
struct Counter {
value: i64,
}
impl Counter {
fn new() -> Self {
Self { value: 0 }
}
fn update(&mut self, message: Message) {
match message {
Message::Increment => self.value += 1,
Message::Decrement => self.value -= 1,
}
}
fn view(&self) -> iced::Element<'_, Message> {
// let col = column![
// button("+").on_press(Message::Increment),
// text(self.value),
// text("This is a test"),
// button("-").on_press(Message::Decrement),
// ];
let bla = row![
button("+").on_press(Message::Increment),
text(self.value),
text("This is a test"),
button("-").on_press(Message::Decrement),
];
widget::container(bla)
.center_x(iced::Length::Fill)
.center_y(iced::Length::Fill)
.height(iced::Length::Fill)
.into()
}
}
#[test]
fn it_counts_properly() {
let mut counter = Counter { value: 0 };
counter.update(Message::Increment);
counter.update(Message::Increment);
counter.update(Message::Increment);
counter.update(Message::Decrement);
counter.update(Message::Increment);
assert_eq!(counter.value, 3)
}
fn main() -> Result<(), iced::Error> {
iced::application("Counter Example", Counter::update, Counter::view)
.run_with(|| (Counter::new(), iced::Task::none()))
}