All pastes #1997227 Raw Edit

delete.patch

public diff v1 · immutable
#1997227 ·published 2010-11-20 17:28 UTC
rendered paste body
diff -urN delete/Makefile new/delete/Makefile--- delete/Makefile	1970-01-01 09:00:00.000000000 +0900+++ new/delete/Makefile	2010-11-21 02:20:51.000000000 +0900@@ -0,0 +1,18 @@+INCLUDES = -L/usr/X11R6/lib -I/usr/X11R6/include+LIBS = -lX11 -lm+CFLAGS = -Wall -O2+CC = gcc++OBJS = main.o function.o++delete	: $(OBJS)+	$(CC) -o delete $(CFLAGS) $(INCLUDES) main.o function.o $(LIBS)++main.o	: main.c+	$(CC) $(CFLAGS) $(INCLUDES) -c main.c++function.o	: function.c+	$(CC) $(CFLAGS) $(INCLUDES) -c function.c++clean	:+	rm -f $(OBJS) delete *.corediff -urN delete/common.h new/delete/common.h--- delete/common.h	1970-01-01 09:00:00.000000000 +0900+++ new/delete/common.h	2010-11-21 02:20:51.000000000 +0900@@ -0,0 +1,12 @@+#include	<stdio.h>+#include	<stdlib.h>+#include	<string.h>+#include	<X11/Xlib.h>+#include	<X11/Xutil.h>+#include <locale.h>++Display *disp;+Window  rw;+GC      rgc;+//Font    font;+XFontSet fontset;diff -urN delete/function.c new/delete/function.c--- delete/function.c	1970-01-01 09:00:00.000000000 +0900+++ new/delete/function.c	2010-11-21 02:20:51.000000000 +0900@@ -0,0 +1,33 @@+#include	"common.h"++#define LINE_SEP   2+#define STRING_SEP 6++void delete(char *string)+{+    XColor def, closest;+    int	x, y, width, height;+    XRectangle ink, logical;+    +    XAllocNamedColor(disp, DefaultColormap(disp, 0),+		     "black", &closest, &def);+    XSetForeground(disp, rgc, closest.pixel);++    XSetSubwindowMode(disp, rgc, IncludeInferiors);++    width  = DisplayWidth(disp, 0);+    height = DisplayHeight(disp, 0);++    if(string == NULL) string = "delete";++    XmbTextExtents(fontset, string, strlen(string), &ink, &logical);+    +    for(y=0; y<height; y+=logical.height+LINE_SEP){+	for(x=0; x<width; x+=logical.width+STRING_SEP){+//	    XDrawString(disp, rw, rgc, x, y, string,+//			strlen(string));+	    XmbDrawString(disp, rw, fontset, rgc, x, y, string,+			  strlen(string));+	}+    }+}diff -urN delete/main.c new/delete/main.c--- delete/main.c	1970-01-01 09:00:00.000000000 +0900+++ new/delete/main.c	2010-11-21 02:20:51.000000000 +0900@@ -0,0 +1,34 @@+#include	"common.h"++void delete();++int+main(int argc, char *argv[])+{+    char **ml;+    int mc;+    char *ds;++    setlocale(LC_CTYPE, "");+    +    disp = XOpenDisplay(NULL);+    +    rw = RootWindow(disp, DefaultScreen(disp));++    rgc = XCreateGC(disp, rw, 0, NULL);++//    font = XLoadFont(disp, argv[1]);+//    XSetFont(disp, rgc, font);++    fontset = XCreateFontSet(disp, "fixed,k14", &ml, &mc, &ds);+    +    delete(argv[1]);++    XFreeFontSet(disp, fontset);+//    XUnloadFont(disp, font);+    XFreeGC(disp, rgc);++    XCloseDisplay(disp);++    exit(0);+}