Makefile.in generated now
[nvi.git] / gtk / gtkvi.c
blobe6fc17bbb5fe032c79235a5384a38b373ecc4e54
1 /*-
2 * Copyright (c) 1999
3 * Sven Verdoolaege. All rights reserved.
4 * Copyright (c) 1996
5 * Rob Zimmermann. All rights reserved.
6 * Copyright (c) 1996
7 * Keith Bostic. All rights reserved.
9 * See the LICENSE file for redistribution information.
12 #include "config.h"
14 #include <sys/types.h>
15 #include <sys/queue.h>
17 #include <bitstring.h>
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
22 #include "../common/common.h"
23 #include "../ipc/ip.h"
25 #include <gtk/gtk.h>
26 #include <zvt/zvtterm.h>
27 #include <zvt/vt.h>
28 #include "gtkvi.h"
29 #include "gtkviscreen.h"
30 #include "gtkviwindow.h"
31 #include "extern.h"
33 static int vi_key_press_event __P((GtkWidget*, GdkEventKey*, GtkVi*));
37 static int
38 vi_fork(ipvi)
39 IPVI *ipvi;
41 GtkVi* vi = (GtkVi*)(ipvi->private_data);
43 return zvt_term_forkpty(ZVT_TERM(vi->term), 0);
46 /*
47 * PUBLIC: int gtk_vi_init __P((GtkVi **, int, char*[]));
49 int
50 gtk_vi_init(vip, argc, argv)
51 GtkVi **vip;
52 int argc;
53 char *argv[];
55 GtkVi *vi;
56 GtkWidget *term;
58 MALLOC_GOTO(NULL, vi, GtkVi*, sizeof(GtkVi));
59 memset(vi, 0, sizeof(GtkVi));
61 term = zvt_term_new();
62 gtk_widget_show(term);
63 vi->term = term;
64 vt_parse_vt(&ZVT_TERM(term)->vx->vt, "test\n", 5);
65 /* doesn't work now; need to know when other process is running
66 gtk_signal_connect(GTK_OBJECT(term), "key_press_event",
67 (GtkSignalFunc) vi_key_press_event, vi);
71 vi_create(&vi->ipvi, IP_EX_ALLOWED);
73 vi_create(&vi->ipvi, 0);
74 vi->ipvi->private_data = vi;
76 /* Run vi: the parent returns, the child is the vi process. */
77 vi->ipvi->run(vi->ipvi, argc, argv);
79 *vip = vi;
81 return 0;
83 alloc_err:
84 return 1;
88 * PUBLIC: void gtk_vi_show_term __P((GtkVi*, gint));
90 void
91 gtk_vi_show_term(vi, show)
92 GtkVi *vi;
93 gint show;
95 gtk_notebook_set_page(GTK_NOTEBOOK(vi->vi_window), show ? 1 : 0);
98 #if 0
99 static int
100 vi_key_press_event(zvt, event, vi)
101 GtkVi *vi;
102 GtkWidget *zvt;
103 GdkEventKey *event;
105 gtk_vi_key_press_event(vi, event);
107 gtk_signal_emit_stop_by_name(GTK_OBJECT(zvt), "key_press_event");
108 /* handled */
109 return 1;
111 #endif