kernel: Implement querying the terminal window size
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
78ea5dc352
commit
efd5bae7a5
@ -198,6 +198,13 @@ Result<u64> ConsoleDevice::ioctl(int request, void* arg)
|
|||||||
if (!MemoryManager::copy_to_user_typed((pid_t*)arg, &pgid)) return err(EFAULT);
|
if (!MemoryManager::copy_to_user_typed((pid_t*)arg, &pgid)) return err(EFAULT);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
case TIOCGWINSZ: {
|
||||||
|
struct winsize window;
|
||||||
|
window.ws_col = TextConsole::cols();
|
||||||
|
window.ws_row = TextConsole::rows();
|
||||||
|
if (!MemoryManager::copy_to_user_typed((struct winsize*)arg, &window)) return err(EFAULT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
default: return err(EINVAL);
|
default: return err(EINVAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,4 +207,14 @@ namespace TextConsole
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u16 rows()
|
||||||
|
{
|
||||||
|
return Framebuffer::height() / FONT_HEIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 cols()
|
||||||
|
{
|
||||||
|
return Framebuffer::width() / FONT_WIDTH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,4 +19,7 @@ namespace TextConsole
|
|||||||
Result<void> println(const char* str);
|
Result<void> println(const char* str);
|
||||||
void wprintln(const wchar_t* str);
|
void wprintln(const wchar_t* str);
|
||||||
Result<usize> printf(const char* format, ...) _format(1, 2);
|
Result<usize> printf(const char* format, ...) _format(1, 2);
|
||||||
|
|
||||||
|
u16 rows();
|
||||||
|
u16 cols();
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,14 @@ struct termios
|
|||||||
tcflag_t c_lflag;
|
tcflag_t c_lflag;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct winsize
|
||||||
|
{
|
||||||
|
u16 ws_row;
|
||||||
|
u16 ws_col;
|
||||||
|
u16 ws_xpixel;
|
||||||
|
u16 ws_ypixel;
|
||||||
|
};
|
||||||
|
|
||||||
// Values for c_lflag.
|
// Values for c_lflag.
|
||||||
#define ECHO 1
|
#define ECHO 1
|
||||||
#define TOSTOP 2
|
#define TOSTOP 2
|
||||||
@ -20,5 +28,6 @@ struct termios
|
|||||||
#define TCSETS 1
|
#define TCSETS 1
|
||||||
#define TIOCSPGRP 2
|
#define TIOCSPGRP 2
|
||||||
#define TIOCGPGRP 3
|
#define TIOCGPGRP 3
|
||||||
|
#define TIOCGWINSZ 4
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user