Automatically get size of terminal
This commit is contained in:
parent
4943ddf955
commit
f804ad52e4
9
Makefile
9
Makefile
|
@ -64,6 +64,11 @@ else
|
|||
ifneq ($(kvm),no)
|
||||
QEMUFLAGS+=-enable-kvm -cpu host
|
||||
endif
|
||||
ifeq ($(storage),usb)
|
||||
QEMUFLAGS+=-device usb-ehci,id=flash_bus -drive id=flash_drive,file=$(KBUILD)/harddrive.bin,format=raw,if=none -device usb-storage,drive=flash_drive,bus=flash_bus.0
|
||||
else
|
||||
QEMUFLAGS+=-device ahci,id=ahci -drive id=disk,file=$(KBUILD)/harddrive.bin,format=raw,if=none -device ide-hd,drive=disk,bus=ahci.0
|
||||
endif
|
||||
ifeq ($(vga),no)
|
||||
QEMUFLAGS+=-nographic -vga none
|
||||
endif
|
||||
|
@ -82,10 +87,10 @@ $(KBUILD)/harddrive.bin: $(KBUILD)/kernel $(BUILD)/filesystem.bin bootloader/$(A
|
|||
nasm -f bin -o $@ -D ARCH_$(ARCH) -ibootloader/$(ARCH)/ bootloader/$(ARCH)/harddrive.asm
|
||||
|
||||
qemu: $(KBUILD)/harddrive.bin
|
||||
$(QEMU) $(QEMUFLAGS) -drive file=$<,format=raw,index=0,media=disk
|
||||
$(QEMU) $(QEMUFLAGS)
|
||||
|
||||
qemu_no_build:
|
||||
$(QEMU) $(QEMUFLAGS) -drive file=$(KBUILD)/harddrive.bin,format=raw,index=0,media=disk
|
||||
$(QEMU) $(QEMUFLAGS)
|
||||
endif
|
||||
|
||||
bochs: $(KBUILD)/harddrive.bin
|
||||
|
|
|
@ -113,6 +113,25 @@ impl Scheme for DisplayScheme {
|
|||
}
|
||||
}
|
||||
|
||||
fn fpath(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
let path_str = if id == 1 {
|
||||
format!("display:input")
|
||||
} else {
|
||||
let console = self.console.borrow();
|
||||
format!("display:{}/{}", console.w, console.h)
|
||||
};
|
||||
|
||||
let path = path_str.as_bytes();
|
||||
|
||||
let mut i = 0;
|
||||
while i < buf.len() && i < path.len() {
|
||||
buf[i] = path[i];
|
||||
i += 1;
|
||||
}
|
||||
|
||||
Ok(i)
|
||||
}
|
||||
|
||||
fn close(&self, _id: usize) -> Result<usize> {
|
||||
Ok(0)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use octavo::octavo_digest::sha3::Sha512;
|
|||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::process::Command;
|
||||
use std::{env, io, thread};
|
||||
use std::{env, io, str, thread};
|
||||
use termion::input::TermRead;
|
||||
|
||||
pub struct Passwd<'a> {
|
||||
|
@ -61,9 +61,17 @@ pub fn main() {
|
|||
|
||||
env::set_current_dir("file:").unwrap();
|
||||
|
||||
env::set_var("COLUMNS", "80");
|
||||
env::set_var("LINES", "30");
|
||||
env::set_var("TTY", &tty);
|
||||
{
|
||||
let mut path = [0; 4096];
|
||||
if let Ok(count) = syscall::fpath(0, &mut path) {
|
||||
let path_str = str::from_utf8(&path[..count]).unwrap_or("");
|
||||
let reference = path_str.split(':').nth(1).unwrap_or("");
|
||||
let mut parts = reference.split('/');
|
||||
env::set_var("COLUMNS", parts.next().unwrap_or("80"));
|
||||
env::set_var("LINES", parts.next().unwrap_or("30"));
|
||||
}
|
||||
}
|
||||
|
||||
thread::spawn(move || {
|
||||
let stdin = io::stdin();
|
||||
|
|
Loading…
Reference in a new issue