better last tab closing behaviour
This commit is contained in:
parent
f86a8ab094
commit
f9a712fea4
74
.github/workflows/release.yml
vendored
74
.github/workflows/release.yml
vendored
|
@ -1,74 +0,0 @@
|
|||
permissions:
|
||||
contents: write
|
||||
actions: read
|
||||
checks: write
|
||||
deployments: write
|
||||
issues: write
|
||||
packages: write
|
||||
pull-requests: write
|
||||
statuses: write
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: release ${{ matrix.target }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
# Temporarily disabling Windows compilation
|
||||
# - x86_64-pc-windows-gnu
|
||||
- x86_64-unknown-linux-musl
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Install musl-gcc
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y musl-tools
|
||||
|
||||
- name: Install target
|
||||
run: rustup target add ${{ matrix.target }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get update && sudo apt-get install -y libxkbcommon-x11-0 libglib2.0-dev libgl1-mesa-dev libglu1-mesa-dev libatk1.0-dev libgdk-pixbuf2.0-dev libwebkit2gtk-4.0-dev libgtk-3-dev
|
||||
|
||||
- name: Verify installed dependencies
|
||||
run: |
|
||||
ldconfig -p | grep xkbcommon
|
||||
ldconfig -p | grep libGL
|
||||
ldconfig -p | grep libGLU
|
||||
ldconfig -p | grep libatk-1.0.so.0
|
||||
ldconfig -p | grep libgdk_pixbuf-2.0.so.0
|
||||
ldconfig -p | grep libwebkit2gtk-4.0.so.37
|
||||
ldconfig -p | grep libgtk-3.so.0
|
||||
|
||||
- name: Compile the app
|
||||
run: |
|
||||
echo "Compiling for target: ${{ matrix.target }}"
|
||||
RUST_BACKTRACE=1 cargo build --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Create tarball
|
||||
run: |
|
||||
release_tag=${{ github.event.release.tag_name }}
|
||||
tar -czvf calcifer_auto_v${release_tag}.tar.gz -C target/${{ matrix.target }}/release calcifer
|
||||
|
||||
- name: Upload release assets
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_path: calcifer_auto_v${{ github.event.release.tag_name }}.tar.gz
|
||||
asset_name: calcifer_auto_v${{ github.event.release.tag_name }}.tar.gz
|
||||
asset_content_type: application/gzip
|
|
@ -1 +1 @@
|
|||
{"categories":[{"name":"to do","content":[{"name":"update workflow .yml","description":"make a workflow compiling the calcifer and put the linux in calcifer-{version}\nand the windows in calcifer_windows_{version}\n\nupdate nix\nupdate jiji","id":5},{"name":"repair build.rs","description":"// Hello there","id":1},{"name":"repair tinyfiledialog","description":"// Hello there","id":2}]},{"name":"in progress","content":[{"name":"export copy paste fix","description":"// Hello there","id":1}]},{"name":"done","content":[{"name":"move .project file","description":"// Hello there","id":4},{"name":"move config","description":"config from .calcifer/save.json\nto .config/calcifer/state.json","id":1},{"name":"add id to textarea per tab","description":"to improve undo, make each code area of each tab have a unique id (no more undo into another tab)","id":1},{"name":"file tree id ?","description":"// Hello there","id":1},{"name":"open dir in tree ?","description":"// Hello there","id":2},{"name":"fix tab title","description":"// Hello there","id":2}]},{"name":"+","content":[]}]}
|
||||
{"categories":[{"name":"to do","content":[{"name":"update workflow .yml","description":"make a workflow compiling the calcifer and put the linux in calcifer-{version}\nand the windows in calcifer_windows_{version}\n\nupdate nix\nupdate jiji","id":5},{"name":"repair build.rs","description":"// Hello there","id":1},{"name":"draggable tabs","description":"// Hello there","id":2}]},{"name":"in progress","content":[{"name":"export copy paste fix","description":"// Hello there","id":1}]},{"name":"done","content":[{"name":"move .project file","description":"// Hello there","id":4},{"name":"move config","description":"config from .calcifer/save.json\nto .config/calcifer/state.json","id":1},{"name":"add id to textarea per tab","description":"to improve undo, make each code area of each tab have a unique id (no more undo into another tab)","id":1},{"name":"file tree id ?","description":"// Hello there","id":1},{"name":"open dir in tree ?","description":"// Hello there","id":2},{"name":"fix tab title","description":"// Hello there","id":2},{"name":"when closing last tab","description":"close tab and THEN close calcifer (to save no tab in save.json)","id":1}]},{"name":"+","content":[]}]}
|
|
@ -155,7 +155,9 @@ impl Calcifer {
|
|||
|
||||
pub fn delete_tab(&mut self, index: usize) {
|
||||
self.tabs.remove(index);
|
||||
self.selected_tab = min(index, self.tabs.len() - 1);
|
||||
if self.tabs.len() != 0 {
|
||||
self.selected_tab = min(index, self.tabs.len() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toggle(&self, ui: &mut egui::Ui, display: bool, title: &str) -> bool {
|
||||
|
|
|
@ -28,16 +28,28 @@ impl Calcifer {
|
|||
}
|
||||
}
|
||||
ui.separator();
|
||||
|
||||
self.tree_visible = self.toggle(ui, self.tree_visible, "📦");
|
||||
ui.separator();
|
||||
self.terminal_visible = self.toggle(ui, self.terminal_visible, "🖵");
|
||||
|
||||
let toggle_terminal = self.toggle(ui, self.terminal_visible, "🖵");
|
||||
if toggle_terminal && !self.terminal_visible {
|
||||
let mut path = self.tabs[self.selected_tab].path.clone();
|
||||
path.pop();
|
||||
panels::send_command(format!("cd {}", path.display()));
|
||||
}
|
||||
self.terminal_visible = toggle_terminal;
|
||||
ui.separator();
|
||||
|
||||
self.search_menu.visible = self.toggle(ui, self.search_menu.visible, "🔍");
|
||||
ui.separator();
|
||||
|
||||
self.settings_menu.visible = self.toggle(ui, self.settings_menu.visible, "⚙");
|
||||
ui.separator();
|
||||
|
||||
self.shortcuts_menu.visible = self.toggle(ui, self.shortcuts_menu.visible, "⌨");
|
||||
ui.separator();
|
||||
|
||||
self.profiler_visible = self.toggle(ui, self.profiler_visible, "⚡");
|
||||
|
||||
if self.tabs[self.selected_tab].language == PROJECT_EXTENSION {
|
||||
|
@ -226,18 +238,11 @@ impl Calcifer {
|
|||
.clicked()
|
||||
&& !self.close_tab_confirm.visible
|
||||
{
|
||||
if self.tabs.len() > 1 {
|
||||
if tab.saved {
|
||||
self.delete_tab(index);
|
||||
} else {
|
||||
self.close_tab_confirm.ask();
|
||||
self.tab_to_close = index;
|
||||
}
|
||||
if tab.saved {
|
||||
self.delete_tab(index);
|
||||
} else {
|
||||
egui::Context::send_viewport_cmd(
|
||||
ctx,
|
||||
egui::ViewportCommand::Close,
|
||||
);
|
||||
self.close_tab_confirm.ask();
|
||||
self.tab_to_close = index;
|
||||
}
|
||||
}
|
||||
ui.with_layout(
|
||||
|
@ -268,7 +273,7 @@ impl Calcifer {
|
|||
}
|
||||
strip.cell(|ui| {
|
||||
if ui
|
||||
.add(egui::Label::new(" +").sense(egui::Sense::click()))
|
||||
.add(egui::Label::new(" ➕").sense(egui::Sense::click()))
|
||||
.clicked()
|
||||
{
|
||||
self.open_file(None);
|
||||
|
@ -280,20 +285,12 @@ impl Calcifer {
|
|||
|
||||
pub fn draw_content_panel(&mut self, ctx: &egui::Context) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
if self.selected_tab >= self.tabs.len() {
|
||||
return
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
if ui
|
||||
.add(egui::Button::new("open directory in terminal"))
|
||||
.clicked()
|
||||
{
|
||||
let mut path = self.tabs[self.selected_tab].path.clone();
|
||||
path.pop();
|
||||
panels::send_command(format!("cd {}", path.display()));
|
||||
}
|
||||
|
||||
if ui
|
||||
.add(egui::Button::new("expand tree"))
|
||||
.clicked()
|
||||
{
|
||||
ui.style_mut().visuals.hyperlink_color = core::hex_str_to_color(self.theme.comments);
|
||||
if ui.link(self.tabs[self.selected_tab].path.to_string_lossy().to_string()).clicked() {
|
||||
let mut current_path = self.tabs[self.selected_tab].path.clone();
|
||||
current_path.pop();
|
||||
|
||||
|
@ -308,14 +305,6 @@ impl Calcifer {
|
|||
self.tree_visible = true;
|
||||
self.file_tree = None;
|
||||
}
|
||||
|
||||
ui.label("Picked file:");
|
||||
ui.monospace(
|
||||
self.tabs[self.selected_tab]
|
||||
.path
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
);
|
||||
});
|
||||
|
||||
ui.separator();
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -25,7 +25,7 @@ const TERMINAL_HEIGHT: f32 = 200.0;
|
|||
const TERMINAL_RANGE: Range<f32> = 100.0..600.0;
|
||||
const RED: egui::Color32 = egui::Color32::from_rgb(235, 108, 99);
|
||||
const TIME_LABELS: [&str; 7] = [
|
||||
"input", "settings", "tree", "terminal", "tabs", "content", "windows",
|
||||
"input", "settings", "tree", "terminal+tray", "tabs", "content", "windows",
|
||||
];
|
||||
const ZOOM_FACTOR: f32 = 1.1;
|
||||
const MAX_FPS: f32 = 30.0;
|
||||
|
@ -266,6 +266,14 @@ impl eframe::App for Calcifer {
|
|||
self.exit_confirm.ask();
|
||||
}
|
||||
}
|
||||
|
||||
if self.tabs.len() == 0 {
|
||||
egui::Context::send_viewport_cmd(
|
||||
ctx,
|
||||
egui::ViewportCommand::Close,
|
||||
);
|
||||
return
|
||||
}
|
||||
|
||||
self.time_watch[0] = watch.elapsed().as_micros() as f32 / 1000.0;
|
||||
watch = time::Instant::now();
|
||||
|
|
Loading…
Reference in a new issue