Merge commit 'ocaml3102'
[ocaml.git] / win32caml / inria.h
blob8b0ad226235fa2a0c08f11af8206a879fe39b123
1 /***********************************************************************/
2 /* */
3 /* Objective Caml */
4 /* */
5 /* Developed by Jacob Navia. */
6 /* Copyright 2001 Institut National de Recherche en Informatique et */
7 /* en Automatique. All rights reserved. This file is distributed */
8 /* under the terms of the GNU Library General Public License, with */
9 /* the special exception on linking described in file ../LICENSE. */
10 /* */
11 /***********************************************************************/
13 /* $Id$ */
15 /*------------------------------------------------------------------------
16 Module: D:\lcc\inria\inria.h
17 Author: Jacob
18 Project:
19 State:
20 Creation Date: June 2001
21 Description: The user interface works as follows:
22 1: At startup it will look for the path to the
23 ocaml interpreter in the registry using the
24 key HKEY_CURRENT_USER\SOFTWARE\ocaml. If not
25 found will prompt the user.
26 2: It will start the ocaml interpreter with
27 its standard output and standard input
28 connected to two pipes in a dedicated thread.
29 3: It will open a window containing an edit
30 field. The output from the interpreter will be
31 shown in the edit field, and the input of the
32 user in the edit field will be sent to the
33 interpreter when the user types return.
34 4: Line editing is provided by moving to the
35 desired line with the arrows, then pressing
36 return; If we aren't in the last input line,
37 the input will be copied to the last line and
38 sent to the interpreter.
39 5: The GUI ensures that when we exit the ocaml
40 interpreter is stopped by sending the
41 character string "#quit;;\nCtrl-Z"
42 6: A history of all lines sent to the interpreter
43 is maintained in a simple linked list. The
44 History dialog box shows that, and allows the
45 user to choose a given input line.
46 7: Memory limits. The edit buffer can be of an
47 arbitrary length, i.e. maybe 7-8MB or more,
48 there are no fixed limits. The History list
49 will always grow too, so memory consumption
50 could be "high" after several days of
51 uninterrupted typing at the keyboard. For that
52 cases it is recommended to stop the GUI and
53 get some sleep...
54 9: The GUI will start a timer, looking 4 times a
55 second if the interpreter has written
56 something in the pipe. This is enough for most
57 applications.
58 ------------------------------------------------------------------------*/
59 #ifndef _INRIA_H_
60 #define _INRIA_H_
62 #include <windows.h>
63 #include "editbuffer.h"
64 #include "history.h"
66 #if _MSC_VER <= 1200
67 #define GetWindowLongPtr GetWindowLong
68 #define SetWindowLongPtr SetWindowLong
69 #define DWLP_USER DWL_USER
70 #define GWLP_WNDPROC GWL_WNDPROC
71 #define LONG_PTR DWORD
72 #endif
74 // In this structure should go eventually all global variables scattered
75 // through the program.
76 typedef struct _programParams {
77 HFONT hFont; // The handle of the current font
78 COLORREF TextColor; // The text color
79 char CurrentWorkingDir[MAX_PATH];// The current directory
80 } PROGRAM_PARAMS;
82 //**************** Global variables ***********************
83 extern PROGRAM_PARAMS ProgramParams;
85 extern COLORREF BackColor; // The background color
86 extern HBRUSH BackgroundBrush; // A brush built with the background color
87 extern char LibDir[]; // The lib directory
88 extern char OcamlPath[]; // The Path to ocaml.exe
89 extern HANDLE hInst; // The instance handle for this application
90 extern HWND hwndSession; // The current session window handle
91 extern LOGFONT CurrentFont; // The current font characteristics
92 extern HWND hwndMain,hwndMDIClient; // Window handles of frame and mdi window
94 // ***************** Function prototypes ******************
95 int WriteToPipe(char *data); // Writes to the pipe
96 int ReadFromPipe(char *data,int len);// Reads from the pipe
97 int AskYesOrNo(char *msg); //Ditto!
98 int BrowseForFile(char *fname,char *path);
99 void GotoEOF(void); // Positions the cursor at the end of the text
100 void ShowDbgMsg(char *msg); // Shows an error message
101 void HandleCommand(HWND hwnd, WPARAM wParam,LPARAM lParam);
102 int GetOcamlPath(void); // Finds where ocaml.exe is
103 void ForceRepaint(void); // Ditto.
104 void AddLineToControl(char *buf);
105 void AddStringToControl(char* buf);
106 char *GetHistoryLine(int n); // Gets the nth history line base 1.
107 int StartOcaml(void);
108 void InterruptOcaml(void);
109 int ResetText(void);
110 BOOL SendingFullCommand(void);
111 void RewriteCurrentEditBuffer(void);
112 void RefreshCurrentEditBuffer(void);
114 // **************** User defined window messages *************
115 #define WM_NEWLINE (WM_USER+6000)
116 #define WM_TIMERTICK (WM_USER+6001)
117 #define WM_QUITOCAML (WM_USER+6002)
118 #define WM_SYNTAXERROR (WM_USER+6003)
119 #define WM_UNBOUNDVAL (WM_USER+6004)
120 #define WM_ILLEGALCHAR (WM_USER+6005)
122 // ********************** Structures ***********************
123 typedef struct tagPosition {
124 int line;
125 int col;
126 } POSITION;
128 extern void *SafeMalloc(int);
129 extern StatementHistory *History; // The root of the history lines
130 extern StatementHistory *HistoryTail; // The tail of the history lines
131 extern EditBuffer *CurrentEditBuffer; // current edit buffer
133 #define IDEDITCONTROL 15432
134 #endif