- got text boxes fully working
- this includes text wrapping not cutting words in half (can be disabled using a method on the text box) - refactored frame.rs, cg_core.rs and cg_widgets.rs to avoid code reuse and duplication - created a simplified unified interface for rendering frames to the screen using the Frame struct provided by frame.rs instead of Element, FrameGen, etc. - moved all widgets from cg_core.rs to cg_widgets.rs - the label widget now works - also added CgIndicatorBar and CgIndicatorWidget widgets to eventually make a working status bar - refactored all applications in the system to use the new api to render to the screen
This commit is contained in:
+27
-33
@@ -1,24 +1,22 @@
|
||||
use async_trait::async_trait;
|
||||
use lazy_static::lazy_static;
|
||||
use spin::Mutex;
|
||||
use x86_64::instructions::interrupts;
|
||||
|
||||
use alloc::{boxed::Box, string::{String, ToString}, vec, vec::Vec};
|
||||
use vga::writers::{GraphicsWriter, PrimitiveDrawing};
|
||||
|
||||
use crate::{print, printerr, println, serial_println, std, std::application::{Application, Error}, user::bin::*};
|
||||
use crate::kernel::render::ScreenChar;
|
||||
use crate::std::frame::ColouredElement;
|
||||
use crate::kernel::render::ColorCode;
|
||||
use crate::std::frame::{Dimensions, Position};
|
||||
use crate::std::io::{Color, write, Screen, Stdin, Serial};
|
||||
use crate::std::random::Random;
|
||||
use crate::user::bin::gigachad_detector::GigachadDetector;
|
||||
use crate::user::bin::grapher::Grapher;
|
||||
use crate::user::lib::libgui;
|
||||
use crate::user::lib::libgui::{
|
||||
cg_core::{Frame, Position, Dimensions, CgComponent},
|
||||
cg_core::{CgComponent},
|
||||
cg_widgets::{CgTextBox, CgContainer},
|
||||
};
|
||||
use crate::user::lib::libgui::cg_widgets::CgLabel;
|
||||
use crate::user::lib::libgui::cg_widgets::{CgIndicatorBar, CgIndicatorWidget, CgLabel};
|
||||
|
||||
lazy_static! {
|
||||
pub static ref CMD: Mutex<CommandHandler> = Mutex::new(CommandHandler::new());
|
||||
@@ -44,7 +42,7 @@ pub async fn eventloop() {
|
||||
CMD.lock().prompt();
|
||||
|
||||
loop {
|
||||
let string = crate::std::io::Stdin::readline().await;
|
||||
let string = Stdin::readline().await;
|
||||
CMD.lock().current.push_str(&string);
|
||||
match exec().await {
|
||||
Ok(_) => {
|
||||
@@ -187,53 +185,49 @@ async fn exec() -> Result<(), Error> {
|
||||
"test_features" => {
|
||||
std::io::Screen::application_mode();
|
||||
|
||||
serial_println!("OK");
|
||||
|
||||
let textbox = CgTextBox::new(
|
||||
String::from("i'd just like to interject for a moment"),
|
||||
String::from("I'd just like to interject for a moment. What you're refering to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called Linux, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project. There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux!"),
|
||||
Position::new(2, 2),
|
||||
Position::new(2, 5),
|
||||
Dimensions::new(40, 12),
|
||||
true,
|
||||
);
|
||||
|
||||
let textbox2 = CgTextBox::new(
|
||||
String::from("i'd just like to interject for a moment"),
|
||||
String::from("I'd just like to interject for a moment. What you're refering to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called Linux, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project. There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux!"),
|
||||
Position::new(10, 5),
|
||||
Dimensions::new(40, 12),
|
||||
true,
|
||||
let mut indicatorbar = CgIndicatorBar::new(
|
||||
Position::new(0, 0),
|
||||
80
|
||||
);
|
||||
|
||||
|
||||
let mut label = CgLabel::new(
|
||||
String::from("i'd just like to interject for a moment"),
|
||||
Position::new(5, 16),
|
||||
15,
|
||||
let mut w1 = CgIndicatorWidget::new(
|
||||
String::from("test"),
|
||||
5
|
||||
);
|
||||
|
||||
let mut w2 = CgIndicatorWidget::new(
|
||||
String::from("widget 2"),
|
||||
20
|
||||
);
|
||||
w2.set_colour(ColorCode::new(Color::Cyan, Color::Black));
|
||||
|
||||
indicatorbar.fields.push(w1);
|
||||
indicatorbar.fields.push(w2);
|
||||
|
||||
let mut container = CgContainer::new(
|
||||
Position::new(2, 2),
|
||||
Dimensions::new(65, 20),
|
||||
true,
|
||||
Position::new(0, 0),
|
||||
Dimensions::new(80, 25),
|
||||
false,
|
||||
);
|
||||
|
||||
container.elements.push(Box::new(textbox));
|
||||
container.elements.push(Box::new(textbox2));
|
||||
container.elements.push(Box::new(label));
|
||||
container.elements.push(Box::new(indicatorbar));
|
||||
|
||||
let res = if let Ok(frame) = container.render() {
|
||||
frame
|
||||
if let Ok(frame) = container.render() {
|
||||
frame.render_to_screen().unwrap();
|
||||
} else {
|
||||
return Err(Error::CommandFailed("failed to render frame".to_string()))
|
||||
};
|
||||
|
||||
let mut elem = ColouredElement::generate(
|
||||
res.render_screen_char(),
|
||||
(res.dimensions().x as u8, res.dimensions().y as u8),
|
||||
);
|
||||
|
||||
elem.render((0, 0)).unwrap();
|
||||
|
||||
//std::io::Screen::terminal_mode();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user