580
|
1 // tree-base.cc -*- C++ -*- |
|
2 /* |
|
3 |
|
4 Copyright (C) 1992, 1993, 1994 John W. Eaton |
|
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 |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include "config.h" |
|
26 #endif |
|
27 |
|
28 #include <iostream.h> |
|
29 #include <assert.h> |
|
30 |
|
31 #include "tree-base.h" |
|
32 |
|
33 // Current indentation. |
|
34 int tree_print_code::curr_print_indent_level = 0; |
|
35 |
|
36 // Nonzero means we are at the beginning of a line. |
|
37 int tree_print_code::beginning_of_line = 1; |
|
38 |
|
39 // All print_code() functions should use this to print new lines. |
|
40 |
|
41 void |
|
42 tree_print_code::print_code_new_line (ostream& os) |
|
43 { |
|
44 os << "\n"; |
|
45 |
|
46 beginning_of_line = 1; |
|
47 } |
|
48 |
|
49 // Each print_code() function should call this before printing |
|
50 // anything. |
|
51 // |
|
52 // This doesn't need to be fast, but isn't there a better way? |
|
53 |
|
54 void |
|
55 tree_print_code::print_code_indent (ostream& os) |
|
56 { |
|
57 assert (curr_print_indent_level >= 0); |
|
58 |
|
59 if (beginning_of_line) |
|
60 { |
|
61 os.form ("%*s", curr_print_indent_level, ""); |
|
62 beginning_of_line = 0; |
|
63 } |
|
64 } |
|
65 |
|
66 // For ressetting print_code state. |
|
67 |
|
68 void |
|
69 tree_print_code::print_code_reset (void) |
|
70 { |
|
71 beginning_of_line = 1; |
|
72 curr_print_indent_level = 0; |
|
73 } |
|
74 |
|
75 /* |
|
76 ;;; Local Variables: *** |
|
77 ;;; mode: C++ *** |
|
78 ;;; page-delimiter: "^/\\*" *** |
|
79 ;;; End: *** |
|
80 */ |