resizable window; refresh rate lowered to 50Hz instead of highest possible to avoid railing a CPU core

type-render
korin 3 years ago
parent 32e9ccc97a
commit 9f3b0e01e7
  1. 4
      src/editor_render.rs
  2. 10
      src/main.rs

@ -8,8 +8,8 @@ use std::{fs::File, path::Path, io::Read};
use sdl2::rect::Point;
pub struct GlyphMetrics {
width: usize,
height: usize,
pub width: usize,
pub height: usize,
}
impl GlyphMetrics {

@ -1,7 +1,7 @@
extern crate sdl2;
use clipboard::{ClipboardProvider, ClipboardContext};
use sdl2::event::Event;
use sdl2::event::{Event, WindowEvent};
use sdl2::keyboard::Keycode;
use sdl2::pixels::Color;
use sdl2::rect::Point;
@ -27,6 +27,7 @@ pub fn main() -> Result<(), String> {
let window = video_subsys
.window("Rude", SCREEN_WIDTH, SCREEN_HEIGHT)
.position_centered()
.resizable()
.opengl()
.build()
.map_err(|e| e.to_string())?;
@ -77,6 +78,11 @@ pub fn main() -> Result<(), String> {
// TODO: Make this completely user-configurable instead of hardcoded
for event in sdl_context.event_pump()?.poll_iter() {
match event {
Event::Window { win_event, .. } => {
if let WindowEvent::Resized(_w, _h) = win_event {
draw_text(&buffer, cursor_position)?
}
}
// ESC or SIGKILL
Event::KeyDown { keycode: Some(Keycode::Escape), .. } |
Event::Quit { .. } => break 'mainloop,
@ -234,6 +240,8 @@ pub fn main() -> Result<(), String> {
_ => {}
}
}
::std::thread::sleep(std::time::Duration::new(0, 50_000_000));
}
format!("{selection_anchor:?}");
println!("{buffer}");

Loading…
Cancel
Save