mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
Userland: Make man
provide a view_width
to `render_for_terminal()'
This makes tables actually show up when rendered through `man'
This commit is contained in:
parent
619cd613d0
commit
5b72d17ff6
Notes:
sideshowbarker
2024-07-19 01:48:31 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/5b72d17ff64 Pull-request: https://github.com/SerenityOS/serenity/pull/3814 Reviewed-by: https://github.com/bugaevc
1 changed files with 12 additions and 1 deletions
|
@ -30,10 +30,21 @@
|
|||
#include <LibCore/File.h>
|
||||
#include <LibMarkdown/Document.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int view_width = 0;
|
||||
if (isatty(STDOUT_FILENO)) {
|
||||
struct winsize ws;
|
||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0)
|
||||
view_width = ws.ws_col;
|
||||
}
|
||||
|
||||
if (view_width == 0)
|
||||
view_width = 80;
|
||||
|
||||
if (pledge("stdio rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
|
@ -104,6 +115,6 @@ int main(int argc, char* argv[])
|
|||
auto document = Markdown::Document::parse(source);
|
||||
ASSERT(document);
|
||||
|
||||
String rendered = document->render_for_terminal();
|
||||
String rendered = document->render_for_terminal(view_width);
|
||||
printf("%s", rendered.characters());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue