wmcalclockkbd: Move variable definitions from xutil.h -> xutil.c
[dockapps.git] / wmjmail / src / jDockApp / jprintf.c
blob6aee482a4c8f4615c89643681e0e9912b281966b
1 #include <stdarg.h>
2 #include "jDockApp.h"
4 #define char_width 5
5 #define char_height 7
7 #define left_edge 5
8 #define right_edge 59
9 #define top_edge 6
10 #define stop_edge 12
12 #define num_start 85
13 #define Letter_start 135
14 #define letter_start 400
16 #define cc(X, Y, Z) case X: copy_start = Y; copy_width = Z; break
17 #define cw(X, Y) case X: copy_width = Y; break
19 int start_x;
20 int start_y;
21 int line_position;
23 void jprintf_internal(int, const char*);
25 void jpprintf(int x, int y, int color, const char *format, ...) {
26 va_list arguments;
27 char line[80];
29 if(y<=5 && y>=1) {
30 start_y = stop_edge + y * char_height + y-1;
31 } else if ( !y ) {
32 start_y = top_edge;
33 } else {
34 printf("You can't jprintf to line %i.\n", y);
35 printf(" The range is currently: 0-6.\n");
36 exit(1);
39 start_x = left_edge+1 + x * char_width;
40 line_position = 0;
42 va_start(arguments, format);
43 vsnprintf(line, 80, format, arguments);
44 va_end(arguments);
46 jprintf_internal(color, line);
49 void jprintf(int color, const char *format, ...) {
50 va_list arguments;
51 char line[80];
53 va_start(arguments, format);
54 vsnprintf(line, 80, format, arguments);
55 va_end(arguments);
57 jprintf_internal(color, line);
60 void jprintf_internal(int color, const char *line) {
61 char cur_char;
62 int string_position;
63 int copy_start;
64 int copy_width;
66 if(!start_x) {
67 printf("You must make at least one call to jpprintf()\n");
68 exit(1);
71 string_position = 0;
73 while(line[string_position] != '\0') {
74 cur_char = line[string_position];
75 copy_start = 0;
76 copy_width = char_width;
78 if(cur_char>='0' && cur_char<='9') {
79 copy_start = (cur_char-'0')*char_width+num_start;
81 else if(cur_char>='A' && cur_char<='Z') {
82 copy_start = (cur_char-'A')*char_width+Letter_start;
84 else if(cur_char>='a' && cur_char<='z') {
85 copy_start = (cur_char-'a')*char_width+letter_start;
88 switch(cur_char) {
89 cw('l', 4);
90 cw('T', 4);
91 cw('I', 4);
92 cw('1', 4);
93 cw('Y', 4);
94 cw('c', 4);
95 cw('0', 4);
96 cw('i', 4);
97 cw('v', 4);
98 cw(' ', 3);
100 cc( '!', 267, 2);
101 cc( '@', 270, 5);
102 cc( '#', 275, 6);
103 cc( '$', 281, 6);
104 cc( '%', 287, 5);
105 cc( '^', 292, 4);
106 cc( '&', 296, 4);
107 cc( '*', 301, 4);
108 cc( '(', 306, 3);
109 cc( ')', 311, 3);
110 cc( '{', 315, 4);
111 cc( '}', 320, 4);
112 cc( '[', 325, 4);
113 cc( ']', 330, 4);
114 cc( '<', 335, 4);
115 cc( '>', 340, 4);
116 cc( '/', 345, 5);
117 cc('\\', 350, 5);
118 cc( '+', 355, 6);
119 cc( '-', 362, 3);
120 cc( '=', 365, 4);
121 cc( ':', 371, 2);
122 cc( ';', 375, 3);
123 cc( ',', 380, 3);
124 cc( '.', 386, 3);
125 cc('\'', 391, 3);
126 cc( '"', 396, 4);
129 if(start_x+line_position+char_width > right_edge)
130 break;
132 if(copy_start) copyXPMArea(
133 copy_start,
134 color,
135 copy_width,
136 char_height,
137 start_x+line_position,
138 start_y
141 line_position += copy_width;
142 string_position++;