aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term.h
Commit message (Collapse)AuthorAgeFilesLines
* In private header files, __BEGIN_DECLS and __END_DECLS are pointless.Ingo Schwarze2015-11-071-4/+1
| | | | | | | | | | | | Because these work slightly differently on different systems, they are becoming a maintenance burden in the portable version, so delete them. Besides, one of the chief design goals of the mandoc toolbox is to make sure that nothing related to documentation requires C++. Consequently, linking mandoc against any kind of C++ program would defeat the purpose and is not supported. I don't understand why kristaps@ added them in the first place.
* Major character table cleanup:Ingo Schwarze2015-10-131-2/+1
| | | | | | | | | | | | | * Use ohash(3) rather than a hand-rolled hash table. * Make the character table static in the chars.c module: There is no need to pass a pointer around, we most certainly never want to use two different character tables concurrently. * No need to keep the characters in a separate file chars.in; that merely encourages downstream porters to mess with them. * Sort the characters to agree with the mandoc_chars(7) manual page. * Specify Unicode codepoints in hex, not decimal (that's the detail that originally triggered this patch). No functional change, minus 100 LOC, and i don't see a performance change.
* Trailing whitespace is significant when determining the width of a tagIngo Schwarze2015-09-211-7/+8
| | | | | in mdoc(7) .Bl -tag and man(7) .TP, but not in man(7) .IP. Quirk reported by Jan Stary <hans at stare dot cz> on ports@.
* Initial, still somewhat experimental implementation to leverageIngo Schwarze2015-07-171-1/+2
| | | | | | | | | | | | | | | less(1) -T and :t ctags(1)-like functionality to jump to the definitions of various terms inside manual pages. To be polished in the tree, so bear with me and report issues. Technically, if less(1) is used as a pager, information is collected by the mdoc(7) terminal formatter, first stored using the ohash library, then ultimately written to a temporary file which is passed to less via -T. No change intended for other output formatters or when running without a pager. Based on an idea from Kristaps using feedback from many, in particular phessler@ nicm@ millert@ halex@ doug@ kspillner@ deraadt@.
* Replace the kludge for the \z escape sequence by an actualIngo Schwarze2015-04-291-8/+9
| | | | | | | | implementation. As a side effect, minus ten lines of code. As another side effect, this also fixes the assertion failure that used to be triggered by "\z\o'ab'c" at the beginning of an output line, found by jsg@ with afl (test case 022/Apr27).
* Rounding rules for horizontal scaling widths are more complicated.Ingo Schwarze2015-04-041-3/+3
| | | | | | | | | | | | | There is a first rounding to basic units on the input side. After that, rounding rules differ between requests and macros. Requests round to the nearest possible character position. Macros round to the next character position to the left. Implement that by changing the return value of term_hspan() to basic units and leaving the second scaling and rounding stage to the formatters instead of doing it in the terminal handler. Improves for example argtable2(3).
* Third step towards parser unification:Ingo Schwarze2015-04-021-6/+7
| | | | | Replace struct mdoc_meta and struct man_meta by a unified struct roff_meta. Written of the train from London to Exeter on the way to p2k15.
* Use relative offsets instead of absolute pointers for the terminalIngo Schwarze2015-01-311-3/+2
| | | | | | font stack. The latter fail after the stack is grown with realloc(). Fixing an assertion failure found by jsg@ with afl some time ago (test case number 51).
* support negative horizontal widths in man(7);Ingo Schwarze2014-12-231-5/+3
| | | | minus twenty lines of code in spite of enhanced functionality
* Enforcing an arbitrary, implementation dependent, undocumented limitIngo Schwarze2014-12-191-5/+5
| | | | | | by calling assert() when valid user input exceeds it is a bad idea. Allocate the terminal font stack dynamically instead of crashing above 10 entries. Issue found by jsg@ with afl.
* Fix the implementation and documentation of \c (continue text input line).Ingo Schwarze2014-12-021-1/+2
| | | | | In particular, make it work in no-fill mode, too. Reminded by Carsten dot Kunze at arcor dot de (Heirloom roff).
* header cleanup:Ingo Schwarze2014-12-011-5/+8
| | | | | | * add missing forward declarations * remove needless header inclusions * some style unification
* remove unneccessary inclusion protection; patch from deraadt@Ingo Schwarze2014-12-011-5/+1
|
* Make the character table available to libroff so it can check theIngo Schwarze2014-10-281-2/+2
| | | | | | | | validity of character escape names and warn about unknown ones. This requires mchars_spec2cp() to report unknown names again. Fortunately, that doesn't require changing the calling code because according to groff, invalid character escapes should not produce output anyway, and now that we warn about them, that's fine.
* Improve -Tascii output for Unicode escape sequences: For the first 512Ingo Schwarze2014-10-261-1/+3
| | | | | | | | | | | | code points, provide ASCII approximations. This is already much better than what groff does, which prints nothing for most code points. A few minor fixes while here: * Handle Unicode escape sequences in the ASCII range. * In case of errors, use the REPLACEMENT CHARACTER U+FFFD for -Tutf8 and the string "<?>" for -Tascii output. * Handle all one-character escape sequences in mchars_spec2{cp,str}() and remove the workarounds on the higher level.
* simplify handling of .An -[no]split for terminal output:Ingo Schwarze2014-09-171-4/+3
| | | | | delete one static function, one flag #define, and 25 lines of code; no functional change
* Implement the traditional -h option for man(1): show the SYNOPSIS only.Ingo Schwarze2014-09-031-1/+2
| | | | | | | As usual, we get mandoc -h and apropos -h for free. Try stuff like "apropos -h In=dirent" or "apropos -h Fa=timespec". Only useful for terminal output, so -Tps, -Tpdf, -Thtml ignore -h for now.
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-3/+3
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* Add a new term_flushln() flag TERMP_BRIND (if break, then indent)Ingo Schwarze2014-04-081-6/+7
| | | | | | | | | | to control indentation of continuation lines in TERMP_NOBREAK mode. In the past, this was always on; continue using it for .Bl, .Nm, .Fn, .Fo, and .HP, but no longer for .IP and .TP. I looked at this because sthen@ reported the issue in a manual of a Perl module from ports, but it affects base, too: This patch reduces groff-mandoc differences in base by more than 15%.
* Support relative arguments to .ll (increase or decrease line length).Ingo Schwarze2014-03-301-3/+3
|
* Implement the roff(7) .ll (line length) request.Ingo Schwarze2014-03-301-2/+5
| | | | | Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
* Do not break output lines in .Fn function arguments in SYNOPSIS mode.Ingo Schwarze2013-12-251-1/+2
| | | | | Following an idea from Franco Fichtner, but implemented more cleanly. This reduces groff-mandoc-differences in OpenBSD base by a fantastic 7.5%.
* Delete the unused flag TERMP_IGNDELIMIngo Schwarze2013-12-241-9/+8
| | | | | and the empty callback termp_igndelim_pre(). Sort the remaining termp flags.
* Polishing the worms in my favourite can, term_flushln().Ingo Schwarze2013-12-221-2/+3
| | | | | | | | | | | The TERMP_TWOSPACE flag i introduced in August 2009 was idiosyncratic and served only a very narrow purpose. Replace it by a more intuitive and more general termp attribute "trailspace", to be used together with TERMP_NOBREAK, to request a minimum amount of whitespace at the end of the current column. Adapt all code to the new interface. No functional change intended; code reviews to confirm that are welcome *eg*.
* Move the last column-counting members of struct termp (col and maxcols)Ingo Schwarze2013-08-211-3/+3
| | | | | | | | | from int to size_t, to match some existing ones (offset, *rmargin, viscol). Move some related local variables from int to size_t as well. Needed as a preparation to make a generalized adjbuf() function available beyond the file term.c, i.e. in mandoc.c. Also saves a couple of ugly casts.
* Implement the roff(7) font-escape sequence \f(BI "bold+italic".Ingo Schwarze2013-08-081-1/+2
| | | | | This improves the formatting of about 40 base manuals and reduces groff-mandoc formatting differences in base by about 5%.
* Implement the roff \z escape sequence, intended to output the nextIngo Schwarze2012-05-311-1/+2
| | | | | | | | | | | | | | | | | | character without advancing the cursor position; implement it to simply skip the next character, as it will usually be overwritten. With this change, the pod2man(1) preamble user-defined string \*:, intended to render as a diaeresis or umlaut diacritic above the preceding character, is rendered in a slightly less ugly way, though still not correctly. It was rendered as "z.." and is now rendered as ".". Given that the definition of \*: uses elaborate manual \h positioning, there is little chance for mandoc(1) to ever render it correctly, but at least we can refrain from printing out a spurious "z", and we can make the \z do something semi-reasonable for easier cases. "just commit" kristaps@
* Fix the vertical spacing around tbl(7) instances in man(7).Ingo Schwarze2012-05-271-1/+2
| | | | | | | | | | | | | | | Groff forces the document author to manually request sufficient spacing after .TE - that is, at least .sp 1v after a table with the "box" option and at least .sp 2v after a table with the "doublebox" option - or else it clobbers the box. I consider that insane, so i'm not imitating groff in that respect. Instead, i add at least as much vertical space as groff, or more where required to avoid clobbering the box. Consequently, output will be identical for input that looks sane with groff, and mandoc will make output look better for input that looks bad with groff. "Please check them in and I'll look into them later!" kristaps@
* Implement mdoc(7)-like output style variant for man(7) documents:Ingo Schwarze2011-12-041-1/+2
| | | | | | | | | | | * one instead of three blank lines after the page header; * one instead of three blank lines before the page footer; * source instead of title(section) in the lower right corner. Select this style variant with the undocumented command line option -Omdoc. In the long run, we hope to unify the ouput of both languages and to pull this out again, but that requires coordination with groff. Grudgingly ok and, (as usual,-) more comments requested by kristaps@
* Make the default left text margin configurable from the command line,Ingo Schwarze2011-11-131-1/+2
| | | | | | | just like the default right margin already is. This may be useful for people with expensive screen real estate. Besides, it helps automated man(7) to mdoc(7) output comparisons to validate -Tman output. ok kristaps@ on an earlier version
* Remove the terminal frontend flag TERMP_NOLPAD.Ingo Schwarze2011-09-191-2/+1
| | | | | | | | | | | | | | | | | In columnated contexts (.Bl -column, .Bl -tag, .IP, .TP, .HP etc.), do not pad after writing a column. Instead, always pad before writing content. In itself, this change avoids: - writing trailing whitespace in some situations - with .fi/.nf in .HP, breaking lines that were already padded It allows several bugfixes included in this patch: - Do not count backspace as a character with positive width. - Set up proper indentation when encountering .fi/.nf in .HP. - Adjust the .HP indentation width to what groff does. - Never unlimit the right margin unless in the final column. ok kristaps@
* forgotten Copyright bumps; no code changeIngo Schwarze2011-09-181-2/+2
| | | | found while syncing to OpenBSD
* Add character output (-Tpdf, -Tps, -Tascii) for equations. This is theKristaps Dzonsons2011-07-221-1/+2
| | | | minimum: unseparated terms.
* Flip on -Tutf8 backend support. This forces the UTF-8 LC_CTYPE and doesKristaps Dzonsons2011-05-201-2/+3
| | | | | | little else. Also remove the check for __STDC_ISO_10646__. It turns out that very few systems---even those that support it---actually declare this and it's just causing problems instead of being useful.
* Add mode for -Tlocale. This mode, with this commit, behaves exactlyKristaps Dzonsons2011-05-171-3/+3
| | | | | | | like -Tascii. While adding this, inline term_alloc() (was a one-liner), remove some switches around the terminal encoding for the symbol table (unnecessary), and split out ascii_alloc() into ascii_init(), which is also called from locale_init().
* Move struct termp_ps into term_ps.c; remove the engine union in struct termp,Kristaps Dzonsons2011-05-151-33/+2
| | | | | | which only held one entry; finally (as per the first), make "ps" member into a pointer managed by term_ps.c. This frees up a nice chunk of memory during run-time and in the binary.
* Make some values "int" that were "size_t". These are primarily used forKristaps Dzonsons2011-05-141-3/+3
| | | | indexing into arrays, so this removes lots of casts from size_t to int.
* Make character engine (-Tascii, -Tpdf, -Tps) ready for Unicode: make bufferKristaps Dzonsons2011-05-141-4/+4
| | | | | | consist of type "int". This will take more work (especially in encode and friends), but this is a strong start. This commit also consists of some harmless lint fixes.
* Move "chars" interface out of out.h and into mandoc.h. This doesn'tKristaps Dzonsons2011-04-291-2/+2
| | | | | | | | | | change any code but for renaming functions and types to be consistent with other mandoc.h stuff. The reason for moving into libmandoc is that the rendering of special characters is part of mandoc itself---not an external part. From mandoc(1)'s perspective, this changes nothing, but for other utilities, it's important to have these part of libmandoc. Note this isn't documented [yet] in mandoc.3 because there are some parts I'd like to change around beforehand.
* Stuff tbl_calc() into out.c so that it can be shared by all output modesKristaps Dzonsons2011-01-051-2/+2
| | | | | | | | | | | | | | | | (isn't now, but will need to be, used by -T[x]html also). Necessitated a lot of churn in getting tbl_calc* code out of tbl_term.c and into out.c, including renaming some structures and so on. The abstraction is in having a pointer to a wrapper function for calculating string widths. The char devices use term_strlen and term_len; the others will probably just use strlen(). While at it, remove some superfluous assertions in the tbl code. This allows all tbl manuals to clear. Lastly, set the right-margin to be the maximum margin for each table span. This allows big, complicated tbl-pages like terminfo to be displayed. They're ugly, but they work.
* Make width calculations occur within tbl_term.c, not tbl.c. This allowsKristaps Dzonsons2011-01-031-2/+8
| | | | | | | | | | | | | | | | for front-ends to make decisions about widths, not the back-end. To pull this off, first make each tbl_head contain a unique index value (0 <= index < total tbl_head elements) and remove the tbl_calc() routine from the back-end. Then, when encountering the first tbl_span in the front-end, dynamically create an array of configurations (termp_tbl) keyed on each tbl_head's unique index value. Construct the decimals and widths at this time, then continue parsing as before. The termp_tbl and indexes are required because we pass a const tbl AST into the front-end.
* Turn on -Tascii tbl printing. The output still has some issues---I'mKristaps Dzonsons2011-01-021-1/+2
| | | | | | not sure whether it's in the header calculation or term.c squashing spaces or whatever, but let's get this in for general testing as soon as possible.
* Fully-working -Tpdf: xref table is now generated. This works for bothKristaps Dzonsons2010-07-251-4/+6
| | | | single and multiple-manual mode (e.g., mandoc -Tpdf foo.1 bar.1).
* Initial PDF shim over PS. This produces working PDF output with -Tpdf.Kristaps Dzonsons2010-07-251-2/+6
| | | | | | | | | | It's currently missing the xref table, so you'll get a warning in most PDF viewers). It also produces lots of redundant output, which will go away once I get a better handle on the PDF spec. The code doesn't really touch any existing functionality; it's a bunch of conditionals atop the -Tps (term_ps.c) implementation. I'm checking it in now to have it exist and be auditable. It needs clean-up, polish, and general care (and xref!).
* correct lots of copyright notices;Ingo Schwarze2010-07-131-2/+2
| | | | ok kristaps@
* Suppress printing of newlines/space at start of new -Tps page.Kristaps Dzonsons2010-07-041-2/+3
| | | | | Also renamed "psstate" -> "flags" (was wrongly implying some sort of state machine).
* PostScript can now handle scaled glyph sizes (see "scale" in structKristaps Dzonsons2010-06-301-1/+2
| | | | termp_ps) to arbitrarily scale font. Tested with 10 (default), 12, 14.
* Pushed normalisation of scaling units into term_hspan().Kristaps Dzonsons2010-06-301-2/+2
|
* Move term_hspan() calculation into the output devices, where it belongs.Kristaps Dzonsons2010-06-301-1/+3
|
* Push paper calculation out of getsubopt() loop. Make all points be AFMKristaps Dzonsons2010-06-301-11/+11
| | | | glyph units to make positioning more precise.