From d26fd24983970cf5ac4b747a832b4d0314d53092 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 10 Nov 2021 19:49:30 +0100 Subject: add GIO_CMAP wrapper We should be able to get the currently active palette. --- src/vtcol.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/vtcol.rs b/src/vtcol.rs index e1b4d6a..361b8fe 100644 --- a/src/vtcol.rs +++ b/src/vtcol.rs @@ -21,7 +21,9 @@ const RAW_COLEXPR_SIZE: usize = 6; // e. g. 0xBADF00 type RawPalette<'a> = [&'a str; PALETTE_SIZE]; +/* XXX: can we get these into ``libc``? */ const KDGKBTYPE: libc::c_int = 0x4b33; /* kd.h */ +const GIO_CMAP: libc::c_int = 0x00004B70; /* kd.h */ const PIO_CMAP: libc::c_int = 0x00004B71; /* kd.h */ const KB_101: libc::c_char = 0x0002; /* kd.h */ const O_NOCTTY: libc::c_int = 0o0400; /* fcntl.h */ @@ -609,6 +611,20 @@ fn ioctl_pio_cmap(fd: Fd, pal: &Palette) -> Result<()> } } +fn ioctl_gio_cmap(fd: Fd) -> Result +{ + let mut pal = Palette::new(); + + if unsafe { ioctl(fd, GIO_CMAP, std::mem::transmute(&mut pal)) } < 0 { + Err(anyhow!( + "ioctl(GIO_CMAP) failed to get current palette: {}", + Error::last_os_error() + )) + } else { + Ok(pal) + } +} + fn main() -> Result<()> { let job = Job::from_argv()?; -- cgit v1.2.3