1*84d9c625SLionel Sambuc /*-
2*84d9c625SLionel Sambuc * Copyright (c) 1999
3*84d9c625SLionel Sambuc * Sven Verdoolaege. All rights reserved.
4*84d9c625SLionel Sambuc * Copyright (c) 1996
5*84d9c625SLionel Sambuc * Rob Zimmermann. All rights reserved.
6*84d9c625SLionel Sambuc * Copyright (c) 1996
7*84d9c625SLionel Sambuc * Keith Bostic. All rights reserved.
8*84d9c625SLionel Sambuc *
9*84d9c625SLionel Sambuc * See the LICENSE file for redistribution information.
10*84d9c625SLionel Sambuc */
11*84d9c625SLionel Sambuc
12*84d9c625SLionel Sambuc #include "config.h"
13*84d9c625SLionel Sambuc
14*84d9c625SLionel Sambuc #include <sys/types.h>
15*84d9c625SLionel Sambuc #include <sys/queue.h>
16*84d9c625SLionel Sambuc
17*84d9c625SLionel Sambuc #include <bitstring.h>
18*84d9c625SLionel Sambuc #include <stdio.h>
19*84d9c625SLionel Sambuc #include <stdlib.h>
20*84d9c625SLionel Sambuc #include <string.h>
21*84d9c625SLionel Sambuc
22*84d9c625SLionel Sambuc #include <gtk/gtk.h>
23*84d9c625SLionel Sambuc
24*84d9c625SLionel Sambuc #include "../common/common.h"
25*84d9c625SLionel Sambuc #include "../ipc/ip.h"
26*84d9c625SLionel Sambuc
27*84d9c625SLionel Sambuc #if 0
28*84d9c625SLionel Sambuc #include <zvt/zvtterm.h>
29*84d9c625SLionel Sambuc #include <zvt/vt.h>
30*84d9c625SLionel Sambuc #endif
31*84d9c625SLionel Sambuc #include "gtkvi.h"
32*84d9c625SLionel Sambuc #include "gtkviscreen.h"
33*84d9c625SLionel Sambuc #include "gtkviwindow.h"
34*84d9c625SLionel Sambuc #include "gtk_extern.h"
35*84d9c625SLionel Sambuc
36*84d9c625SLionel Sambuc static int vi_key_press_event __P((GtkWidget*, GdkEventKey*, GtkVi*));
37*84d9c625SLionel Sambuc
38*84d9c625SLionel Sambuc
39*84d9c625SLionel Sambuc
40*84d9c625SLionel Sambuc #if 0
41*84d9c625SLionel Sambuc static int
42*84d9c625SLionel Sambuc vi_fork(ipvi)
43*84d9c625SLionel Sambuc IPVI *ipvi;
44*84d9c625SLionel Sambuc {
45*84d9c625SLionel Sambuc GtkVi* vi = (GtkVi*)(ipvi->private_data);
46*84d9c625SLionel Sambuc
47*84d9c625SLionel Sambuc return zvt_term_forkpty(ZVT_TERM(vi->term), 0);
48*84d9c625SLionel Sambuc }
49*84d9c625SLionel Sambuc #endif
50*84d9c625SLionel Sambuc
51*84d9c625SLionel Sambuc /*
52*84d9c625SLionel Sambuc * PUBLIC: int gtk_vi_init __P((GtkVi **, int, char*[]));
53*84d9c625SLionel Sambuc */
54*84d9c625SLionel Sambuc int
gtk_vi_init(GtkVi ** vip,int argc,char ** argv)55*84d9c625SLionel Sambuc gtk_vi_init(GtkVi **vip, int argc, char **argv)
56*84d9c625SLionel Sambuc {
57*84d9c625SLionel Sambuc GtkVi *vi;
58*84d9c625SLionel Sambuc GtkWidget *term;
59*84d9c625SLionel Sambuc
60*84d9c625SLionel Sambuc MALLOC_GOTO(NULL, vi, GtkVi*, sizeof(GtkVi));
61*84d9c625SLionel Sambuc memset(vi, 0, sizeof(GtkVi));
62*84d9c625SLionel Sambuc
63*84d9c625SLionel Sambuc #if 0
64*84d9c625SLionel Sambuc term = zvt_term_new();
65*84d9c625SLionel Sambuc gtk_widget_show(term);
66*84d9c625SLionel Sambuc vi->term = term;
67*84d9c625SLionel Sambuc vt_parse_vt(&ZVT_TERM(term)->vx->vt, "test\n", 5);
68*84d9c625SLionel Sambuc #endif
69*84d9c625SLionel Sambuc /* doesn't work now; need to know when other process is running
70*84d9c625SLionel Sambuc gtk_signal_connect(GTK_OBJECT(term), "key_press_event",
71*84d9c625SLionel Sambuc (GtkSignalFunc) vi_key_press_event, vi);
72*84d9c625SLionel Sambuc */
73*84d9c625SLionel Sambuc
74*84d9c625SLionel Sambuc /*
75*84d9c625SLionel Sambuc vi_create(&vi->ipvi, IP_EX_ALLOWED);
76*84d9c625SLionel Sambuc */
77*84d9c625SLionel Sambuc vi_create(&vi->ipvi, 0);
78*84d9c625SLionel Sambuc vi->ipvi->private_data = vi;
79*84d9c625SLionel Sambuc
80*84d9c625SLionel Sambuc /* Run vi: the parent returns, the child is the vi process. */
81*84d9c625SLionel Sambuc vi->ipvi->run(vi->ipvi, argc, argv);
82*84d9c625SLionel Sambuc
83*84d9c625SLionel Sambuc *vip = vi;
84*84d9c625SLionel Sambuc
85*84d9c625SLionel Sambuc return 0;
86*84d9c625SLionel Sambuc
87*84d9c625SLionel Sambuc alloc_err:
88*84d9c625SLionel Sambuc return 1;
89*84d9c625SLionel Sambuc }
90*84d9c625SLionel Sambuc
91*84d9c625SLionel Sambuc #if 0
92*84d9c625SLionel Sambuc static int
93*84d9c625SLionel Sambuc vi_key_press_event(zvt, event, vi)
94*84d9c625SLionel Sambuc GtkVi *vi;
95*84d9c625SLionel Sambuc GtkWidget *zvt;
96*84d9c625SLionel Sambuc GdkEventKey *event;
97*84d9c625SLionel Sambuc {
98*84d9c625SLionel Sambuc gtk_vi_key_press_event(vi, event);
99*84d9c625SLionel Sambuc
100*84d9c625SLionel Sambuc gtk_signal_emit_stop_by_name(GTK_OBJECT(zvt), "key_press_event");
101*84d9c625SLionel Sambuc /* handled */
102*84d9c625SLionel Sambuc return 1;
103*84d9c625SLionel Sambuc }
104*84d9c625SLionel Sambuc #endif
105