fixed zoom and tree, + working with nix
This commit is contained in:
parent
716a5eb3fa
commit
f4a62c9c32
29
project/calcifer.nix
Normal file
29
project/calcifer.nix
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
|
|
||||||
|
pkgs.stdenv.mkDerivation rec {
|
||||||
|
pname = "Calcifer";
|
||||||
|
version = "1.0";
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "WanderingPenwing";
|
||||||
|
repo = "Calcifer";
|
||||||
|
rev = "v${version}";
|
||||||
|
sha256 = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
|
||||||
|
};
|
||||||
|
|
||||||
|
buildInputs = [ pkgs.rustc pkgs.cargo ];
|
||||||
|
|
||||||
|
nativeBuildInputs = [ pkgs.pkg-config ];
|
||||||
|
|
||||||
|
cargoSha256 = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
cargo install --path . --root $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with pkgs.stdenv.lib; {
|
||||||
|
description = "MyApp - A simple desktop application written in Rust";
|
||||||
|
homepage = "https://github.com/your-github-username/myapp";
|
||||||
|
license = licenses.mit;
|
||||||
|
maintainers = [ maintainers.your-name ];s
|
||||||
|
};
|
||||||
|
}
|
38
shell.nix
Normal file
38
shell.nix
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{ pkgs ? import <nixpkgs> { overlays = [ (import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz)) ]; },}:
|
||||||
|
with pkgs;
|
||||||
|
|
||||||
|
mkShell {
|
||||||
|
nativeBuildInputs = with xorg; [
|
||||||
|
libxcb
|
||||||
|
libXcursor
|
||||||
|
libXrandr
|
||||||
|
libXi
|
||||||
|
pkg-config
|
||||||
|
] ++ [
|
||||||
|
cargo
|
||||||
|
rustc
|
||||||
|
atk
|
||||||
|
gdk-pixbuf
|
||||||
|
webkitgtk
|
||||||
|
glib
|
||||||
|
libGL
|
||||||
|
libGLU
|
||||||
|
libxkbcommon
|
||||||
|
gtk3-x11
|
||||||
|
gnome.zenity
|
||||||
|
];
|
||||||
|
buildInputs = [
|
||||||
|
latest.rustChannels.stable.rust
|
||||||
|
xorg.libX11
|
||||||
|
wayland
|
||||||
|
libxkbcommon
|
||||||
|
python3Packages.virtualenv
|
||||||
|
python3Packages.plyer
|
||||||
|
python3Packages.pygobject3
|
||||||
|
python3Packages.pillow
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
export LD_LIBRARY_PATH=/run/opengl-driver/lib/:${lib.makeLibraryPath ([libGL libGLU libxkbcommon])}
|
||||||
|
'';
|
||||||
|
}
|
|
@ -74,6 +74,11 @@ impl Calcifer {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
println!("zoom : {}", app_state.zoom.clone());
|
||||||
|
if app_state.zoom != 0.0 {
|
||||||
|
new.zoom = app_state.zoom;
|
||||||
|
}
|
||||||
|
|
||||||
for path in app_state.tabs {
|
for path in app_state.tabs {
|
||||||
if !path
|
if !path
|
||||||
.file_name()
|
.file_name()
|
||||||
|
@ -104,6 +109,7 @@ impl Calcifer {
|
||||||
let app_state = core::AppState {
|
let app_state = core::AppState {
|
||||||
tabs: state_tabs,
|
tabs: state_tabs,
|
||||||
theme: state_theme,
|
theme: state_theme,
|
||||||
|
zoom: self.zoom,
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = core::save_state(&app_state, save_path().as_path());
|
let _ = core::save_state(&app_state, save_path().as_path());
|
||||||
|
|
|
@ -14,6 +14,7 @@ use serde::Deserialize;
|
||||||
pub struct AppState {
|
pub struct AppState {
|
||||||
pub tabs: Vec<PathBuf>,
|
pub tabs: Vec<PathBuf>,
|
||||||
pub theme: usize,
|
pub theme: usize,
|
||||||
|
pub zoom: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn save_state(state: &AppState, file_path: &Path) -> Result<(), std::io::Error> {
|
pub fn save_state(state: &AppState, file_path: &Path) -> Result<(), std::io::Error> {
|
||||||
|
|
|
@ -191,7 +191,7 @@ impl Calcifer {
|
||||||
core::hex_str_to_color(self.theme.bg),
|
core::hex_str_to_color(self.theme.bg),
|
||||||
);
|
);
|
||||||
StripBuilder::new(ui)
|
StripBuilder::new(ui)
|
||||||
.sizes(Size::remainder(), max(10, self.tabs.len() + 1))
|
.sizes(Size::remainder(), max(6, self.tabs.len() + 1))
|
||||||
.sense(egui::Sense::click())
|
.sense(egui::Sense::click())
|
||||||
.horizontal(|mut strip| {
|
.horizontal(|mut strip| {
|
||||||
for (index, tab) in self.tabs.clone().iter().enumerate() {
|
for (index, tab) in self.tabs.clone().iter().enumerate() {
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -17,7 +17,7 @@ const TITLE: &str = " debug";
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
const TITLE: &str = "";
|
const TITLE: &str = "";
|
||||||
|
|
||||||
const ALLOWED_FILE_EXTENSIONS: [&str; 13] = ["", "rs", "toml", "txt", "project", "sh", "md", "html", "js", "css", "php", "py", "kv"];
|
//const ALLOWED_FILE_EXTENSIONS: [&str; 14] = ["", "rs", "toml", "txt", "project", "sh", "md", "html", "js", "css", "php", "py", "kv", "nix"];
|
||||||
const PROJECT_EXTENSION: &str = "project";
|
const PROJECT_EXTENSION: &str = "project";
|
||||||
const TERMINAL_HEIGHT: f32 = 200.0;
|
const TERMINAL_HEIGHT: f32 = 200.0;
|
||||||
const TERMINAL_RANGE: Range<f32> = 100.0..600.0;
|
const TERMINAL_RANGE: Range<f32> = 100.0..600.0;
|
||||||
|
@ -25,6 +25,7 @@ const RED: egui::Color32 = egui::Color32::from_rgb(235, 108, 99);
|
||||||
const TIME_LABELS: [&str; 7] = [
|
const TIME_LABELS: [&str; 7] = [
|
||||||
"input", "settings", "tree", "terminal", "tabs", "content", "windows",
|
"input", "settings", "tree", "terminal", "tabs", "content", "windows",
|
||||||
];
|
];
|
||||||
|
const ZOOM_FACTOR: f32 = 1.1;
|
||||||
const MAX_FPS: f32 = 30.0;
|
const MAX_FPS: f32 = 30.0;
|
||||||
const DISPLAY_PATH_DEPTH: usize = 3;
|
const DISPLAY_PATH_DEPTH: usize = 3;
|
||||||
const MAX_PROJECT_COLUMNS: usize = 8;
|
const MAX_PROJECT_COLUMNS: usize = 8;
|
||||||
|
@ -67,6 +68,7 @@ struct Calcifer {
|
||||||
|
|
||||||
theme: editor::ColorTheme,
|
theme: editor::ColorTheme,
|
||||||
font_size: f32,
|
font_size: f32,
|
||||||
|
zoom: f32,
|
||||||
|
|
||||||
project_content: panels::Project,
|
project_content: panels::Project,
|
||||||
|
|
||||||
|
@ -104,6 +106,7 @@ impl Default for Calcifer {
|
||||||
|
|
||||||
theme: editor::themes::DEFAULT_THEMES[0],
|
theme: editor::themes::DEFAULT_THEMES[0],
|
||||||
font_size: 14.0,
|
font_size: 14.0,
|
||||||
|
zoom: 1.0,
|
||||||
|
|
||||||
project_content: panels::Project::new(),
|
project_content: panels::Project::new(),
|
||||||
|
|
||||||
|
@ -166,6 +169,10 @@ impl eframe::App for Calcifer {
|
||||||
.into();
|
.into();
|
||||||
ctx.set_style(style);
|
ctx.set_style(style);
|
||||||
|
|
||||||
|
if ctx.zoom_factor() != self.zoom {
|
||||||
|
ctx.set_zoom_factor(self.zoom);
|
||||||
|
}
|
||||||
|
|
||||||
if ctx.input(|i| i.key_pressed(egui::Key::R) && i.modifiers.ctrl)
|
if ctx.input(|i| i.key_pressed(egui::Key::R) && i.modifiers.ctrl)
|
||||||
&& !self.refresh_confirm.visible
|
&& !self.refresh_confirm.visible
|
||||||
{
|
{
|
||||||
|
@ -204,11 +211,11 @@ impl eframe::App for Calcifer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.input(|i| i.zoom_delta() > 1.0) {
|
if ctx.input(|i| i.zoom_delta() > 1.0) {
|
||||||
self.font_size = (self.font_size * 1.1).min(30.0);
|
self.zoom = (self.zoom*ZOOM_FACTOR).min(10.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.input(|i| i.zoom_delta() < 1.0) {
|
if ctx.input(|i| i.zoom_delta() < 1.0) {
|
||||||
self.font_size = (self.font_size / 1.1).max(10.0);
|
self.zoom = (self.zoom/ZOOM_FACTOR).max(0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.input(|i| i.key_pressed(egui::Key::F) && i.modifiers.ctrl) {
|
if ctx.input(|i| i.key_pressed(egui::Key::F) && i.modifiers.ctrl) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::ALLOWED_FILE_EXTENSIONS;
|
//use crate::ALLOWED_FILE_EXTENSIONS;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct FileEntry {
|
pub struct FileEntry {
|
||||||
|
@ -118,10 +118,10 @@ fn generate_entry(path: &Path) -> Option<FileEntry> {
|
||||||
if file_name.to_string_lossy().starts_with('.') {
|
if file_name.to_string_lossy().starts_with('.') {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let extension = path.extension().and_then(|ext| ext.to_str());
|
// let extension = path.extension().and_then(|ext| ext.to_str());
|
||||||
if !ALLOWED_FILE_EXTENSIONS.contains(&extension.unwrap_or_default()) {
|
// if !ALLOWED_FILE_EXTENSIONS.contains(&extension.unwrap_or_default()) {
|
||||||
return None;
|
// return None;
|
||||||
}
|
// }
|
||||||
} else {
|
} else {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue