580
|
1 // tree-base.cc -*- C++ -*- |
|
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 |
|
36 #include "tree-base.h" |
|
37 |
|
38 // Current indentation. |
|
39 int tree_print_code::curr_print_indent_level = 0; |
|
40 |
|
41 // Nonzero means we are at the beginning of a line. |
|
42 int tree_print_code::beginning_of_line = 1; |
|
43 |
|
44 // All print_code() functions should use this to print new lines. |
|
45 |
|
46 void |
|
47 tree_print_code::print_code_new_line (ostream& os) |
|
48 { |
|
49 os << "\n"; |
|
50 |
|
51 beginning_of_line = 1; |
|
52 } |
|
53 |
|
54 // Each print_code() function should call this before printing |
|
55 // anything. |
|
56 // |
|
57 // This doesn't need to be fast, but isn't there a better way? |
|
58 |
|
59 void |
|
60 tree_print_code::print_code_indent (ostream& os) |
|
61 { |
|
62 assert (curr_print_indent_level >= 0); |
|
63 |
|
64 if (beginning_of_line) |
|
65 { |
|
66 os.form ("%*s", curr_print_indent_level, ""); |
|
67 beginning_of_line = 0; |
|
68 } |
|
69 } |
|
70 |
|
71 // For ressetting print_code state. |
|
72 |
|
73 void |
|
74 tree_print_code::print_code_reset (void) |
|
75 { |
|
76 beginning_of_line = 1; |
|
77 curr_print_indent_level = 0; |
|
78 } |
|
79 |
|
80 /* |
|
81 ;;; Local Variables: *** |
|
82 ;;; mode: C++ *** |
|
83 ;;; page-delimiter: "^/\\*" *** |
|
84 ;;; End: *** |
|
85 */ |