diff options
Diffstat (limited to 'draw.c')
-rw-r--r-- | draw.c | 185 |
1 files changed, 84 insertions, 101 deletions
@@ -33,118 +33,101 @@ int scale_factor; #define BITS_TOP_0 (BASE_BITS_TOP_0 * scale_factor) #define BITS_BOT_0 (BASE_BITS_BOT_0 * scale_factor) -void -redraw_chars() -{ - int i; - for (i=0; i<15; i++) - { - XCopyArea(display, chars, window, gc, - shown_offsets[i], 0, CHAR_WIDTH, CHAR_HEIGHT, - CHARS_LEFT+BITS_TOP_1*i, CHARS_TOP); - } +void redraw_chars() { + int i; + for(i = 0; i < 15; i++) { + XCopyArea(display, chars, window, gc, + shown_offsets[i], 0, CHAR_WIDTH, CHAR_HEIGHT, + CHARS_LEFT + BITS_TOP_1 * i, CHARS_TOP); + } } -void -redraw() -{ - XCopyArea(display, face, window, gc, 0, 0, widths[winsize], heights[winsize], 0, 0); +void redraw() { + XCopyArea(display, face, window, gc, 0, 0, widths[winsize], + heights[winsize], 0, 0); - if (show_bits) - { - int i, x; - XSetForeground(display, gc, bit_off); - for (i=0; i<32; i++) - { - x = BITS_LEFT_X - (BITS_TOP_1/3)*i - (BITS_TOP_1)/2*(i/4); - if (!(shown_bitmask & (1<<i))) - XDrawLine(display, window, gc, x, BITS_TOP_0, x, BITS_BOT_0); - } - XSetForeground(display, gc, bit_on); - for (i=0; i<32; i++) - { - x = BITS_LEFT_X - scale_factor*2*i - scale_factor*3*(i/4); - if (shown_bitmask & (1<<i)) - XDrawLine(display, window, gc, x, BITS_TOP_1, x, BITS_BOT_1); - } - } - else - redraw_chars(); + if(show_bits) { + int i, x; + XSetForeground(display, gc, bit_off); + for(i = 0; i < 32; i++) { + x = BITS_LEFT_X - (BITS_TOP_1 / 3) * i - + (BITS_TOP_1) / 2 * (i / 4); + if(!(shown_bitmask & (1 << i))) + XDrawLine(display, window, gc, x, BITS_TOP_0, x, + BITS_BOT_0); + } + XSetForeground(display, gc, bit_on); + for(i = 0; i < 32; i++) { + x = BITS_LEFT_X - scale_factor * 2 * i - + scale_factor * 3 * (i / 4); + if(shown_bitmask & (1 << i)) + XDrawLine(display, window, gc, x, BITS_TOP_1, x, + BITS_BOT_1); + } + } else + redraw_chars(); } -void -set_bits(int b) -{ - shown_bitmask = b; - show_bits = 1; - redraw(); +void set_bits(int b) { + shown_bitmask = b; + show_bits = 1; + redraw(); } -void -set_string(char *s) -{ - char tmp[16]; - int i; - sprintf(tmp, "%15.15s", s); - for (i=0; i<15; i++) - shown_offsets[i] = char_to_x[(int)tmp[i]]; - if (show_bits == 0) - redraw_chars(); - else - { - show_bits = 0; - redraw(); - } +void set_string(char *s) { + char tmp[16]; + int i; + sprintf(tmp, "%15.15s", s); + for(i = 0; i < 15; i++) + shown_offsets[i] = char_to_x[(int)tmp[i]]; + if(show_bits == 0) + redraw_chars(); + else { + show_bits = 0; + redraw(); + } } -void -send_current_display() -{ - char tmp[40], *tp=tmp; - int i; - XEvent e; +void send_current_display() { + char tmp[40], *tp = tmp; + int i; + XEvent e; - if (show_bits) - { - for (i=31; i>0; i--) - if (shown_bitmask & (1<<i)) - break; - for (; i>=0; i--) - { - if (shown_bitmask & (1<<i)) - *tp++ = '1'; - else - *tp++ = '0'; - } - } - else - { - for (i=0; i<15; i++) - { - char c = charmap[shown_offsets[i]/BITS_TOP_1]; - if (c != ' ' && c != ',') - *tp++ = c; - } - } + if(show_bits) { + for(i = 31; i > 0; i--) + if(shown_bitmask & (1 << i)) + break; + for(; i >= 0; i--) { + if(shown_bitmask & (1 << i)) + *tp++ = '1'; + else + *tp++ = '0'; + } + } else { + for(i = 0; i < 15; i++) { + char c = charmap[shown_offsets[i] / BITS_TOP_1]; + if(c != ' ' && c != ',') + *tp++ = c; + } + } - *tp = 0; + *tp = 0; - e.type = SelectionNotify; - e.xselection.display = display; - e.xselection.requestor = event.xselectionrequest.requestor; - e.xselection.selection = event.xselectionrequest.selection; - e.xselection.target = event.xselectionrequest.target; - e.xselection.property = event.xselectionrequest.property; - e.xselection.time = event.xselectionrequest.time; + e.type = SelectionNotify; + e.xselection.display = display; + e.xselection.requestor = event.xselectionrequest.requestor; + e.xselection.selection = event.xselectionrequest.selection; + e.xselection.target = event.xselectionrequest.target; + e.xselection.property = event.xselectionrequest.property; + e.xselection.time = event.xselectionrequest.time; - if (event.xselectionrequest.target != XA_STRING) - { - e.xselection.property = None; - } - else - { - XChangeProperty(display, e.xselection.requestor, e.xselection.property, - XA_STRING, 8, PropModeReplace, (unsigned char *)tmp, strlen(tmp)); - } - XSendEvent(display, e.xselection.requestor, False, 0, &e); + if(event.xselectionrequest.target != XA_STRING) { + e.xselection.property = None; + } else { + XChangeProperty(display, e.xselection.requestor, + e.xselection.property, XA_STRING, 8, + PropModeReplace, (unsigned char *)tmp, + strlen(tmp)); + } + XSendEvent(display, e.xselection.requestor, False, 0, &e); } |