This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #include <config.h>
19
20 #include <textstyle.h>
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <unistd.h>
26
27 int
28 main (int argc, char *argv[])
29 {
30 const char *program_name = argv[0];
31 int i;
32
33
34 for (i = 1; i < argc; i++)
35 {
36 const char *arg = argv[i];
37 if (strncmp (arg, "--color=", 8) == 0)
38 handle_color_option (arg + 8);
39 else if (strncmp (arg, "--style=", 8) == 0)
40 handle_style_option (arg + 8);
41 else if (arg[0] == '-')
42 {
43 fprintf (stderr, "%s: invalid argument: %s\n", program_name, arg);
44 exit (1);
45 }
46 else
47
48 ;
49 }
50
51
52 if (color_test_mode)
53 {
54 print_color_test ();
55 exit (0);
56 }
57
58 #if HAVE_LIBTEXTSTYLE
59 if (color_mode == color_yes
60 || (color_mode == color_tty
61 && isatty (STDOUT_FILENO)
62 && getenv ("NO_COLOR") == NULL)
63 || color_mode == color_html)
64 {
65
66
67 if (style_file_name == NULL)
68 style_file_name = SRCDIR "test-libtextstyle-default.css";
69 }
70 else
71
72 style_file_name = NULL;
73 #endif
74
75
76 styled_ostream_t stream =
77 (color_mode == color_html
78 ? html_styled_ostream_create (file_ostream_create (stdout),
79 style_file_name)
80 : styled_ostream_create (STDOUT_FILENO, "(stdout)", TTYCTL_AUTO,
81 style_file_name));
82
83 ostream_write_str (stream, "Hello ");
84
85
86 styled_ostream_begin_use_class (stream, "name");
87
88 ostream_write_str (stream, "Dr. ");
89 styled_ostream_begin_use_class (stream, "boy-name");
90 ostream_write_str (stream, "Linus");
91 styled_ostream_end_use_class (stream, "boy-name");
92 ostream_write_str (stream, " Pauling");
93
94
95 styled_ostream_end_use_class (stream, "name");
96
97 ostream_write_str (stream, "!\n");
98
99
100 styled_ostream_free (stream);
101
102 return 0;
103 }