w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

putc.c (1028B)


      1 
      2 #include "wc.h"
      3 #include "wtf.h"
      4 
      5 static wc_status putc_st;
      6 static wc_ces putc_f_ces, putc_t_ces;
      7 static Str putc_str;
      8 
      9 void
     10 wc_putc_init(wc_ces f_ces, wc_ces t_ces)
     11 {
     12     wc_output_init(t_ces, &putc_st);
     13     putc_str = Strnew_size(8);
     14     putc_f_ces = f_ces;
     15     putc_t_ces = t_ces;
     16 }
     17 
     18 void
     19 wc_putc(char *c, FILE *f)
     20 {
     21     wc_uchar *p;
     22 
     23     if (putc_f_ces != WC_CES_WTF)
     24 	p = (wc_uchar *)wc_conv(c, putc_f_ces, WC_CES_WTF)->ptr;
     25     else
     26 	p = (wc_uchar *)c;
     27 
     28     Strclear(putc_str);
     29     while (*p)
     30 	(*putc_st.ces_info->push_to)(putc_str, wtf_parse(&p), &putc_st);
     31     fwrite(putc_str->ptr, 1, putc_str->length, f);
     32 }
     33 
     34 void
     35 wc_putc_end(FILE *f)
     36 {
     37     Strclear(putc_str);
     38     wc_push_end(putc_str, &putc_st);
     39     if (putc_str->length)
     40 	fwrite(putc_str->ptr, 1, putc_str->length, f);
     41 }
     42 
     43 void
     44 wc_putc_clear_status(void)
     45 {
     46     if (putc_st.ces_info->id & WC_CES_T_ISO_2022) {
     47 	putc_st.gl = 0;
     48 	putc_st.gr = 0;
     49 	putc_st.ss = 0;
     50 	putc_st.design[0] = 0;
     51 	putc_st.design[1] = 0;
     52 	putc_st.design[2] = 0;
     53 	putc_st.design[3] = 0;
     54     }
     55 }
     56