From ec5bf8c7bd451ad0e03332034235a1d49b95f283 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 12 Nov 2010 00:28:53 +0000 Subject: new latex package hardwrap (11nov10) git-svn-id: svn://tug.org/texlive/trunk@20407 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/hardwrap/hardwrap.sty | 294 ++++++++++++++++++++++ 1 file changed, 294 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/hardwrap/hardwrap.sty (limited to 'Master/texmf-dist/tex/latex/hardwrap') diff --git a/Master/texmf-dist/tex/latex/hardwrap/hardwrap.sty b/Master/texmf-dist/tex/latex/hardwrap/hardwrap.sty new file mode 100644 index 00000000000..b8158647723 --- /dev/null +++ b/Master/texmf-dist/tex/latex/hardwrap/hardwrap.sty @@ -0,0 +1,294 @@ +%% +%% This is file `hardwrap.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% hardwrap.dtx (with options: `package') +%% ____________________________ +%% The HARDWRAP package +%% (C) 2010 Will Robertson +%% (C) 2010 Kevin Godby +%% License information appended +%% +\ProvidesPackage{hardwrap} + [2010/11/11 v0.1 Hard wrap messages] +\IfFileExists{ifplatform.sty}{% + \RequirePackage{ifplatform} +}{% + \newif\ifwindows + \IfFileExists{/dev/null}{\windowsfalse}{\windowstrue} +} +\IfFileExists{pdftexcmds.sty}{% + \RequirePackage{pdftexcmds} +}{% + \def\pdf@shellescape{\pdfshellescape} +} +\RequirePackage{ifxetex} +\newcount\hw@charcount +\newcount\hw@wordcount +\def\hw@currtext{} +\def\hw@currline{} +\def\hw@currword{} +\protected\def\hw@protected@newline{} +\protected\def\hw@protected@space{ } +\let\hw@expanding@space\space +\protected\def\hw@insert@newline{\hw@insert@newline} +\protected\def\hw@scanstop{\hw@scanstop} +\def\hw@strlen#1{% + \numexpr0\hw@Ncharscan#1\hw@scanstop\relax +} +\def\hw@Ncharscan#1{% + \ifx#1\hw@scanstop + \expandafter\@gobble + \else + \expandafter\@firstofone + \fi + {+1\hw@Ncharscan}% +} +\def\hw@strlen@of#1{% + \expandafter\hw@strlen\expandafter{#1}% +} +\newcount\hw@maxprintline +\ifluatex\else + \ifxetex\else + \ifwindows\else + \ifnum\pdf@shellescape>0\relax + \hw@maxprintline=\@@input"|kpsewhich -var-value=max_print_line"\relax + \fi + \fi + \fi +\fi +\ifnum\hw@maxprintline=0\relax + \hw@maxprintline=79\relax % default +\fi +\newcommand*{\setmaxprintline}[1]{% + \hw@maxprintline=#1\relax +} +\newcommand*\HardWrap[5]{% + \begingroup + \hw@maxprintline=#2\relax + \let\space\hw@protected@space + \def\ {\space}% + \let\\\hw@insert@newline + \let\noexpand\string + \begingroup + #3% + \let\protect\string + \xdef\@tempa{#5}% + \endgroup + \expandafter\hw@scan\@tempa\hw@scanstop + \def\\{\hw@protected@newline}% + \def\hw@protected@newline{#4}% + \let\space\hw@expanding@space + \@temptokena={#1}% + \expandafter\the\expandafter\@temptokena\expandafter{\hw@wrappedtext}% + \endgroup +} +\def\hw@scan{% + \futurelet\let@token\hw@process +} +\def\hw@process{% + \ifx\let@token\hw@scanstop\relax + \hw@process@end + \let\next\@gobble + \else\ifx\let@token\@sptoken + \hw@process@space + \def\next{\afterassignment\hw@scan\let\@tempa= }% + \else\ifx\let@token\hw@insert@newline + \hw@process@messagebreak + \def\next{\expandafter\hw@dochar\@gobble}% + \else\ifx\let@token^^J + \hw@process@messagebreak + \def\next{\expandafter\hw@dochar\@gobble}% + \else\ifx\let@token\bgroup + \def\next{\expandafter\hw@dochar\hw@process@group}% + \else + \let\next\hw@dochar + \fi\fi\fi\fi\fi + \next +} +\def\hw@dochar#1{% + \edef\hw@currword{\hw@currword #1}% + \hw@scan +} +\def\hw@process@space{% + \hw@wordcount=\hw@strlen@of\hw@currword\relax + \ifnum\numexpr(\hw@charcount+\hw@wordcount)\relax<\hw@maxprintline + \advance\hw@charcount by \hw@wordcount + \ifx\hw@currline\@empty + \edef\hw@currline{\hw@currword}% + \else + \advance\hw@charcount by 1\relax % account for the space character + \edef\hw@currline{\hw@currline\hw@expanding@space\hw@currword}% + \fi + \else + \hw@charcount=\hw@wordcount\relax + \edef\hw@currtext{\hw@currtext\hw@currline\hw@protected@newline}% + \let\hw@currline\hw@currword + \fi + \let\hw@currword\@empty +} +\def\hw@process@messagebreak{% + \hw@wordcount=\hw@strlen@of\hw@currword\relax + \ifnum\numexpr(\hw@charcount+\hw@wordcount)<\hw@maxprintline + \edef\hw@currtext{% + \hw@currtext + \ifx\hw@currline\@empty\else + \hw@currline\space + \fi + \hw@currword\hw@protected@newline + }% + \hw@charcount=0\relax + \let\hw@currline\@empty + \else + \edef\hw@currtext{\hw@currtext\hw@currline\hw@protected@newline}% + \hw@charcount=\hw@wordcount + \let\hw@currline\hw@currword + \fi + \let\hw@currword\@empty +} +\def\hw@process@end{% + \hw@wordcount=\hw@strlen@of\hw@currword\relax + \ifnum\numexpr(\hw@charcount+\hw@wordcount)<\hw@maxprintline + \edef\hw@wrappedtext{% + \hw@currtext + \ifx\hw@currline\@empty\else + \hw@currline\space + \fi + \hw@currword + }% + \else + \edef\hw@wrappedtext{% + \hw@currtext\hw@currline\hw@protected@newline\hw@currword + }% + \fi +} +\edef\hw@process@group#1{% + \expandafter\@gobble\string\{% + #1% + \expandafter\@gobble\string\}% +} +\def\HardWrapSetup{% + \def\MessageBreak{\\}% + \def\newline{\\}% + \def\emph##1{\string_##1\string_}% + \def\textit##1{/##1/}% + \def\textbf##1{*##1*}% +} +\newcommand\hw@suffix{^^JThis message occurred} +\newcommand\GenerateLogMacros[1]{% + \lowercase{\def\hw@tempa{#1}}% + \def\hw@tempb{package}% + \ifx\hw@tempa\hw@tempb + \expandafter\GeneratePackageLogMacros + \else + \def\hw@tempb{class}% + \ifx\hw@tempa\hw@tempb + \expandafter\expandafter\expandafter\GenerateClassLogMacros + \else + \PackageError{hardwrap}{\MessageBreak + \string\GenerateLogMacros\space only accepts "package" + \MessageBreak or "class" types% + }{% + E.g., \detokenize{\GenerateLogMacros{package}[HW]{hardwrap}}% + }% + \fi + \fi +} +\newcommand{\GeneratePackageLogMacros}[2][]{% + \hw@generate@logging@macros{package}{#1}{#2}% + {\hw@maxprintline-\hw@strlen{#2}-16}% info length + {\hw@maxprintline-\hw@strlen{#2}-19}% warning length +} +\newcommand{\GenerateClassLogMacros}[2][]{% + \hw@generate@logging@macros{class}{#1}{#2}% + {\hw@maxprintline-\hw@strlen{#2}-14}% info length + {\hw@maxprintline-\hw@strlen{#2}-17}% warning length +} +\newcommand{\hw@generate@logging@macros}[5]{% + \def\@tempa{#2}\ifx\@tempa\@empty + \hw@generate@logging@macros@aux{#1}{#3}{#3}{#4}{#5}% + \else + \hw@generate@logging@macros@aux{#1}{#2}{#3}{#4}{#5}% + \fi +} +\newcommand{\hw@generate@logging@macros@aux}[5]{% + \expandafter\edef\csname #2@info\endcsname##1{% + \noexpand\HardWrap + {\@nameuse{hw@#1@info}{#3}} + {\number\numexpr#4\relax} + {\unexpanded\expandafter{\HardWrapSetup}} + {\noexpand\MessageBreak} + {##1}% + }% + \expandafter\edef\csname #2@info@noline\endcsname##1{% + \noexpand\HardWrap + {\@nameuse{hw@#1@info@noline}{#3}} + {\number\numexpr#4\relax} + {\unexpanded\expandafter{\HardWrapSetup}} + {\noexpand\MessageBreak} + {##1}% + }% + \expandafter\edef\csname #2@warning\endcsname##1{% + \noexpand\HardWrap + {\@nameuse{hw@#1@warning}{#3}} + {\number\numexpr#5\relax} + {\unexpanded\expandafter{\HardWrapSetup}} + {\noexpand\MessageBreak} + {##1}% + }% + \expandafter\edef\csname #2@warning@noline\endcsname##1{% + \noexpand\HardWrap + {\@nameuse{hw@#1@warning@noline}{#3}} + {\number\numexpr#5\relax} + {\unexpanded\expandafter{\HardWrapSetup}} + {\noexpand\MessageBreak} + {##1}% + }% + \expandafter\edef\csname #2@error\endcsname##1##2{% + \noexpand\HardWrap + {\xdef\noexpand\hw@tempa} + {\number\numexpr#5\relax} + {\unexpanded\expandafter{\HardWrapSetup}} + {\MessageBreak} + {\MessageBreak ##1}% + \noexpand\HardWrap + {\xdef\noexpand\hw@tempb} + {\the\hw@maxprintline} + {\unexpanded\expandafter{\HardWrapSetup}} + {\MessageBreak} + {\MessageBreak ##2}% + \unexpanded{% + \@nameuse{hw@#1@error}{#3}{\hw@tempa}{\hw@tempb}% + }% + }% +} +\protected\def\hw@class@info #1#2{\ClassInfo {#1}{#2\hw@suffix}} +\protected\def\hw@class@info@noline #1#2{\ClassInfo {#1}{#2\@gobbletwo}} +\protected\def\hw@class@warning #1#2{\ClassWarning{#1}{#2\hw@suffix}} +\protected\def\hw@class@warning@noline#1#2{\ClassWarning{#1}{#2\@gobbletwo}} +\protected\def\hw@class@error #1#2{\ClassError {#1}{#2\@gobble}} +\protected\def\hw@package@info #1#2{\PackageInfo {#1}{#2\hw@suffix}} +\protected\def\hw@package@info@noline #1#2{\PackageInfo {#1}{#2\@gobbletwo}} +\protected\def\hw@package@warning #1#2{\PackageWarning{#1}{#2\hw@suffix}} +\protected\def\hw@package@warning@noline#1#2{\PackageWarning{#1}{#2\@gobbletwo}} +\protected\def\hw@package@error #1#2{\PackageError {#1}{#2\@gobble}} +%% +%% Copyright (C) 2010 by Will Robertson +%% Copyright (C) 2010 by Kevin Godby +%% +%% Distributable under the LaTeX Project Public License, +%% version 1.3c or higher (your choice). The latest version of +%% this license is at: http://www.latex-project.org/lppl.txt +%% +%% This work is "maintained" (as per LPPL maintenance status) +%% by Will Robertson. +%% +%% This work consists of the file hardwrap.dtx +%% and the derived files hardwrap.sty, +%% hardwrap.ins, and +%% hardwrap.pdf. +%% +%% +%% End of file `hardwrap.sty'. -- cgit v1.2.3