FPS counter added
This commit is contained in:
@@ -39,6 +39,7 @@ pub fn render_ui(
|
||||
command_input: &str,
|
||||
command_mode: bool,
|
||||
command_message: &str,
|
||||
current_fps: f64,
|
||||
app_state: &AppState,
|
||||
) {
|
||||
render_background(f, f.area(), theme);
|
||||
@@ -175,6 +176,6 @@ pub fn render_ui(
|
||||
render_buffer_list(f, area, theme, buffer_state);
|
||||
}
|
||||
}
|
||||
render_status_line(f, status_line_area, current_dir, theme, is_edit_mode);
|
||||
render_status_line(f, status_line_area, current_dir, theme, is_edit_mode, current_fps);
|
||||
render_command_line(f, command_line_area, command_input, command_mode, theme, command_message);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ use crate::state::app::state::AppState;
|
||||
// Import SaveOutcome
|
||||
use crate::tui::terminal::{EventReader, TerminalCore};
|
||||
use crate::ui::handlers::render::render_ui;
|
||||
use std::time::Instant;
|
||||
use crossterm::cursor::SetCursorStyle;
|
||||
|
||||
pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -51,6 +52,10 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.await?;
|
||||
form_state.reset_to_empty();
|
||||
|
||||
// --- FPS Calculation State ---
|
||||
let mut last_frame_time = Instant::now();
|
||||
let mut current_fps = 0.0;
|
||||
|
||||
loop {
|
||||
// Determine edit mode based on EventHandler state
|
||||
let is_edit_mode = event_handler.is_edit_mode;
|
||||
@@ -92,6 +97,7 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
&event_handler.command_input,
|
||||
event_handler.command_mode,
|
||||
&event_handler.command_message,
|
||||
current_fps,
|
||||
&app_state,
|
||||
);
|
||||
})?;
|
||||
@@ -302,6 +308,14 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// terminal.cleanup()?; // Optional: Drop handles this
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// --- FPS Calculation ---
|
||||
let now = Instant::now();
|
||||
let frame_duration = now.duration_since(last_frame_time);
|
||||
last_frame_time = now;
|
||||
if frame_duration.as_secs_f64() > 1e-6 {
|
||||
current_fps = 1.0 / frame_duration.as_secs_f64();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user