mirror of
https://github.com/leahneukirchen/mblaze
synced 2024-11-09 19:10:32 +00:00
mscan: use tty width
This commit is contained in:
parent
e709f6f588
commit
2c2be8bd37
19
mscan.c
19
mscan.c
@ -1,5 +1,6 @@
|
|||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
@ -15,7 +16,9 @@
|
|||||||
|
|
||||||
#include "blaze822.h"
|
#include "blaze822.h"
|
||||||
|
|
||||||
wchar_t replacement = '?';
|
static int cols;
|
||||||
|
static wchar_t replacement = L'?';
|
||||||
|
static char *cur;
|
||||||
|
|
||||||
void
|
void
|
||||||
u8putstr(FILE *out, char *s, size_t l, int pad)
|
u8putstr(FILE *out, char *s, size_t l, int pad)
|
||||||
@ -44,8 +47,6 @@ u8putstr(FILE *out, char *s, size_t l, int pad)
|
|||||||
putc(' ', out);
|
putc(' ', out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *cur;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
oneline(char *file)
|
oneline(char *file)
|
||||||
{
|
{
|
||||||
@ -62,7 +63,7 @@ oneline(char *file)
|
|||||||
|
|
||||||
struct message *msg = blaze822(file);
|
struct message *msg = blaze822(file);
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
int p = 80-38-3-indent;
|
int p = cols-38-3-indent;
|
||||||
printf("%*.*s\\_ %*.*s\n", -38 - indent, 38 + indent, "",
|
printf("%*.*s\\_ %*.*s\n", -38 - indent, 38 + indent, "",
|
||||||
-p, p, file);
|
-p, p, file);
|
||||||
return;
|
return;
|
||||||
@ -141,7 +142,7 @@ oneline(char *file)
|
|||||||
int z;
|
int z;
|
||||||
for (z = 0; z < indent; z++)
|
for (z = 0; z < indent; z++)
|
||||||
printf(" ");
|
printf(" ");
|
||||||
u8putstr(stdout, subjdec, 80-38-indent, 0);
|
u8putstr(stdout, subjdec, cols-38-indent, 0);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
blaze822_free(msg);
|
blaze822_free(msg);
|
||||||
@ -154,6 +155,14 @@ main(int argc, char *argv[])
|
|||||||
if (wcwidth(0xFFFD) > 0)
|
if (wcwidth(0xFFFD) > 0)
|
||||||
replacement = 0xFFFD;
|
replacement = 0xFFFD;
|
||||||
|
|
||||||
|
struct winsize w;
|
||||||
|
if (ioctl(1, TIOCGWINSZ, &w) == 0)
|
||||||
|
cols = w.ws_col;
|
||||||
|
if (getenv("COLUMNS"))
|
||||||
|
cols = atoi(getenv("COLUMNS"));
|
||||||
|
if (cols <= 40)
|
||||||
|
cols = 80;
|
||||||
|
|
||||||
char *seqmap = blaze822_seq_open(0);
|
char *seqmap = blaze822_seq_open(0);
|
||||||
blaze822_seq_load(seqmap);
|
blaze822_seq_load(seqmap);
|
||||||
cur = blaze822_seq_cur();
|
cur = blaze822_seq_cur();
|
||||||
|
Loading…
Reference in New Issue
Block a user