[clean up trailing whitespace, clean up some formatting
John Meacham <john@repetae.net>**20050725120441] {
hunk ./xfttext.c 1
-#include <glib.h>
-#include <fontconfig/fontconfig.h>
-#include <Xfttext.h>
-
-typedef struct _XftPatternSet {
-   int num_patterns;
-   FcPattern **patterns;
-} XftPatternSet;
-
-typedef struct _CharProp {
-   int pattern_index; /* index of "patterns" */ 
-   int count_chars;   /* number of characters sharing the same pattern */
-} CharProp;
-
-static void
-XftFreePatternSet(XftPatternSet *set)
-{
-   int n;
-   
-   for (n=0; n < set->num_patterns; ++n)
-       FcPatternDestroy(set->patterns[n]);
-     
-    g_free(set->patterns);
-    g_free(set);
-}
-
-static XftPatternSet *
-XftCreatePatternSet(FcPattern *pattern)
-{
-   XftPatternSet *set;
-   FcFontSet     *font_patterns;
-   int f;
-   
-   font_patterns = FcFontSort(NULL, pattern, FcTrue, 0, NULL);
-   if (!font_patterns) return NULL;
- 
-   set = g_new0(XftPatternSet, 1);
-   set->patterns = g_new0(FcPattern *, font_patterns->nfont);
-   set->num_patterns = font_patterns->nfont;
-
-   for (f=0; f < font_patterns->nfont; f++)
-	set->patterns[f] = FcFontRenderPrepare(NULL, pattern, font_patterns->fonts[f]);
-    
-   FcFontSetDestroy(font_patterns);
-
-   return set;
-}
-   
-static int
-getFontIdx(FcChar32 ucs4, XftPatternSet *set)
-{
-   int n;
-   
-   for (n=0; n < set->num_patterns; ++n)
-     {
-       FcCharSet *charset;
-       FcPattern *pattern = set->patterns[n];
-	
-       if (FcPatternGetCharSet(pattern, FC_CHARSET, 0, &charset) != FcResultMatch)
-         return -1;
-
-       if (FcCharSetHasChar(charset, ucs4)) return n;
-     }
-	
-   return -1;
-}
-
-static CharProp *
-getCharProp(XftPatternSet *set, void *v, int count_chars, XftTextEncoding encoding)
-{
-    CharProp *charprop;
-    int i, position,prev_index;
-   
-    charprop = g_new0(CharProp, count_chars);
-    for (i = 0; i < count_chars; ++i)
-     {
-       gunichar ucs4;
-       
-       switch (encoding)
-	  {
-	  case String8:
-	     {
-		char *p = (char *)v;
-		ucs4 = (FcChar32)*p;
-		v = (void *)(p+1);
-	     }	     
-	     break;
-	  case String16:
-	     {
-		FcChar16 *p = (FcChar16 *)v;
-		ucs4 = (FcChar32)*p;
-		v = (void *)(p+1);
-	     }
-	     break;
-	  case String32:
-	     {
-		FcChar32 *p = (FcChar32 *)v;
-		ucs4 = *p;
-		v = (void *)(p+1);
-	     }	     
-	     break;
-	  case StringUtf8:
-	     {
-	        char *p = (char *)v;
-	        ucs4 = g_utf8_get_char(p);
-	        v = (void *)g_utf8_next_char(p);
-	      }
-	     break;
-	  case StringUtf16:
-	     // not implemented yet
-	     break;
-	  }
-	
-       charprop[i].pattern_index = getFontIdx(ucs4, set);
-     }
-   
-    position = 0;
-    prev_index = charprop[0].pattern_index;
-    for(i=1; i < count_chars; ++i)
-     {
-	if (charprop[i].pattern_index != prev_index)
-	  {
-	     charprop[position].count_chars = i - position;
-	     prev_index = charprop[i].pattern_index;
-	     position = i;
-	  }	
-     }   
-   charprop[position].count_chars = i - position;
-   
-   return charprop;
-}
-
-XftText *
-XftCreateText(Display *dpy, int scr, FcPattern *pattern, 
-	      void *v, int count_chars, XftTextEncoding encoding)
-{
-   XftPatternSet *set;
-   XftText *text;
-   CharProp *charprop;
-   int i, num_textitems = 0;
-   
-   set = XftCreatePatternSet(pattern);
-   charprop = getCharProp(set, v, count_chars, encoding);
-   
-   for(i=0; i<count_chars; ++i)
-       if (charprop[i].count_chars) ++num_textitems;
-   
-   text = g_new0(XftText, 1);
-   text->num_textitems = num_textitems;
-   text->textitems = g_new0(XftTextItem, num_textitems);
-   
-   num_textitems = 0;
-   for(i=0; i < count_chars; ++i)
-     {
-	if (charprop[i].count_chars)
-	  {
-	      FcPattern *match;
-	      FcResult result;
-	      XftTextItem *item = &text->textitems[num_textitems];
-
-	      item->encoding = encoding;
-	     
-	      switch (encoding)
-	       {
-		case String8:
-		  {
-		     char *string = (char *)v;
-		     item->text = g_strndup(string, count_chars);
-		  }
-		  break;
-		case String16:
-		  {
-		     FcChar16 *string = (FcChar16 *)v;
-
-		     item->text = g_new0(FcChar16, count_chars + 1);
-		     memcpy(item->text, string, count_chars * sizeof(FcChar16)/sizeof(char));
-		  }
-		  break;
-		case String32:
-		  {
-		     FcChar32 *string = (FcChar32 *)v;
-
-		     item->text = g_new0(FcChar32, count_chars + 1);
-		     memcpy(item->text, string, count_chars * sizeof(FcChar32)/sizeof(char));
-		  }
-		  break;
-		case StringUtf8:
-	          {
-		     char *string = (char *)v;
-	     	     char *start = (char *)g_utf8_offset_to_pointer(string, i);
-	             char *end = (char *)g_utf8_offset_to_pointer(string, i + charprop[i].count_chars);
-	    
-	             item->text = g_new0(char, end - start + 1);
-	             g_utf8_strncpy((char *)item->text, start, charprop[i].count_chars);
-	    	  } 
-		  break;
-		case StringUtf16:
-		  // not implemented yet
-		  break;
-	       }
-
-	     match = XftFontMatch(dpy, scr, 
-			set->patterns[charprop[i].pattern_index], &result);
-	     if (match) 
-		 {
-	     	    item->font = XftFontOpenPattern(dpy, match);
-		    FcPatternDestroy(match);
-		 }
-	       
-	     ++num_textitems;
-	  }
-     }   
-  
-   g_free(charprop);
-   XftFreePatternSet(set);
-   
-   return text;
-}
-
-void
-XftDrawText(XftDraw *draw, _Xconst XftColor *color, XftText *text, int x, int y)
-{
-   int i, xx = x, yy = y;
-   
-   for(i=0; i < text->num_textitems; ++i)
-     {
-	XftFont *font;
-	Display *dpy = XftDrawDisplay(draw);
-	XGlyphInfo extents;
-	int len;
-	
-	font = text->textitems[i].font;
-	switch (text->textitems[i].encoding)
-	  {
-	   case String8:
-	     {
-		char *string = (char *)text->textitems[i].text;
-		
-		len = strlen(string);
-		XftDrawString8(draw, color, font, xx, yy, string, len);
-		XftTextExtentsUtf8(dpy, font, string, len, &extents);
-	     }
-	     break;
-	   case String16:
-	     {
-		FcChar16 *string = (FcChar16 *)text->textitems[i].text;
-
-		len = 0;
-		while (string[len] != (FcChar16)0) ++len;
-		
-		XftDrawString16(draw, color, font, xx, yy, string, len);
-		XftTextExtents16(dpy, font, string, len, &extents);
-	     }
-	     break;
-	   case String32:
-	     {
-		FcChar32 *string = (FcChar32 *)text->textitems[i].text;
-
-		len = 0;
-		while (string[len] != (FcChar32)0) ++len;
-		
-		XftDrawString32(draw, color, font, xx, yy, string, len);
-		XftTextExtents32(dpy, font, string, len, &extents);
-	     }
-	     break;
-	   case StringUtf8:
-	     {
-		char *string = (char *)text->textitems[i].text;
-		
-		len = strlen(string);
-		
-		XftDrawStringUtf8(draw, color, font, xx, yy, string, len);
-		XftTextExtentsUtf8(dpy, font, string, len, &extents);
-	     }
-	     break;
-	   case StringUtf16:
-	     // not implemented yet
-	     break;
-	  }
-	
-	xx += extents.xOff;
-     }
-}
-
-void
-XftFreeText(Display *dpy, XftText *text)
-{
-   int i;
-   
-   if (!text) return;
-   
-   for (i=0; i < text->num_textitems; ++i)
-     {
-	XftTextItem textitem = text->textitems[i];
-	
-	if (textitem.text) g_free(textitem.text);
-	XftFontClose(dpy, textitem.font);
-     }
-   
-   g_free(text->textitems);
-   g_free(text);
-}
-
---------------89A6484203A15FCE7F7A254B
-Content-Type: text/plain; charset=gb2312;
- name="Xfttext.h"
-Content-Transfer-Encoding: 7bit
-Content-Disposition: inline;
- filename="Xfttext.h"
-
-#ifndef _Xfttext_H_
-#define _Xfttext_H_
-
-#include <X11/Xlib.h>
-#include <X11/Xft/Xft.h>
-#include <X11/Xft/XftCompat.h>
-
-typedef enum {String8, String16, String32, StringUtf8, StringUtf16 } XftTextEncoding;
-
-typedef struct _XftTextItem {
-   XftFont         *font;
-   void            *text;
-   XftTextEncoding encoding; /* specify the encoding of 'text' */
-} XftTextItem;
-
-typedef struct _XftText {   
-   int         num_textitems;
-   XftTextItem *textitems;
-} XftText;
-
-extern XftText *XftCreateText(Display *, int, FcPattern *, void *, int, XftTextEncoding);
-extern void XftDrawText(XftDraw *, _Xconst XftColor *, XftText *, int, int);
-extern void XftFreeText(Display *dpy, XftText *);
-
-#endif
rmfile ./xfttext.c
hunk ./colors.c 15
-static void 
+static void
hunk ./colors.c 33
-        for(;c; c = c->next) 
+        for(;c; c = c->next)
hunk ./colors.c 52
-void 
+void
hunk ./colors.c 56
-        for(;c; c = c->next) 
+        for(;c; c = c->next)
hunk ./emulator.c 1102
-static void 
+static void
hunk ./emulator.c 1144
-        for(int i = 0; i < 4; i++) 
+        for(int i = 0; i < 4; i++)
hunk ./emulator.c 1147
-        for(int i = 0; i < e->cols; i++) 
-                if(test_bit(e->tabs,i)) 
+        for(int i = 0; i < e->cols; i++)
+                if(test_bit(e->tabs,i))
hunk ./gendefs.prl 15
-static void 
-parse_bool(const char *s, bool *b) 
+static void
+parse_bool(const char *s, bool *b)
hunk ./gendefs.prl 19
-    *b = (strcasecmp(\"no\",s) && strcasecmp(\"false\", s)); 
+    *b = (strcasecmp(\"no\",s) && strcasecmp(\"false\", s));
hunk ./gendefs.prl 29
-    while(n >= 0 && isspace(s[n])) s[n--] = '\\0';  
+    while(n >= 0 && isspace(s[n])) s[n--] = '\\0';
hunk ./gendefs.prl 58
-    $cg->fun("setup_defaults","if(tmp) D_$1 = chomp(tmp);"); 
-    $cg->fun("defaults_print","printf(\"uterm.$1: %s\\n\", D_$1);"); 
+    $cg->fun("setup_defaults","if(tmp) D_$1 = chomp(tmp);");
+    $cg->fun("defaults_print","printf(\"uterm.$1: %s\\n\", D_$1);");
hunk ./gendefs.prl 65
-    } 
+    }
hunk ./keysym2ucs.c 39
-  
+
hunk ./multigraph.c 1
- 
+
hunk ./multigraph.c 9
-int 
-compare_mgraph_exact(const void *a, const void *b) 
+int
+compare_mgraph_exact(const void *a, const void *b)
hunk ./multigraph.c 17
-int 
-compare_mgraph_substr(const void *a, const void *b) 
+int
+compare_mgraph_substr(const void *a, const void *b)
hunk ./multigraph.h 14
-int compare_mgraph_exact(const void *a, const void *b); 
+int compare_mgraph_exact(const void *a, const void *b);
hunk ./print_event.c 323
-    printf ("    (%d,%d), override %s\n", e->x, e->y, 
+    printf ("    (%d,%d), override %s\n", e->x, e->y,
hunk ./pty-outfifo.c 22
-on_writeable(oop_source *source, int fd, oop_event event, void *_pty) 
+on_writeable(oop_source *source, int fd, oop_event event, void *_pty)
hunk ./pty-outfifo.c 29
-                        if(errno == EINTR) 
+                        if(errno == EINTR)
hunk ./pty-outfifo.c 50
-        if(FIFO_EMPTY(out_fifo)) 
+        if(FIFO_EMPTY(out_fifo))
hunk ./pty-outfifo.c 55
-void 
+void
hunk ./resizeable_buf.c 20
-		while (sz > rb->size) rb->size*=2; 
+		while (sz > rb->size) rb->size*=2;
hunk ./resizeable_buf.c 32
-void 
+void
hunk ./resizeable_buf.c 41
-void 
+void
hunk ./resizeable_buf.c 133
-void 
+void
hunk ./resizeable_buf.c 139
-                memmove(fifo->rb.buf, fifo->rb.buf + fifo->offset, FIFO_LEN(*fifo)); 
+                memmove(fifo->rb.buf, fifo->rb.buf + fifo->offset, FIFO_LEN(*fifo));
hunk ./resizeable_buf.h 16
-}; 
+};
hunk ./seven.c 765
-        XResizeWindow(conn->dpy, win.w, fw*80, fh*25); 
+        XResizeWindow(conn->dpy, win.w, fw*80, fh*25);
hunk ./seven_client.c 17
-/* arch-tag: 85b95cb3-e43d-4f92-b7d4-9edc68c807e8 */
-
hunk ./seven_client.c 40
-        POPT_TABLEEND 
+        POPT_TABLEEND
hunk ./seven_client.c 49
-        POPT_TABLEEND 
+        POPT_TABLEEND
hunk ./seven_client.c 56
-        POPT_TABLEEND 
+        POPT_TABLEEND
hunk ./seven_client.c 77
-                if(ret == -1) 
+                if(ret == -1)
hunk ./seven_client.c 98
-                        sevens_found++; 
+                        sevens_found++;
hunk ./seven_client.c 102
-                        sevens_found++; 
+                        sevens_found++;
hunk ./seven_client.c 108
-                        sevens_found++; 
+                        sevens_found++;
hunk ./seven_client.c 118
-{        
+{
hunk ./seven_client.c 122
-        else 
+        else
hunk ./seven_client.c 124
-        
+
hunk ./seven_client.c 134
-static int 
+static int
hunk ./seven_client.c 144
-                if(si->connections.connections_len) {   
+                if(si->connections.connections_len) {
hunk ./seven_client.c 156
-        } 
+        }
hunk ./seven_client.c 222
-                                POPT_AUTOHELP 
-                                POPT_TABLEEND 
+                                POPT_AUTOHELP
+                                POPT_TABLEEND
hunk ./seven_client.c 247
-                } 
+                }
hunk ./seven_client.c 260
-        
+
hunk ./seven_client.c 262
-                printf("%6.6s - %s\n",cfuncs[i].name, cfuncs[i].desc); 
+                printf("%6.6s - %s\n",cfuncs[i].name, cfuncs[i].desc);
hunk ./seven_client.h 4
-/* arch-tag: 677a561e-8a95-4d3f-8eeb-f677a0bf95ec */
-
hunk ./stty_print.c 102
-        char buf1[100], buf2[100];
+        char buf1[100];
hunk ./unicode.c 2
-/* arch-tag: 091ef160-e1ff-4114-ade8-89163904a7cd */
hunk ./unicode.c 32
-  
+
hunk ./unicode.c 90
-  
+
hunk ./unicode.c 93
-  
+
hunk ./unix.c 99
-        stty_print(&pty->termios, &pty->winsize); 
+        stty_print(&pty->termios, &pty->winsize);
}
