comparison src/pr-output.cc @ 1186:d94bcafabac2

[project @ 1995-03-30 04:57:32 by jwe]
author jwe
date Thu, 30 Mar 1995 05:00:41 +0000
parents 75fc98220389
children b6360f2d4fa6
comparison
equal deleted inserted replaced
1185:669750cfad84 1186:d94bcafabac2
52 static char *curr_real_fmt = 0; 52 static char *curr_real_fmt = 0;
53 53
54 // Current format string for the imaginary part of complex numbers. 54 // Current format string for the imaginary part of complex numbers.
55 static char *curr_imag_fmt = 0; 55 static char *curr_imag_fmt = 0;
56 56
57 // Nonzero means don\'t do any fancy formatting. 57 // Nonzero means don't do any fancy formatting.
58 static int free_format = 0; 58 static int free_format = 0;
59 59
60 // Nonzero means print plus sign for nonzero, blank for zero. 60 // Nonzero means print plus sign for nonzero, blank for zero.
61 static int plus_format = 0; 61 static int plus_format = 0;
62
63 // Nonzero means don't put newlines around the column number headers.
64 static int compact_format = 0;
62 65
63 // Nonzero means always print like dollars and cents. 66 // Nonzero means always print like dollars and cents.
64 static int bank_format = 0; 67 static int bank_format = 0;
65 68
66 // Nonzero means use an e format. 69 // Nonzero means use an e format.
876 os << "(" << nr << "x" << nc << ")"; 879 os << "(" << nr << "x" << nc << ")";
877 os << "\n"; 880 os << "\n";
878 } 881 }
879 } 882 }
880 883
884 static void
885 pr_col_num_header (ostream& os, int total_width, int max_width,
886 int lim, int col)
887 {
888 if (total_width > max_width && user_pref.split_long_rows)
889 {
890 if (col != 0 && ! compact_format)
891 os << "\n";
892
893 int num_cols = lim - col;
894
895 if (num_cols == 1)
896 os << " Column " << col + 1 << ":\n";
897 else if (num_cols == 2)
898 os << " Columns " << col + 1 << " and " << lim << ":\n";
899 else
900 os << " Columns " << col + 1 << " through " << lim << ":\n";
901
902 if (! compact_format)
903 os << "\n";
904 }
905 }
906
881 void 907 void
882 octave_print_internal (ostream& os, double d, int pr_as_read_syntax) 908 octave_print_internal (ostream& os, double d, int pr_as_read_syntax)
883 { 909 {
884 if (plus_format) 910 if (plus_format)
885 { 911 {
1000 { 1026 {
1001 for (int col = 0; col < nc; col += inc) 1027 for (int col = 0; col < nc; col += inc)
1002 { 1028 {
1003 int lim = col + inc < nc ? col + inc : nc; 1029 int lim = col + inc < nc ? col + inc : nc;
1004 1030
1005 if (total_width > max_width && user_pref.split_long_rows) 1031 pr_col_num_header (os, total_width, max_width, lim, col);
1006 {
1007 if (col != 0)
1008 os << "\n";
1009
1010 int num_cols = lim - col;
1011 if (num_cols == 1)
1012 os << " Column " << col + 1 << ":\n\n";
1013 else if (num_cols == 2)
1014 os << " Columns " << col + 1 << " and " << lim
1015 << ":\n\n";
1016 else
1017 os << " Columns " << col + 1 << " through " << lim
1018 << ":\n\n";
1019 }
1020 1032
1021 for (int i = 0; i < nr; i++) 1033 for (int i = 0; i < nr; i++)
1022 { 1034 {
1023 for (int j = col; j < lim; j++) 1035 for (int j = col; j < lim; j++)
1024 { 1036 {
1159 { 1171 {
1160 for (int col = 0; col < nc; col += inc) 1172 for (int col = 0; col < nc; col += inc)
1161 { 1173 {
1162 int lim = col + inc < nc ? col + inc : nc; 1174 int lim = col + inc < nc ? col + inc : nc;
1163 1175
1164 if (total_width > max_width && user_pref.split_long_rows) 1176 pr_col_num_header (os, total_width, max_width, lim, col);
1165 {
1166 if (col != 0)
1167 os << "\n";
1168
1169 int num_cols = lim - col;
1170 if (num_cols == 1)
1171 os << " Column " << col + 1 << ":\n\n";
1172 else if (num_cols == 2)
1173 os << " Columns " << col + 1 << " and " << lim
1174 << ":\n\n";
1175 else
1176 os << " Columns " << col + 1 << " through " << lim
1177 << ":\n\n";
1178 }
1179 1177
1180 for (int i = 0; i < nr; i++) 1178 for (int i = 0; i < nr; i++)
1181 { 1179 {
1182 for (int j = col; j < lim; j++) 1180 for (int j = col; j < lim; j++)
1183 { 1181 {
1263 int col = 0; 1261 int col = 0;
1264 while (col < num_elem) 1262 while (col < num_elem)
1265 { 1263 {
1266 int lim = col + inc < num_elem ? col + inc : num_elem; 1264 int lim = col + inc < num_elem ? col + inc : num_elem;
1267 1265
1268 if (total_width > max_width && user_pref.split_long_rows) 1266 pr_col_num_header (os, total_width, max_width, lim, col);
1269 {
1270 if (col != 0)
1271 os << "\n";
1272
1273 int num_cols = lim - col;
1274 if (num_cols == 1)
1275 os << " Column " << col + 1 << ":\n\n";
1276 else if (num_cols == 2)
1277 os << " Columns " << col + 1 << " and " << lim
1278 << ":\n\n";
1279 else
1280 os << " Columns " << col + 1 << " through " << lim
1281 << ":\n\n";
1282 }
1283 1267
1284 for (int i = col; i < lim; i++) 1268 for (int i = col; i < lim; i++)
1285 { 1269 {
1286 double val = base + i * increment; 1270 double val = base + i * increment;
1287 os << " "; 1271 os << " ";
1416 { 1400 {
1417 init_format_state (); 1401 init_format_state ();
1418 free_format = 1; 1402 free_format = 1;
1419 } 1403 }
1420 else if (strcmp (*argv, "compact") == 0) 1404 else if (strcmp (*argv, "compact") == 0)
1421 error ("format: format state `compact' not implemented yet"); 1405 {
1406 compact_format = 1;
1407 }
1422 else if (strcmp (*argv, "loose") == 0) 1408 else if (strcmp (*argv, "loose") == 0)
1423 error ("format: format state `loose' not implemented yet"); 1409 {
1410 compact_format = 0;
1411 }
1424 else 1412 else
1425 error ("format: unrecognized format state `%s'", *argv); 1413 error ("format: unrecognized format state `%s'", *argv);
1426 } 1414 }
1427 else 1415 else
1428 usage ("format [format_state]"); 1416 usage ("format [format_state]");