* mdocml: Make the output width an option for ascii_alloc and use that to
@ 2010-05-15 16:18 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2010-05-15 16:18 UTC (permalink / raw)
To: source
Log Message:
-----------
Make the output width an option for ascii_alloc and use that to compute
the default margin. Hard-code 80 chars/line for now.
Modified Files:
--------------
mdocml:
main.c
main.h
man_term.c
mdoc_term.c
term.c
term.h
Revision Data
-------------
Index: term.c
===================================================================
RCS file: /home/joerg/cvsroot/mdocml/term.c,v
retrieving revision 1.133
retrieving revision 1.134
diff -Lterm.c -Lterm.c -u -p -r1.133 -r1.134
--- term.c
+++ term.c
@@ -34,7 +34,7 @@
#include "mdoc.h"
#include "main.h"
-static struct termp *term_alloc(enum termenc);
+static struct termp *term_alloc(enum termenc, size_t);
static void term_free(struct termp *);
static void spec(struct termp *, const char *, size_t);
static void res(struct termp *, const char *, size_t);
@@ -45,10 +45,10 @@ static void encode(struct termp *, co
void *
-ascii_alloc(void)
+ascii_alloc(size_t width)
{
- return(term_alloc(TERMENC_ASCII));
+ return(term_alloc(TERMENC_ASCII, width));
}
@@ -74,7 +74,7 @@ term_free(struct termp *p)
static struct termp *
-term_alloc(enum termenc enc)
+term_alloc(enum termenc enc, size_t width)
{
struct termp *p;
@@ -84,6 +84,10 @@ term_alloc(enum termenc enc)
exit(EXIT_FAILURE);
}
p->enc = enc;
+ /* Enforce some lower boundary. */
+ if (width < 60)
+ width = 60;
+ p->defrmargin = width - 2;
return(p);
}
Index: term.h
===================================================================
RCS file: /home/joerg/cvsroot/mdocml/term.h,v
retrieving revision 1.54
retrieving revision 1.55
diff -Lterm.h -Lterm.h -u -p -r1.54 -r1.55
--- term.h
+++ term.h
@@ -32,6 +32,7 @@ enum termfont {
#define TERM_MAXMARGIN 100000 /* FIXME */
struct termp {
+ size_t defrmargin; /* Right margin of the device.. */
size_t rmargin; /* Current right margin. */
size_t maxrmargin; /* Max right margin. */
size_t maxcols; /* Max size of buf. */
Index: man_term.c
===================================================================
RCS file: /home/joerg/cvsroot/mdocml/man_term.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -Lman_term.c -Lman_term.c -u -p -r1.64 -r1.65
--- man_term.c
+++ man_term.c
@@ -163,7 +163,7 @@ terminal_man(void *arg, const struct man
p = (struct termp *)arg;
p->overstep = 0;
- p->maxrmargin = 65;
+ p->maxrmargin = p->defrmargin;
if (NULL == p->symtab)
switch (p->enc) {
@@ -803,6 +803,7 @@ post_RS(DECL_ARGS)
static void
print_man_node(DECL_ARGS)
{
+ size_t rm, rmax;
int c;
c = 1;
@@ -819,10 +820,13 @@ print_man_node(DECL_ARGS)
/* FIXME: this means that macro lines are munged! */
if (MANT_LITERAL & mt->fl) {
+ rm = p->rmargin;
+ rmax = p->maxrmargin;
p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
p->flags |= TERMP_NOSPACE;
term_flushln(p);
- p->rmargin = p->maxrmargin = 65;
+ p->rmargin = rm;
+ p->maxrmargin = rmax;
}
break;
default:
Index: mdoc_term.c
===================================================================
RCS file: /home/joerg/cvsroot/mdocml/mdoc_term.c,v
retrieving revision 1.122
retrieving revision 1.123
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.122 -r1.123
--- mdoc_term.c
+++ mdoc_term.c
@@ -273,7 +273,7 @@ terminal_mdoc(void *arg, const struct md
p = (struct termp *)arg;
p->overstep = 0;
- p->maxrmargin = 78;
+ p->maxrmargin = p->defrmargin;
if (NULL == p->symtab)
switch (p->enc) {
Index: main.h
===================================================================
RCS file: /home/joerg/cvsroot/mdocml/main.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lmain.h -Lmain.h -u -p -r1.2 -r1.3
--- main.h
+++ main.h
@@ -38,7 +38,7 @@ void html_free(void *);
void tree_mdoc(void *, const struct mdoc *);
void tree_man(void *, const struct man *);
-void *ascii_alloc(void);
+void *ascii_alloc(size_t);
void terminal_mdoc(void *, const struct mdoc *);
void terminal_man(void *, const struct man *);
void terminal_free(void *);
Index: main.c
===================================================================
RCS file: /home/joerg/cvsroot/mdocml/main.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -Lmain.c -Lmain.c -u -p -r1.68 -r1.69
--- main.c
+++ main.c
@@ -484,7 +484,7 @@ fdesc(struct curparse *curp)
case (OUTT_LINT):
break;
default:
- curp->outdata = ascii_alloc();
+ curp->outdata = ascii_alloc(80);
curp->outman = terminal_man;
curp->outmdoc = terminal_mdoc;
curp->outfree = terminal_free;
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-05-15 16:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-15 16:18 mdocml: Make the output width an option for ascii_alloc and use that to kristaps
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).