1742
|
1 // pt-base.cc -*- C++ -*- |
580
|
2 /* |
|
3 |
1009
|
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton |
580
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
580
|
21 |
|
22 */ |
|
23 |
1297
|
24 #if defined (__GNUG__) |
|
25 #pragma implementation |
|
26 #endif |
|
27 |
580
|
28 #ifdef HAVE_CONFIG_H |
1192
|
29 #include <config.h> |
580
|
30 #endif |
|
31 |
1343
|
32 #include <cassert> |
|
33 |
580
|
34 #include <iostream.h> |
|
35 |
1742
|
36 #include "pt-base.h" |
1588
|
37 #include "user-prefs.h" |
580
|
38 |
|
39 // Current indentation. |
|
40 int tree_print_code::curr_print_indent_level = 0; |
|
41 |
|
42 // Nonzero means we are at the beginning of a line. |
|
43 int tree_print_code::beginning_of_line = 1; |
|
44 |
|
45 // All print_code() functions should use this to print new lines. |
|
46 |
|
47 void |
|
48 tree_print_code::print_code_new_line (ostream& os) |
|
49 { |
|
50 os << "\n"; |
|
51 |
|
52 beginning_of_line = 1; |
|
53 } |
|
54 |
|
55 // Each print_code() function should call this before printing |
|
56 // anything. |
|
57 // |
|
58 // This doesn't need to be fast, but isn't there a better way? |
|
59 |
|
60 void |
|
61 tree_print_code::print_code_indent (ostream& os) |
|
62 { |
|
63 assert (curr_print_indent_level >= 0); |
|
64 |
|
65 if (beginning_of_line) |
|
66 { |
1755
|
67 os.form ("%s%*s", user_pref.ps4.c_str (), curr_print_indent_level, ""); |
580
|
68 beginning_of_line = 0; |
|
69 } |
|
70 } |
|
71 |
|
72 // For ressetting print_code state. |
|
73 |
|
74 void |
|
75 tree_print_code::print_code_reset (void) |
|
76 { |
|
77 beginning_of_line = 1; |
|
78 curr_print_indent_level = 0; |
|
79 } |
|
80 |
|
81 /* |
|
82 ;;; Local Variables: *** |
|
83 ;;; mode: C++ *** |
|
84 ;;; page-delimiter: "^/\\*" *** |
|
85 ;;; End: *** |
|
86 */ |