Fixed dependencies for jquery.collapsibleTabs
[lhc/web/wiklou.git] / maintenance / term / MWTerm.php
1 <?php
2 /**
3 * Set of classes to help with test output and such. Right now pretty specific
4 * to the parser tests but could be more useful one day :)
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * @file
22 * @ingroup Testing
23 * @todo Fixme: Make this more generic
24 */
25
26 /**
27 * Terminal that supports ANSI escape sequences.
28 */
29 class AnsiTermColorer {
30 function __construct() {
31 }
32
33 /**
34 * Return ANSI terminal escape code for changing text attribs/color
35 *
36 * @param $color String: semicolon-separated list of attribute/color codes
37 * @return String
38 */
39 public function color( $color ) {
40 global $wgCommandLineDarkBg;
41
42 $light = $wgCommandLineDarkBg ? "1;" : "0;";
43
44 return "\x1b[{$light}{$color}m";
45 }
46
47 /**
48 * Return ANSI terminal escape code for restoring default text attributes
49 *
50 * @return String
51 */
52 public function reset() {
53 return $this->color( 0 );
54 }
55 }
56
57 /**
58 * A colour-less terminal
59 */
60 class DummyTermColorer {
61 public function color( $color ) {
62 return '';
63 }
64
65 public function reset() {
66 return '';
67 }
68 }
69