Compare commits
2 Commits
8c4bdcbe64
...
4a7aa8d831
Author | SHA1 | Date | |
---|---|---|---|
4a7aa8d831 | |||
c4c8b8acc6 |
9
LICENSE.txt
Normal file
9
LICENSE.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 Mark Poliakov <mark@alnyan.me>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the " Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
userspace/Cargo.lock
generated
31
userspace/Cargo.lock
generated
@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "ec3672c180e71eeaaac3a541fbbc5f5ad4def8b747c595ad30d674e43049f7b0"
|
checksum = "ec3672c180e71eeaaac3a541fbbc5f5ad4def8b747c595ad30d674e43049f7b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ab_glyph_rasterizer",
|
"ab_glyph_rasterizer",
|
||||||
"owned_ttf_parser",
|
"owned_ttf_parser 0.25.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1818,13 +1818,22 @@ dependencies = [
|
|||||||
"libredox",
|
"libredox",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "owned_ttf_parser"
|
||||||
|
version = "0.15.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "05e6affeb1632d6ff6a23d2cd40ffed138e82f1532571a26f527c8a284bb2fbb"
|
||||||
|
dependencies = [
|
||||||
|
"ttf-parser 0.15.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "owned_ttf_parser"
|
name = "owned_ttf_parser"
|
||||||
version = "0.25.0"
|
version = "0.25.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "22ec719bbf3b2a81c109a4e20b1f129b5566b7dce654bc3872f6a05abf82b2c4"
|
checksum = "22ec719bbf3b2a81c109a4e20b1f129b5566b7dce654bc3872f6a05abf82b2c4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ttf-parser",
|
"ttf-parser 0.25.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2312,6 +2321,16 @@ dependencies = [
|
|||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rusttype"
|
||||||
|
version = "0.9.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3ff8374aa04134254b7995b63ad3dc41c7f7236f69528b28553da7d72efaa967"
|
||||||
|
dependencies = [
|
||||||
|
"ab_glyph_rasterizer",
|
||||||
|
"owned_ttf_parser 0.15.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustversion"
|
name = "rustversion"
|
||||||
version = "1.0.19"
|
version = "1.0.19"
|
||||||
@ -2665,6 +2684,7 @@ dependencies = [
|
|||||||
"logsink",
|
"logsink",
|
||||||
"pci-ids",
|
"pci-ids",
|
||||||
"rand 0.9.0-alpha.1",
|
"rand 0.9.0-alpha.1",
|
||||||
|
"regex",
|
||||||
"runtime",
|
"runtime",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@ -2697,6 +2717,7 @@ dependencies = [
|
|||||||
"libpsf",
|
"libpsf",
|
||||||
"log",
|
"log",
|
||||||
"logsink",
|
"logsink",
|
||||||
|
"rusttype",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -2834,6 +2855,12 @@ version = "0.1.33"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
|
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ttf-parser"
|
||||||
|
version = "0.15.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7b3e06c9b9d80ed6b745c7159c40b311ad2916abb34a49e9be2653b90db0d8dd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ttf-parser"
|
name = "ttf-parser"
|
||||||
version = "0.25.1"
|
version = "0.25.1"
|
||||||
|
Binary file not shown.
50
userspace/etc/fonts/licenses.txt
Normal file
50
userspace/etc/fonts/licenses.txt
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
fixed-regular.ttf (Liberation Mono):
|
||||||
|
|
||||||
|
Digitized data copyright (c) 2010 Google Corporation
|
||||||
|
with Reserved Font Arimo, Tinos and Cousine.
|
||||||
|
Copyright (c) 2012 Red Hat, Inc.
|
||||||
|
with Reserved Font Name Liberation.
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
—————————————————————————————-
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
—————————————————————————————-
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
“Font Software” refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
“Reserved Font Name” refers to any names specified as such after the copyright statement(s).
|
||||||
|
|
||||||
|
“Original Version” refers to the collection of Font Software components as distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
“Modified Version” refers to any derivative made by adding to, deleting, or substituting—in part or in whole—any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
|
||||||
|
|
||||||
|
“Author” refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
|
|
||||||
|
regular.psfu: Linux default8x16.psfu
|
@ -12,3 +12,5 @@ logsink.workspace = true
|
|||||||
log.workspace = true
|
log.workspace = true
|
||||||
thiserror.workspace = true
|
thiserror.workspace = true
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
|
|
||||||
|
rusttype = "0.9.3"
|
||||||
|
@ -14,9 +14,9 @@ pub enum Color {
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct DisplayColor {
|
pub struct DisplayColor {
|
||||||
r: u8,
|
pub r: u8,
|
||||||
g: u8,
|
pub g: u8,
|
||||||
b: u8,
|
pub b: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
@ -4,4 +4,6 @@ pub enum Error {
|
|||||||
ApplicationError(#[from] libcolors::error::Error),
|
ApplicationError(#[from] libcolors::error::Error),
|
||||||
#[error("I/O error: {0}")]
|
#[error("I/O error: {0}")]
|
||||||
IoError(#[from] std::io::Error),
|
IoError(#[from] std::io::Error),
|
||||||
|
#[error("Font load error")]
|
||||||
|
FontLoadError,
|
||||||
}
|
}
|
||||||
|
70
userspace/term/src/font.rs
Normal file
70
userspace/term/src/font.rs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
use std::{fs, path::Path};
|
||||||
|
|
||||||
|
use crate::error::Error;
|
||||||
|
|
||||||
|
pub trait Font {
|
||||||
|
fn layout(&self) -> &FontLayout;
|
||||||
|
fn map_glyph<F: FnMut(usize, usize, f32)>(&mut self, ch: char, mapper: F);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct TrueTypeFont<'a> {
|
||||||
|
inner: rusttype::Font<'a>,
|
||||||
|
scale: rusttype::Scale,
|
||||||
|
layout: FontLayout,
|
||||||
|
ascent: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TrueTypeFont<'static> {
|
||||||
|
pub fn load<P: AsRef<Path>>(path: P, pixel_height: usize) -> Result<Self, Error> {
|
||||||
|
let font_data = fs::read(path)?;
|
||||||
|
let inner = rusttype::Font::try_from_vec(font_data).ok_or(Error::FontLoadError)?;
|
||||||
|
let unscaled_v_metrics = inner.v_metrics(rusttype::Scale::uniform(1.0f32));
|
||||||
|
let scale =
|
||||||
|
(pixel_height as f32) / (unscaled_v_metrics.ascent - unscaled_v_metrics.descent);
|
||||||
|
let scale = rusttype::Scale::uniform(scale);
|
||||||
|
let v_metrics = inner.v_metrics(scale);
|
||||||
|
let a_h_metrics = inner.glyph('a').scaled(scale).h_metrics();
|
||||||
|
let layout = FontLayout {
|
||||||
|
width: a_h_metrics.advance_width.ceil() as usize,
|
||||||
|
height: (v_metrics.ascent - v_metrics.descent).ceil() as usize,
|
||||||
|
};
|
||||||
|
let ascent = v_metrics.ascent;
|
||||||
|
Ok(Self {
|
||||||
|
inner,
|
||||||
|
scale,
|
||||||
|
layout,
|
||||||
|
ascent,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Font for TrueTypeFont<'_> {
|
||||||
|
fn layout(&self) -> &FontLayout {
|
||||||
|
&self.layout
|
||||||
|
}
|
||||||
|
|
||||||
|
fn map_glyph<F: FnMut(usize, usize, f32)>(&mut self, ch: char, mut mapper: F) {
|
||||||
|
let glyph = self
|
||||||
|
.inner
|
||||||
|
.glyph(ch)
|
||||||
|
.scaled(self.scale)
|
||||||
|
.positioned(rusttype::Point {
|
||||||
|
x: 0.0,
|
||||||
|
y: self.ascent,
|
||||||
|
});
|
||||||
|
|
||||||
|
if let Some(bb) = glyph.pixel_bounding_box() {
|
||||||
|
glyph.draw(|x, y, v| {
|
||||||
|
let x = (x as i32 + bb.min.x).clamp(0, self.layout.width as i32);
|
||||||
|
let y = (y as i32 + bb.min.y).clamp(0, self.layout.height as i32);
|
||||||
|
mapper(x as usize, y as usize, v);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct FontLayout {
|
||||||
|
pub width: usize,
|
||||||
|
pub height: usize,
|
||||||
|
}
|
@ -15,6 +15,7 @@ use std::{
|
|||||||
rt::io::device,
|
rt::io::device,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
path::PathBuf,
|
||||||
process::{Child, Command, ExitCode, Stdio},
|
process::{Child, Command, ExitCode, Stdio},
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
@ -22,29 +23,32 @@ use std::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use clap::Parser;
|
||||||
use error::Error;
|
use error::Error;
|
||||||
use libpsf::PcScreenFont;
|
use font::{Font, TrueTypeFont};
|
||||||
use libcolors::{
|
use libcolors::{
|
||||||
application::{
|
application::{
|
||||||
window::{EventOutcome, Window},
|
window::{EventOutcome, Window},
|
||||||
Application,
|
Application,
|
||||||
},
|
},
|
||||||
event::KeyModifiers, input::Key,
|
event::KeyModifiers,
|
||||||
|
input::Key,
|
||||||
};
|
};
|
||||||
use state::{Cursor, State};
|
use state::{Cursor, State};
|
||||||
|
|
||||||
pub mod attr;
|
pub mod attr;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
pub mod font;
|
||||||
pub mod state;
|
pub mod state;
|
||||||
|
|
||||||
struct DrawState {
|
struct DrawState<F: Font> {
|
||||||
width: usize,
|
width: usize,
|
||||||
force_redraw: bool,
|
force_redraw: bool,
|
||||||
focus_changed: bool,
|
focus_changed: bool,
|
||||||
focused: bool,
|
focused: bool,
|
||||||
old_cursor: Cursor,
|
old_cursor: Cursor,
|
||||||
|
|
||||||
font: PcScreenFont<'static>,
|
font: F,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Terminal<'a> {
|
pub struct Terminal<'a> {
|
||||||
@ -59,24 +63,24 @@ pub struct Terminal<'a> {
|
|||||||
shell: Child,
|
shell: Child,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DrawState {
|
impl<F: Font> DrawState<F> {
|
||||||
pub fn new(font: PcScreenFont<'static>, width: usize) -> Self {
|
pub fn new(font: F, width: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
width,
|
width,
|
||||||
|
font,
|
||||||
force_redraw: true,
|
force_redraw: true,
|
||||||
focus_changed: false,
|
focus_changed: false,
|
||||||
focused: true,
|
focused: true,
|
||||||
old_cursor: Cursor { row: 0, col: 0 },
|
old_cursor: Cursor { row: 0, col: 0 },
|
||||||
|
|
||||||
font,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw(&mut self, dt: &mut [u32], state: &mut State) {
|
pub fn draw(&mut self, dt: &mut [u32], state: &mut State) {
|
||||||
let default_fg = state.default_attributes.fg.to_display(false).to_u32();
|
let default_fg = state.default_attributes.fg.to_display(false).to_u32();
|
||||||
let default_bg = state.default_attributes.bg.to_display(false).to_u32();
|
let default_bg = state.default_attributes.bg.to_display(false).to_u32();
|
||||||
let fw = self.font.width() as usize;
|
let font_layout = self.font.layout();
|
||||||
let fh = self.font.height() as usize;
|
let fw = font_layout.width;
|
||||||
|
let fh = font_layout.height;
|
||||||
|
|
||||||
let cursor_dirty = self.old_cursor != state.cursor;
|
let cursor_dirty = self.old_cursor != state.cursor;
|
||||||
|
|
||||||
@ -95,7 +99,7 @@ impl DrawState {
|
|||||||
|
|
||||||
for (j, cell) in row.cells().enumerate() {
|
for (j, cell) in row.cells().enumerate() {
|
||||||
let bg = cell.attrs.bg.to_display(false).to_u32();
|
let bg = cell.attrs.bg.to_display(false).to_u32();
|
||||||
let fg = cell.attrs.fg.to_display(cell.attrs.bright).to_u32();
|
let fg = cell.attrs.fg.to_display(cell.attrs.bright);
|
||||||
|
|
||||||
let cx = j * fw;
|
let cx = j * fw;
|
||||||
|
|
||||||
@ -109,9 +113,14 @@ impl DrawState {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let c = cell.char as u32;
|
let c = cell.char as char;
|
||||||
self.font.map_glyph_pixels(c, |x, y, set| {
|
self.font.map_glyph(c, |x, y, v| {
|
||||||
let color = if set { fg } else { bg };
|
let v = (v * 2.0).min(1.0);
|
||||||
|
let r = fg.r as f32 * v;
|
||||||
|
let g = fg.g as f32 * v;
|
||||||
|
let b = fg.b as f32 * v;
|
||||||
|
let color = (b as u32) | ((g as u32) << 8) | ((r as u32) << 16) | 0xFF000000;
|
||||||
|
|
||||||
dt[(cy + y) * self.width + cx + x] = color;
|
dt[(cy + y) * self.width + cx + x] = color;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -145,7 +154,7 @@ impl DrawState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Terminal<'_> {
|
impl Terminal<'_> {
|
||||||
pub fn new(font: PcScreenFont<'static>) -> Result<Self, Error> {
|
pub fn new<F: Font + 'static>(font: F) -> Result<Self, Error> {
|
||||||
let mut app = Application::new()?;
|
let mut app = Application::new()?;
|
||||||
let mut window = Window::new(&app)?;
|
let mut window = Window::new(&app)?;
|
||||||
let mut poll = PollChannel::new()?;
|
let mut poll = PollChannel::new()?;
|
||||||
@ -153,8 +162,10 @@ impl Terminal<'_> {
|
|||||||
let width = window.width() as usize;
|
let width = window.width() as usize;
|
||||||
let height = window.height() as usize;
|
let height = window.height() as usize;
|
||||||
|
|
||||||
let rows = height / font.height() as usize;
|
let font_layout = font.layout();
|
||||||
let columns = width / font.width() as usize;
|
|
||||||
|
let rows = height / font_layout.height;
|
||||||
|
let columns = width / font_layout.width;
|
||||||
|
|
||||||
let termios = TerminalOptions::default();
|
let termios = TerminalOptions::default();
|
||||||
let (pty_master, pty_slave) = create_pty(Some(termios), TerminalSize { rows, columns })?;
|
let (pty_master, pty_slave) = create_pty(Some(termios), TerminalSize { rows, columns })?;
|
||||||
@ -175,8 +186,9 @@ impl Terminal<'_> {
|
|||||||
|
|
||||||
let width = width as usize;
|
let width = width as usize;
|
||||||
let height = height as usize;
|
let height = height as usize;
|
||||||
let rows = height / ds.font.height() as usize;
|
let font_layout = ds.font.layout();
|
||||||
let columns = width / ds.font.width() as usize;
|
let rows = height / font_layout.height;
|
||||||
|
let columns = width / font_layout.width;
|
||||||
|
|
||||||
let term_size = TerminalSize { rows, columns };
|
let term_size = TerminalSize { rows, columns };
|
||||||
let mut buffer = [0; 64];
|
let mut buffer = [0; 64];
|
||||||
@ -187,10 +199,7 @@ impl Terminal<'_> {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
s.resize(
|
s.resize(width / font_layout.width, height / font_layout.height);
|
||||||
width / ds.font.width() as usize,
|
|
||||||
height / ds.font.height() as usize,
|
|
||||||
);
|
|
||||||
ds.width = width;
|
ds.width = width;
|
||||||
ds.force_redraw = true;
|
ds.force_redraw = true;
|
||||||
|
|
||||||
@ -361,10 +370,36 @@ impl Terminal<'_> {
|
|||||||
|
|
||||||
static ABORT: AtomicBool = AtomicBool::new(false);
|
static ABORT: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
fn main() -> ExitCode {
|
#[derive(Debug, Parser)]
|
||||||
logsink::setup_logging(false);
|
struct Args {
|
||||||
let font = PcScreenFont::default();
|
#[clap(
|
||||||
let term = Terminal::new(font).unwrap();
|
long,
|
||||||
|
help = "TTF font to use",
|
||||||
term.run()
|
default_value = "/etc/fonts/fixed-regular.ttf"
|
||||||
|
)]
|
||||||
|
regular_font: PathBuf,
|
||||||
|
#[clap(
|
||||||
|
long,
|
||||||
|
help = "Font height in pixels (only for TTF fonts)",
|
||||||
|
default_value_t = 16
|
||||||
|
)]
|
||||||
|
font_size: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(args: &Args) -> Result<ExitCode, Error> {
|
||||||
|
let font = TrueTypeFont::load(&args.regular_font, args.font_size)?;
|
||||||
|
let term = Terminal::new(font)?;
|
||||||
|
Ok(term.run())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() -> ExitCode {
|
||||||
|
let args = Args::parse();
|
||||||
|
logsink::setup_logging(false);
|
||||||
|
match run(&args) {
|
||||||
|
Ok(code) => code,
|
||||||
|
Err(error) => {
|
||||||
|
log::error!("{error}");
|
||||||
|
ExitCode::FAILURE
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user