comparison finch/libgnt/gntwm.c @ 21680:65f2a29617a2

Fix cursor-next-word behaviour, noticed by jtb. Change dump-screen binding to M-D (and have it use a file req dialog) to give delete-next-word a say in things.
author Richard Nelson <wabz@pidgin.im>
date Wed, 28 Nov 2007 03:51:18 +0000
parents 55146766c91d
children 48bdb5b2e35b
comparison
equal deleted inserted replaced
21679:a312781708e8 21680:65f2a29617a2
26 #endif 26 #endif
27 27
28 #include "config.h" 28 #include "config.h"
29 29
30 #include <glib.h> 30 #include <glib.h>
31 #include <glib/gstdio.h>
31 #include <ctype.h> 32 #include <ctype.h>
32 #include <gmodule.h> 33 #include <gmodule.h>
33 #include <stdlib.h> 34 #include <stdlib.h>
34 #include <string.h> 35 #include <string.h>
35 #include <time.h> 36 #include <time.h>
39 #include "gntmarshal.h" 40 #include "gntmarshal.h"
40 #include "gnt.h" 41 #include "gnt.h"
41 #include "gntbox.h" 42 #include "gntbox.h"
42 #include "gntbutton.h" 43 #include "gntbutton.h"
43 #include "gntentry.h" 44 #include "gntentry.h"
45 #include "gntfilesel.h"
44 #include "gntlabel.h" 46 #include "gntlabel.h"
45 #include "gntmenu.h" 47 #include "gntmenu.h"
46 #include "gnttextview.h" 48 #include "gnttextview.h"
47 #include "gnttree.h" 49 #include "gnttree.h"
48 #include "gntutils.h" 50 #include "gntutils.h"
661 list_of_windows(wm, FALSE); 663 list_of_windows(wm, FALSE);
662 664
663 return TRUE; 665 return TRUE;
664 } 666 }
665 667
666 static gboolean 668 static void
667 dump_screen(GntBindable *bindable, GList *null) 669 dump_file_save(GntFileSel *fs, const char *path, const char *f, gpointer n)
668 { 670 {
671 FILE *file;
669 int x, y; 672 int x, y;
670 chtype old = 0, now = 0; 673 chtype old = 0, now = 0;
671 FILE *file = fopen("dump.html", "w");
672 struct { 674 struct {
673 char ascii; 675 char ascii;
674 char *unicode; 676 char *unicode;
675 } unis[] = { 677 } unis[] = {
676 {'q', "&#x2500;"}, 678 {'q', "&#x2500;"},
687 {'n', "&#x253c;"}, 689 {'n', "&#x253c;"},
688 {'w', "&#x252c;"}, 690 {'w', "&#x252c;"},
689 {'v', "&#x2534;"}, 691 {'v', "&#x2534;"},
690 {'\0', NULL} 692 {'\0', NULL}
691 }; 693 };
694
695
696 if ((file = g_fopen(path, "w+")) == NULL) {
697 return;
698 }
692 699
693 fprintf(file, "<head>\n <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n</head>\n<body>\n"); 700 fprintf(file, "<head>\n <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n</head>\n<body>\n");
694 fprintf(file, "<pre>"); 701 fprintf(file, "<pre>");
695 for (y = 0; y < getmaxy(stdscr); y++) { 702 for (y = 0; y < getmaxy(stdscr); y++) {
696 for (x = 0; x < getmaxx(stdscr); x++) { 703 for (x = 0; x < getmaxx(stdscr); x++) {
794 fprintf(file, "</span>\n"); 801 fprintf(file, "</span>\n");
795 old = 0; 802 old = 0;
796 } 803 }
797 fprintf(file, "</pre>\n</body>"); 804 fprintf(file, "</pre>\n</body>");
798 fclose(file); 805 fclose(file);
806 gnt_widget_destroy(GNT_WIDGET(fs));
807 }
808
809 static void
810 dump_file_cancel(GntWidget *w, GntFileSel *fs)
811 {
812 gnt_widget_destroy(GNT_WIDGET(fs));
813 }
814
815 static gboolean
816 dump_screen(GntBindable *b, GList *null)
817 {
818 GntWidget *window = gnt_file_sel_new();
819 GntFileSel *sel = GNT_FILE_SEL(window);
820 gnt_file_sel_set_suggested_filename(sel, "dump.html");
821 g_signal_connect(G_OBJECT(sel), "file_selected", G_CALLBACK(dump_file_save), NULL);
822 g_signal_connect(G_OBJECT(sel->cancel), "activate", G_CALLBACK(dump_file_cancel), sel);
823 gnt_widget_show(window);
799 return TRUE; 824 return TRUE;
800 } 825 }
801 826
802 static void 827 static void
803 shift_window(GntWM *wm, GntWidget *widget, int dir) 828 shift_window(GntWM *wm, GntWidget *widget, int dir)
1364 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-close", window_close, 1389 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-close", window_close,
1365 "\033" "c", NULL); 1390 "\033" "c", NULL);
1366 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-list", window_list, 1391 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-list", window_list,
1367 "\033" "w", NULL); 1392 "\033" "w", NULL);
1368 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "dump-screen", dump_screen, 1393 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "dump-screen", dump_screen,
1369 "\033" "d", NULL); 1394 "\033" "D", NULL);
1370 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "shift-left", shift_left, 1395 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "shift-left", shift_left,
1371 "\033" ",", NULL); 1396 "\033" ",", NULL);
1372 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "shift-right", shift_right, 1397 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "shift-right", shift_right,
1373 "\033" ".", NULL); 1398 "\033" ".", NULL);
1374 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "action-list", list_actions, 1399 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "action-list", list_actions,