summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2021-11-10 19:49:30 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2021-11-10 18:45:44 +0100
commitd26fd24983970cf5ac4b747a832b4d0314d53092 (patch)
tree360f764545503aa1f3fc71e92cf1d5a5fc39562d
parentd8faf4a20465806f51834bd053bdb16385cf9bec (diff)
downloadvtcol-d26fd24983970cf5ac4b747a832b4d0314d53092.tar.gz
add GIO_CMAP wrapper
We should be able to get the currently active palette.
-rw-r--r--src/vtcol.rs16
1 files changed, 16 insertions, 0 deletions
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<Palette>
+{
+ 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()?;