1 -- Copyright (C) 2003 David Roundy 2 -- 3 -- This program is free software; you can redistribute it and/or modify 4 -- it under the terms of the GNU General Public License as published by 5 -- the Free Software Foundation; either version 2, or (at your option) 6 -- any later version. 7 -- 8 -- This program is distributed in the hope that it will be useful, 9 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 10 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 -- GNU General Public License for more details. 12 -- 13 -- You should have received a copy of the GNU General Public License 14 -- along with this program; see the file COPYING. If not, write to 15 -- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 -- Boston, MA 02110-1301, USA. 17 18 {-# OPTIONS_GHC -cpp #-} 19 {-# LANGUAGE CPP #-} 20 21 #include "gadts.h" 22 23 module Darcs.PrintPatch ( printPatch, contextualPrintPatch, 24 printPatchPager, printFriendly ) where 25 26 import Darcs.Patch ( Patchy, showContextPatch, showPatch ) 27 import Darcs.SlurpDirectory ( Slurpy ) 28 import Darcs.Arguments ( DarcsFlag, showFriendly ) 29 import Printer ( putDocLnWith ) 30 import Darcs.ColorPrinter ( fancyPrinters ) 31 import Darcs.External ( viewDocWith ) 32 33 -- | @'printFriendly' opts patch@ prints @patch@ in accordance with the 34 -- flags in opts, ie, whether @--verbose@ or @--summary@ were passed at 35 -- the command-line. 36 printFriendly :: Patchy p => [DarcsFlag] -> p C(x y) -> IO () 37 printFriendly opts p = putDocLnWith fancyPrinters $ showFriendly opts p 38 39 -- | 'printPatch' prints a patch on standard output. 40 printPatch :: Patchy p => p C(x y) -> IO () 41 printPatch p = putDocLnWith fancyPrinters $ showPatch p 42 43 -- | 'printPatchPager' runs '$PAGER' and shows a patch in it. 44 printPatchPager :: Patchy p => p C(x y) -> IO () 45 printPatchPager p = viewDocWith fancyPrinters $ showPatch p 46 47 -- | 'contextualPrintPatch' prints a patch, together with its context, 48 -- on standard output. 49 contextualPrintPatch :: Patchy p => Slurpy -> p C(x y) -> IO () 50 contextualPrintPatch s p = putDocLnWith fancyPrinters $ showContextPatch s p