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