diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2001-11-06 12:36:24 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2001-11-06 12:36:24 +0000 |
commit | 2f391a02b894fcf9d2580a04ab9ac66ed8040862 (patch) | |
tree | 565d50a408f3cc517a0c94843181fe76013f7b70 /win32caml/inria.h | |
parent | 839a289aa108482e203053488863d622985bc8b0 (diff) |
GUI Win32 pour le toplevel (J.Navia)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3988 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'win32caml/inria.h')
-rw-r--r-- | win32caml/inria.h | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/win32caml/inria.h b/win32caml/inria.h new file mode 100644 index 000000000..8ac701e41 --- /dev/null +++ b/win32caml/inria.h @@ -0,0 +1,112 @@ +/***********************************************************************/ +/* */ +/* Objective Caml */ +/* */ +/* Developed by Jacob Navia. */ +/* Copyright 2001 Institut National de Recherche en Informatique et */ +/* en Automatique. All rights reserved. This file is distributed */ +/* under the terms of the GNU Library General Public License. */ +/* */ +/***********************************************************************/ + +/* $Id$ */ + +/*------------------------------------------------------------------------ + Module: D:\lcc\inria\inria.h + Author: Jacob + Project: + State: + Creation Date: June 2001 + Description: The user interface works as follows: + 1: At startup it will look for the path to the + ocaml interpreter in the registry using the + key HKEY_CURRENT_USER\SOFTWARE\ocaml. If not + found will prompt the user. + 2: It will start the ocaml interpreter with + its standard output and standard input + connected to two pipes in a dedicated thread. + 3: It will open a window containing an edit + field. The output from the interpreter will be + shown in the edit field, and the input of the + user in the edit field will be sent to the + interpreter when the user types return. + 4: Line editing is provided by moving to the + desired line with the arrows, then pressing + return; If we aren't in the last input line, + the input will be copied to the last line and + sent to the interpreter. + 5: The GUI ensures that when we exit the ocaml + interpreter is stopped by sending the + character string "#quit;;\nCtrl-Z" + 6: A history of all lines sent to the interpreter + is maintained in a simple linked list. The + History dialog box shows that, and allows the + user to choose a given input line. + 7: Memory limits. The edit buffer can be of an + arbitrary length, i.e. maybe 7-8MB or more, + there are no fixed limits. The History list + will always grow too, so memory consumption + could be "high" after several days of + uninterrupted typing at the keyboard. For that + cases it is recommended to stop the GUI and + get some sleep... + 9: The GUI will start a timer, looking 4 times a + second if the interpreter has written + something in the pipe. This is enough for most + applications. +------------------------------------------------------------------------*/ + +#include <windows.h> + +// In this structure should go eventually all global variables scattered +// through the program. +typedef struct _programParams { + HFONT hFont; // The handle of the current font + COLORREF TextColor; // The text color + char CurrentWorkingDir[MAX_PATH];// The current directory +} PROGRAM_PARAMS; + +//**************** Global variables *********************** +extern PROGRAM_PARAMS ProgramParams; + +extern COLORREF BackColor; // The background color +extern HBRUSH BackgroundBrush; // A brush built with the background color +extern char LibDir[]; // The lib directory +extern char OcamlPath[]; // The Path to ocaml.exe +extern HANDLE hInst; // The instance handle for this application +extern HWND hwndSession; // The current session window handle +extern LOGFONT CurrentFont; // The current font characteristics +extern HWND hwndMain,hwndMDIClient; // Window handles of frame and mdi window + +// ***************** Function prototypes ****************** +int WriteToPipe(char *data); // Writes to the pipe +int ReadFromPipe(char *data,int len);// Reads from the pipe +int AskYesOrNo(char *msg); //Ditto! +int BrowseForFile(char *fname,char *path); +void GotoEOF(void); // Positions the cursor at the end of the text +void ShowDbgMsg(char *msg); // Shows an error message +void HandleCommand(HWND hwnd, WPARAM wParam,LPARAM lParam); +int GetOcamlPath(void); // Finds where ocaml.exe is +void ForceRepaint(void); // Ditto. +void AddLineToControl(char *buf); +char *GetHistoryLine(int n); // Gets the nth history line base 1. +int StartOcaml(void); +// **************** User defined window messages ************* +#define WM_NEWLINE (WM_USER+6000) +#define WM_TIMERTICK (WM_USER+6001) +#define WM_QUITOCAML (WM_USER+6002) +// ********************** Structures *********************** +typedef struct tagPosition { + int line; + int col; +} POSITION; + +// Simple linked list for holding the history lines +typedef struct tagHistory { + struct tagHistory *Next; + char *Text; +} HISTORYLINE; + +extern void *SafeMalloc(int); +extern HISTORYLINE *History; // The root of the history lines + |