diff -ur ratpoison/src/actions.c ratpoison-license/src/actions.c --- ratpoison/src/actions.c Fri Oct 19 00:47:45 2001 +++ ratpoison-license/src/actions.c Sat Oct 27 04:16:54 2001 @@ -17,6 +17,7 @@ * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA */ + #include #include @@ -49,6 +50,7 @@ {"focuslast", cmd_focuslast, arg_VOID}, {"meta", cmd_meta, arg_STRING}, {"help", cmd_help, arg_VOID}, + {"license", cmd_license, arg_VOID}, {"hsplit", cmd_h_split, arg_VOID}, {"kill", cmd_kill, arg_VOID}, {"redisplay", cmd_redisplay, arg_VOID}, @@ -103,7 +105,6 @@ implemented. See the screen documentation for what should be emulated with these commands */ #if 0 - {"license", cmd_unimplemented, arg_VOID}, {"msgminwait", cmd_unimplemented, arg_VOID}, {"nethack", cmd_unimplemented, arg_VOID}, {"sleep", cmd_unimplemented, arg_VOID}, @@ -308,6 +309,7 @@ add_keybinding (XK_f, 0, "curframe"); add_keybinding (XK_f, RP_CONTROL_MASK, "curframe"); add_keybinding (XK_question, 0, "help"); + add_keybinding (XK_comma, 0, "license"); } /* return a KeySym from a string that contains either a hex value or @@ -1316,6 +1318,95 @@ } } } + + XMaskEvent (dpy, KeyPressMask, &ev); + XUnmapWindow (dpy, s->help_window); + XSetInputFocus (dpy, fwin, revert, CurrentTime); + + return NULL; +} + + +char * +cmd_license (int interactive, void *data) +{ + screen_info *s = current_screen(); + XEvent ev; + Window fwin; /* Window currently in focus */ + int revert; + int x = 10; + int y = 10; + char *row; + int rowlength; + int text_offset = 0; + int newline; + char *license_text = \ + + PACKAGE " version " VERSION "\n" \ + "\n" \ + "Copyright (C) 2000, 2001 Shawn Betts\n" \ + "\n" \ + "ratpoison is free software; you can redistribute it and/or modify " \ + "it under the terms of the GNU General Public License as published by " \ + "the Free Software Foundation; either version 2, or (at your option) " \ + "any later version.\n" \ + "\n" \ + "ratpoison is distributed in the hope that it will be useful, " \ + "but WITHOUT ANY WARRANTY; without even the implied warranty of " \ + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " \ + "GNU General Public License for more details.\n" \ + "\n" \ + "You should have received a copy of the GNU General Public License " \ + "along with this software; see the file COPYING. If not, write to " \ + "the Free Software Foundation, Inc., 59 Temple Place, Suite 330, " \ + "Boston, MA 02111-1307 USA\n" \ + "\n" \ + "Send bugreports, fixes, enhancements, t-shirts, money, beer & pizza " \ + "to address@hidden or visit " \ + "http://ratpoison.sourceforge.net/\n" \ + "\n" \ + "[Press any key to end.] " \ + ; + + XMapRaised (dpy, s->help_window); + + XGetInputFocus (dpy, &fwin, &revert); + XSetInputFocus (dpy, s->help_window, RevertToPointerRoot, CurrentTime); + + rowlength = (s->root_attr.width - 2 * x) / XTextWidth (defaults.font, " ", 1); + + row = xmalloc (rowlength + 1); + + for(text_offset = 0; text_offset < strlen(license_text); text_offset++) + { + if(!strncpy(row, license_text + text_offset, rowlength)) + return -1; + + row[rowlength] = '\0'; + + if((newline = strchr(row, '\n'))) + { + newline -= (int) row; /* FIXME this generates an ugly warning, i don't know how to fix it */ + row[newline] = '\0'; + text_offset += newline; + } + else if ((newline = strrchr(row, ' '))) + { + newline -= (int) row; /* FIXME this generates an ugly warning, i don't know how to fix it */ + row[newline] = '\0'; + text_offset += newline; + } + else + text_offset += rowlength - 1; + + XDrawString (dpy, s->help_window, s->normal_gc, + x, y + defaults.font->max_bounds.ascent, + row, strlen (row)); + + y += FONT_HEIGHT (defaults.font); + } + + free(row); XMaskEvent (dpy, KeyPressMask, &ev); XUnmapWindow (dpy, s->help_window); diff -ur ratpoison/src/actions.h ratpoison-license/src/actions.h --- ratpoison/src/actions.h Fri Oct 19 00:47:45 2001 +++ ratpoison-license/src/actions.h Sat Oct 27 02:59:59 2001 @@ -71,6 +71,7 @@ char * cmd_banish (int interactive, void *data); char * cmd_curframe (int interactive, void *data); char * cmd_help (int interactive, void *data); +char * cmd_license (int interactive, void *data); char * cmd_quit(int interactive, void *data); char * cmd_number (int interactive, void *data); char * cmd_rudeness (int interactive, void *data);