2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 //%% (c) Copyright 1993, 1994 Hewlett-Packard Company
24 //%% (c) Copyright 1993, 1994 International Business Machines Corp.
25 //%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
26 //%% (c) Copyright 1993, 1994 Novell, Inc.
27 //%% $XConsortium: CoEd.C /main/3 1995/10/20 17:04:04 rswiston $
31 * Copyright (c) 1991,1993 by Sun Microsystems.
39 #include "CoEdTextBuffer.h"
41 XtAppContext myContext;
42 Widget myTopWidget = 0;
44 char *myAltMediaType = "ISO_Latin_1";
46 Tt_pattern *sessPats = 0;
47 int timeOutFactor = 1000;
48 int maxBuffers = 1000;
52 const char *ToolName = "CoEd";
54 "Usage: CoEd [-p01] [-w n] [-t n] [-m media_type] [file]\n"
55 " -p print ToolTalk procid\n"
56 " -0 do not open an initial composition window\n"
57 " -1 be a single-buffer editor\n"
58 " -w sleep for n seconds before coming up\n"
59 " -t use n as timeout factor, in milliseconds (default: 1000)\n"
60 " -m set the alternate media type (default: ISO_Latin_1)\n"
69 static const char *here = "main()";
75 XtToolkitInitialize();
76 myContext = XtCreateApplicationContext();
78 // This display may get closed, and another opened, inside
79 // CoEditor::_init(), if e.g. our parent is on a different screen
83 myDpy = XtOpenDisplay( myContext, 0, 0, "CoEd", 0, 0, &argc, argv );
86 while ((c = getopt( argc, argv, "p01w:t:m:" )) != -1) {
98 delay = atoi( optarg );
101 timeOutFactor = atoi( optarg );
104 myAltMediaType = optarg;
107 fputs( usage, stderr );
112 file = argv[ optind ];
120 char *myProcID = ttdt_open( &myTtFd, ToolName, "SunSoft", "%I", 1 );
121 Tt_status status = tt_ptr_error( myProcID );
122 if (status != TT_OK) {
123 fprintf( stderr, "ttdt_open(): %s\n",
124 tt_status_message(status) );
128 printf( "%s\n", myProcID );
131 XtAppAddInput( myContext, myTtFd, (XtPointer)XtInputReadMask,
132 tttk_Xt_input_handler, myProcID );
134 ttmedia_ptype_declare( "Sun_CoEd", 0, CoEditor::loadISOLatin1_,
135 (void *)&myTopWidget, 1 );
137 // Process the message that started us, if any
138 tttk_Xt_input_handler( 0, 0, 0 );
139 if (abortCode != 0) {
140 // Error in message that caused us to start.
145 if (CoEditor::numEditors == 0) {
146 // started by hand, not by ToolTalk
149 new CoEditor( &myTopWidget );
152 new CoEditor( &myTopWidget, file );
156 // If sessPats is unset, then we have no joined the desktop
157 // session yet. So join it.
160 Widget session_shell = CoEditor::editors[0]->shell;
161 if (maxBuffers > 1) {
163 // In multi-window mode, no single window is the
164 // distinguished window.
166 session_shell = myTopWidget;
168 sessPats = ttdt_session_join( 0, CoEditor::contractCB_,
169 session_shell, CoEditor::editors[0], 1 );
172 while (daemon || (CoEditor::numEditors > 0)) {
174 XtAppNextEvent( myContext, &event );
175 XtDispatchEvent( &event );
177 ttdt_close( 0, 0, 1 );