update to latest swi console code

This commit is contained in:
Vítor Santos Costa 2014-02-26 22:10:17 +00:00
parent 3da5cc5977
commit 2d3d9441ef
13 changed files with 558 additions and 340 deletions

View File

@ -1,4 +1,4 @@
/* $Id$
/* $Id$
Part of SWI-Prolog
@ -20,7 +20,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define WINDOWS_LEAN_AND_MEAN 1
@ -43,6 +43,10 @@ typedef enum
CMD_ANSI
} astate;
typedef enum
{ HDL_CONSOLE = 0,
HDL_FILE
} htype;
typedef struct
{ int magic;
@ -57,6 +61,7 @@ typedef struct
int argstat;
astate cmdstat; /* State for sequence processing */
WORD def_attr; /* Default attributes */
htype handletype; /* Type of stream handle */
} ansi_stream;
@ -85,11 +90,19 @@ flush_ansi(ansi_stream *as)
{ BOOL rc;
DWORD done;
rc = WriteConsoleW(as->hConsole,
&as->buffer[written],
(DWORD)(as->buffered-written),
&done,
NULL);
if (as->handletype == HDL_CONSOLE)
{ rc = WriteConsoleW(as->hConsole,
&as->buffer[written],
(DWORD)(as->buffered-written),
&done,
NULL);
} else
{ rc = WriteFile(as->hConsole,
&as->buffer[written],
(DWORD)(as->buffered-written),
&done,
NULL);
}
if ( rc )
{ written += done;
@ -347,7 +360,20 @@ control_ansi(void *handle, int op, void *data)
case SIO_SETENCODING:
return -1; /* We cannot change the encoding! */
case SIO_LASTERROR:
return 0; /* TBD */
{ const char *s;
if ( (s = WinError()) );
{ const char **sp = data;
*sp = s;
return 0;
}
return -1;
}
case SIO_GETFILENO:
{ int *fp = data;
*fp = (int)(intptr_t)as->saved_handle; /* is one of 0,1,2 */
return 0;
}
default:
return -1;
}
@ -402,10 +428,16 @@ error:
static int
wrap_console(HANDLE h, IOSTREAM *s, IOFUNCTIONS *funcs)
{ ansi_stream *as;
DWORD mode;
as = PL_malloc(sizeof(*as));
memset(as, 0, sizeof(*as));
if (GetConsoleMode(h, &mode))
as->handletype = HDL_CONSOLE;
else
as->handletype = HDL_FILE;
as->hConsole = h;
as->pStream = s;
as->saved_handle = s->handle;
@ -413,6 +445,7 @@ wrap_console(HANDLE h, IOSTREAM *s, IOFUNCTIONS *funcs)
s->handle = as;
s->encoding = ENC_WCHAR;
s->functions = funcs;
s->flags &= ~SIO_FILE;
return TRUE;
}

View File

@ -1,75 +1,53 @@
#
# default base directory for YAP installation
# (EROOT for architecture-dependent files)
#
prefix = @prefix@
exec_prefix = @exec_prefix@
ROOTDIR = $(prefix)
EROOTDIR = @exec_prefix@
#
# where YAP should look for libraries
#
LIBDIR=@libdir@/Yap
#
#
CC=@CC@ -municode -DUNICODE -D_UNICODE
CPPFLAGS=@CPPFLAGS@
CFLAGS= @CFLAGS@ $(DEFS) $(CPPFLAGS) -I$(srcdir) -DRLC_VENDOR="\"YAP\""
#
#
# You shouldn't need to change what follows.
#
INSTALL=@INSTALL@
INSTALL_DATA=@INSTALL_DATA@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
RANLIB=@RANLIB@
AR=@AR@
################################################################
# Makefile for the SWI-Prolog console window.
################################################################
srcdir=@srcdir@
@VPATH@ @srcdir@
SOURCES= \
$(srcdir)/complete.c $(srcdir)/console.c \
$(srcdir)/edit.c $(srcdir)/history.c \
$(srcdir)/menu.c
HEADERS= \
$(srcdir)/common.h $(srcdir)/console.h \
$(srcdir)/console_i.h $(srcdir)/history.h \
$(srcdir)/menu.h
CC=@CC@
LDEXE=@LDEXE@
PLARCH=@PLARCH@
XLIBS=@XLIBS@
SOEXT=@SO_EXT@
OBJECTS= complete.o console.o edit.o history.o menu.o
COFLAGS=@COFLAGS@
CWFLAGS=@CWFLAGS@
CIFLAGS=@CIFLAGS@
CMFLAGS=@CMFLAGS@ -DUNICODE -D_UNICODE
CPFLAGS=
CFLAGS= $(CWFLAGS) $(COFLAGS) $(CIFLAGS) $(CMFLAGS) $(CPFLAGS)
LDFLAGS=@LDFLAGS@ $(CPFLAGS)
LIBS=-lgdi32 -lcomdlg32
PLHOME=../../..
all: ../../plterm.dll
include $(srcdir)/../../common.mk
../../plterm.dll: libplterm.a
$(CC) $(CFLAGS) -shared -o ../../plterm.dll \
-Wl,--export-all-symbols \
-Wl,--enable-auto-import \
-Wl,--whole-archive libplterm.a \
-Wl,--no-whole-archive $(LIBS) $(LDFLAGS)
OBJ= complete.o console.o edit.o history.o menu.o
OUT= $(PLHOME)/lib/$(PLARCH)/plterm.$(SOEXT)
INCLDIR=$(PLHOME)/include
HDR= $(INCLDIR)/console.h
libplterm.a: $(OBJECTS) $(SOURCES) $(HEADERS)
-rm -f libplterm.a
$(AR) rc libplterm.a $(OBJECTS)
$(RANLIB) libplterm.a
all: $(OUT) $(HDR)
install:
$(OUT): $(OBJ)
$(CC) -shared $(COFLAGS) -o $@ -Wl,--out-implib,$@.a $(OBJ) $(XLIBS)
$(HDR): $(INCLDIR)
$(INCLDIR):
mkdir -p $@
$(PLHOME)/include/console.h: $(srcdir)/console.h
cp -f $< $@
console.o: $(srcdir)/console_i.h $(srcdir)/console.h
clean:
rm -f *.o *~ *.dll
complete.o: $(srcdir)/complete.c
$(CC) -c $(CFLAGS) $(SHLIB_CFLAGS) $(srcdir)/complete.c -o complete.o
console.o: $(srcdir)/console.c
$(CC) -c $(CFLAGS) $(SHLIB_CFLAGS) $(srcdir)/console.c -o console.o
history.o: $(srcdir)/history.c
$(CC) -c $(CFLAGS) $(SHLIB_CFLAGS) $(srcdir)/history.c -o history.o
menu.o: $(srcdir)/menu.c
$(CC) -c $(CFLAGS) $(SHLIB_CFLAGS) $(srcdir)/menu.c -o menu.o
edit.o: $(srcdir)/edit.c
$(CC) -c $(CFLAGS) $(SHLIB_CFLAGS) $(srcdir)/edit.c -o edit.o
rm -f *.o
rm -f *~
distclean: clean
rm -f $(PLHOME)/lib/$(PLARCH)/plterm.$(SOEXT)
rm -f $(PLHOME)/lib/$(PLARCH)/plterm.$(SOEXT).a
rm -f $(INCLDIR)/console.h

View File

@ -1,4 +1,4 @@
/* $Id: common.h,v 1.1 2008-04-01 08:50:48 vsc Exp $
/* $Id$
Part of SWI-Prolog
@ -19,7 +19,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define IMODE_SWITCH_CHAR -2

View File

@ -1,4 +1,4 @@
/* $Id: complete.c,v 1.1 2008-03-27 00:41:33 vsc Exp $
/* $Id$
Part of SWI-Prolog
@ -19,21 +19,21 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <windows.h>
#include <tchar.h>
#include "console.h"
#ifndef __TCHAR_DEFINED
typedef wint_t _TINT;
#endif
#ifndef EOS
#define EOS 0
#endif
#ifndef _TINT
typedef wint_t _TINT;
#endif
static TCHAR *completion_chars = TEXT("~:\\/-.");
static size_t
@ -77,7 +77,7 @@ rlc_complete_file_function(RlcCompleteData data)
for( ; n < ln->point; n++)
{ int c = ln->data[n];
if ( c == '/' )
c = '\\';
if ( c == '\\' )
@ -108,7 +108,7 @@ rlc_complete_file_function(RlcCompleteData data)
{ _tcscpy(data->candidate, fdata.cFileName);
return TRUE;
}
return FALSE;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $Id: console.h,v 1.1 2008-04-01 08:45:42 vsc Exp $
/* $Id$
Part of SWI-Prolog
@ -19,7 +19,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _CONSOLE_H_INCLUDED
@ -41,21 +41,21 @@
#include <signal.h>
#include <stddef.h>
#if __GNUC__
#include <stdint.h>
#else
#ifdef _MSC_VER
#if (_MSC_VER < 1300)
typedef long intptr_t;
typedef unsigned long uintptr_t;
#endif
#else
#include <stdint.h>
#endif
#define RLC_APPTIMER_ID 100 /* >=100: application timer */
typedef struct
{ int first;
int last;
int size; /* size of the buffer */
{ int first;
int last;
int size; /* size of the buffer */
TCHAR *buffer; /* character buffer */
int flags; /* flags for the queue */
} rlc_queue, *RlcQueue;
@ -75,7 +75,7 @@ typedef struct
int x; /* # pixels (0: default) */
int y; /* # pixels (0: default) */
int savelines; /* # lines to save (0: default) */
TCHAR face_name[32]; /* font name */
TCHAR face_name[32]; /* font name */
int font_family; /* family id */
int font_size;
int font_weight;
@ -94,7 +94,7 @@ typedef void (*RlcResizeHook)(int, int); /* Hook for window change */
typedef void (*RlcMenuHook)(rlc_console, const TCHAR *id); /* Hook for menu-selection */
typedef void (*RlcFreeDataHook)(uintptr_t data); /* release data */
#if defined(_WINDOWS_) || defined(_WINDOWS_H) /* <windows.h> is included */
#ifdef __WINDOWS__ /* <windows.h> is included */
/* rlc_color(which, ...) */
#define RLC_WINDOW (0) /* window background */
#define RLC_TEXT (1) /* text color */
@ -116,7 +116,7 @@ typedef LRESULT (*RlcMessageHook)(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam);
_export RlcMessageHook rlc_message_hook(RlcMessageHook hook);
#endif /*_WINDOWS_*/
#endif /*__WINDOWS__*/
_export RlcUpdateHook rlc_update_hook(RlcUpdateHook updatehook);
_export RlcTimerHook rlc_timer_hook(RlcTimerHook timerhook);
@ -182,9 +182,9 @@ _export int rlc_set(rlc_console c, int what,
typedef struct _line
{ rlc_mark origin; /* origin of edit */
size_t point; /* location of the caret */
size_t point; /* location of the caret */
size_t size; /* # characters in buffer */
size_t allocated; /* # characters allocated */
size_t allocated; /* # characters allocated */
size_t change_start; /* start of change */
int complete; /* line is completed */
int reprompt; /* repeat the prompt */
@ -199,6 +199,8 @@ typedef struct _line
#define COMPLETE_ENUMERATE 1
#define COMPLETE_CLOSE 2
struct _complete_data;
typedef int (*RlcCompleteFunc)(struct _complete_data *);
typedef struct _complete_data
@ -221,5 +223,9 @@ _export int rlc_complete_file_function(RlcCompleteData data);
_export void rlc_init_history(rlc_console c, int size);
_export void rlc_add_history(rlc_console c, const TCHAR *line);
_export int rlc_bind(int chr, const char *fname);
_export int rlc_for_history(
rlc_console b,
int (*handler)(void *ctx, int no, const TCHAR *line),
void *ctx);
#endif /* _CONSOLE_H_INCLUDED */

View File

@ -1,4 +1,4 @@
/* $Id: console_i.h,v 1.1 2008-04-01 08:50:44 vsc Exp $
/* $Id$
Part of SWI-Prolog
@ -19,7 +19,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -45,7 +45,7 @@ typedef struct _history
#define ANSI_MAX_ARGC 10 /* Ansi-escape sequence argv */
#define MAXPROMPT 80 /* max size of prompt */
#define OQSIZE 4096 /* output queue size */
#define OQSIZE 4096 /* output queue size */
#define MAX_USER_VALUES 10 /* max user data-handles */
typedef struct lqueued
@ -53,8 +53,29 @@ typedef struct lqueued
struct lqueued* next; /* Next in queue */
} lqueued, *LQueued;
typedef unsigned short text_flags;
#define ANSI_COLOR_DEFAULT 31
#define TF_FG(f) ((f)&0x1f) /* foreground */
#define TF_BG(f) (((f)>>5)&0x1f) /* background */
#define TF_BOLD(f) ((f)&(1<<10)) /* bold */
#define TF_UNDERLINE(f) ((f)&(1<<11)) /* underline */
#define TF_DEFAULT (ANSI_COLOR_DEFAULT | ANSI_COLOR_DEFAULT<<5)
#define TF_SET_FG(f,c) (((f)&~0x1f)|(c))
#define TF_SET_BG(f,c) (((f)&~(0x1f<<5))|((c)<<5))
#define TF_SET_BOLD(f,v) (((f)&~(1<<10))|((v)<<10))
#define TF_SET_UNDERLINE(f,v) (((f)&~(1<<11))|((v)<<11))
typedef struct
{ TCHAR * text; /* the storage */
{ TCHAR code; /* character code */
text_flags flags; /* flags for the text */
} text_char;
typedef struct
{ text_char *text; /* the storage */
unsigned short size; /* #characters in line */
unsigned adjusted : 1; /* line has been adjusted? */
unsigned changed : 1; /* line needs redraw */
@ -78,7 +99,7 @@ typedef struct
int caret_y; /* its line */
int window_start; /* start line of the window */
int window_size; /* #lines on the window */
TextLine lines; /* the actual lines */
TextLine lines; /* the actual lines */
int sel_unit; /* SEL_CHAR, SEL_WORD, SEL_LINE */
int sel_org_line; /* line origin of the selection */
int sel_org_char; /* char origin of the selection */
@ -100,6 +121,8 @@ typedef struct
COLORREF background; /* Background color */
COLORREF sel_foreground; /* Selection foreground */
COLORREF sel_background; /* Selection background */
COLORREF ansi_color[16]; /* ANSI colors (8 normal + 8 bright) */
text_flags sgr_flags; /* Current SGR flags */
int cw; /* character width */
int ch; /* character height */
int cb; /* baseline */
@ -139,7 +162,7 @@ typedef struct
DWORD console_thread_id; /* I/O thread id */
DWORD application_thread_id;
HWND kill_window; /* window in app thread for destroy */
user_data values[MAX_USER_VALUES]; /* associated user data */
} rlc_data, *RlcData;

View File

@ -1,4 +1,4 @@
/* $Id: edit.c,v 1.1 2008-03-27 00:41:33 vsc Exp $
/* $Id$
Part of SWI-Prolog
@ -19,13 +19,13 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define _MAKE_DLL 1
#undef _export
#include <windows.h>
#include <tchar.h>
#define _MAKE_DLL 1
#undef _export
#include "console.h"
#include "console_i.h"
#include "common.h"
@ -127,7 +127,7 @@ delete(Line ln, size_t from, size_t len)
_tcsncpy(&ln->data[from], &ln->data[from+len], ln->size - (from+len));
ln->size -= len;
}
}
/*******************************
@ -232,7 +232,7 @@ forward_word(Line ln, int chr)
static void
backward_delete_word(Line ln, int chr)
{ size_t from = back_word(ln, ln->point);
memmove(&ln->data[from], &ln->data[ln->point],
(ln->size - ln->point)*sizeof(TCHAR));
ln->size -= ln->point - from;
@ -244,7 +244,7 @@ backward_delete_word(Line ln, int chr)
static void
forward_delete_word(Line ln, int chr)
{ size_t to = forw_word(ln, ln->point);
memmove(&ln->data[ln->point], &ln->data[to], (ln->size - to)*sizeof(TCHAR));
ln->size -= to - ln->point;
changed(ln, ln->point);
@ -258,7 +258,7 @@ transpose_chars(Line ln, int chr)
ln->data[ln->point-1] = ln->data[ln->point];
ln->data[ln->point] = c0;
changed(ln, ln->point-1);
}
}
}
@ -291,7 +291,7 @@ empty_line(Line ln, int chr)
static void
enter(Line ln, int chr)
{ ln->point = ln->size;
#ifdef DOS_CRNL
#ifdef DOS_CRNL
make_room(ln, 2);
ln->data[ln->point++] = '\r';
ln->data[ln->point++] = '\n';
@ -325,7 +325,7 @@ delete_character_or_eof(Line ln, int chr)
static void
undefined(Line ln, int chr)
{
{
}
@ -442,7 +442,7 @@ complete(Line ln, int chr)
}
data->call_type = COMPLETE_CLOSE;
(*data->function)(data);
delete(ln, data->replace_from, patlen);
ln->point = data->replace_from;
make_room(ln, ncommon);
@ -487,7 +487,7 @@ list_completions(Line ln, int chr)
if ( nmatches > COMPLETE_MAX_MATCHES )
{ TCHAR *msg = _T("\r\n! Too many matches\r\n");
while(*msg)
rlc_putchar(ln->console, *msg++);
ln->reprompt = TRUE;
@ -511,7 +511,7 @@ list_completions(Line ln, int chr)
{ len++;
rlc_putchar(ln->console, *s++);
}
rlc_free(buf[n++]);
if ( n % cols == 0 )
@ -552,7 +552,7 @@ update_display(Line ln)
{ if ( ln->reprompt )
{ const TCHAR *prompt = rlc_prompt(ln->console, NULL);
const TCHAR *s = prompt;
rlc_putchar(ln->console, '\r');
while(*s)
rlc_putchar(ln->console, *s++);
@ -646,7 +646,7 @@ init_dispatch_table()
dispatch_table[n] = insert_self;
for(n=0; n<256; n++)
dispatch_meta[n] = undefined;
bind_actions();
done = TRUE;
@ -704,7 +704,7 @@ int
rlc_bind(int chr, const char *fname)
{ if ( chr >= 0 && chr <= 256 )
{ Action a = actions;
for( ; a->name; a++ )
{ if ( strcmp(a->name, fname) == 0 )
{ if ( chr > META_OFFSET )

View File

@ -1,4 +1,4 @@
/* $Id: history.c,v 1.1 2008-03-27 00:41:33 vsc Exp $
/* $Id$
Part of SWI-Prolog
@ -19,13 +19,13 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define _MAKE_DLL 1
#undef _export
#include <windows.h>
#include <tchar.h>
#define _MAKE_DLL 1
#undef _export
#include "console.h" /* public stuff */
#include "console_i.h" /* internal stuff */
#include <string.h>
@ -100,7 +100,7 @@ rlc_add_history(rlc_console c, const TCHAR *line)
{ b->history.current = -1;
return; /* same as last line added */
}
if ( i == b->history.tail ) /* this one is lost */
b->history.tail = next(b, b->history.tail);
b->history.head = i;
@ -120,6 +120,25 @@ rlc_add_history(rlc_console c, const TCHAR *line)
}
int
rlc_for_history(rlc_console c,
int (*handler)(void *ctx, int no, const TCHAR *line),
void *ctx)
{ RlcData b = rlc_get_data(c);
int here = b->history.head;
int no = 1;
for( ; here != b->history.tail; here = prev(b, here))
{ int rc;
if ( (rc=(*handler)(ctx, no++, b->history.lines[here])) != 0 )
return rc;
}
return 0;
}
int
rlc_at_head_history(RlcData b)
{ return b->history.current == -1 ? TRUE : FALSE;

View File

@ -1,4 +1,4 @@
/* $Id: history.h,v 1.1 2008-04-01 08:52:50 vsc Exp $
/* $Id$
Part of SWI-Prolog
@ -19,7 +19,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* history.c */

View File

@ -1,4 +1,4 @@
/* $Id: menu.c,v 1.1 2008-03-27 00:41:33 vsc Exp $
/* $Id$
Part of SWI-Prolog
@ -19,12 +19,13 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <windows.h>
#include <tchar.h>
#define _MAKE_DLL
#define _MAKE_DLL 1
#undef _export
#include "console.h"
#include "console_i.h"
#include "menu.h"
@ -83,7 +84,7 @@ lookupMenuLabel(const TCHAR *label)
llen = _tcslen(label);
menuids[nmenus] = rlc_malloc((llen+1)*sizeof(TCHAR));
_tcsncpy(menuids[nmenus], label, llen+1);
return nmenus++ + IDM_USER;
}
@ -109,7 +110,7 @@ insertMenu(HMENU in, const TCHAR *label, const TCHAR *before)
AppendMenu(in, MF_SEPARATOR, 0, NULL);
else
{ UINT id = lookupMenuLabel(label);
AppendMenu(in, MF_STRING, id, label);
}
} else
@ -199,15 +200,15 @@ rlc_add_menu_bar(HWND cwin)
/*append_builtin(edit, IDM_CUT);*/
append_builtin(edit, IDM_COPY);
append_builtin(edit, IDM_PASTE);
append_builtin(settings, IDM_FONT);
append_builtin(run, IDM_BREAK);
AppendMenu(menu, MF_POPUP, (UINT)file, _T("&File"));
AppendMenu(menu, MF_POPUP, (UINT)edit, _T("&Edit"));
AppendMenu(menu, MF_POPUP, (UINT)settings, _T("&Settings"));
AppendMenu(menu, MF_POPUP, (UINT)run, _T("&Run"));
AppendMenu(menu, MF_POPUP, (UINT_PTR)file, _T("&File"));
AppendMenu(menu, MF_POPUP, (UINT_PTR)edit, _T("&Edit"));
AppendMenu(menu, MF_POPUP, (UINT_PTR)settings, _T("&Settings"));
AppendMenu(menu, MF_POPUP, (UINT_PTR)run, _T("&Run"));
SetMenu(cwin, menu);
}
@ -218,13 +219,22 @@ rlc_add_menu_bar(HWND cwin)
#define MEN_MAGIC 0x6c4a58e0
typedef struct menu_data
{ intptr_t magic; /* safety */
const TCHAR *menu; /* menu to operate on */
const TCHAR *label; /* new label */
const TCHAR *before; /* add before this one */
int rc; /* result */
} menu_data;
void
rlc_menu_action(rlc_console c, menu_data *data)
{ RlcData b = rlc_get_data(c);
if ( !data || !data->magic == MEN_MAGIC )
return;
if ( data->menu ) /* rlc_insert_menu_item() */
{ HMENU popup;
@ -255,7 +265,7 @@ rlc_menu_action(rlc_console c, menu_data *data)
info.hSubMenu = CreatePopupMenu();
info.dwTypeData = (TCHAR *)data->label;
info.cch = (int)_tcslen(data->label);
InsertMenuItem(mb, bid, TRUE, &info);
/* force redraw; not automatic! */
DrawMenuBar(hwnd);

View File

@ -1,4 +1,4 @@
/* $Id: menu.h,v 1.1 2008-04-01 08:50:44 vsc Exp $
/* $Id$
Part of SWI-Prolog
@ -19,7 +19,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* see also console.c */
@ -35,14 +35,7 @@
#define IDM_BREAK 14
#define IDM_FONT 15
typedef struct menu_data
{ intptr_t magic; /* safety */
const TCHAR *menu; /* menu to operate on */
const TCHAR *label; /* new label */
const TCHAR *before; /* add before this one */
int rc; /* result */
} menu_data;
struct menu_data;
const TCHAR *lookupMenuId(UINT id);
void rlc_add_menu_bar(HWND win);

View File

@ -1,4 +1,4 @@
/* $Id: registry.c,v 1.1 2008-03-27 00:41:33 vsc Exp $
/* $Id$
Part of SWI-Prolog
@ -19,7 +19,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <windows.h>