Merge branch 'master' of git.dcc.fc.up.pt:yap-6.3
Conflicts: configure configure.in
This commit is contained in:
commit
0ab280ad25
51
configure
vendored
51
configure
vendored
@ -5230,8 +5230,49 @@ then
|
|||||||
if test "$cygwin" = "no" -o "$target_os" = "mingw32"
|
if test "$cygwin" = "no" -o "$target_os" = "mingw32"
|
||||||
then
|
then
|
||||||
# locale complaints without this.
|
# locale complaints without this.
|
||||||
|
if test "$threads" = yes; then
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lmscrt" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpthread" >&5
|
||||||
|
$as_echo_n "checking for main in -lpthread... " >&6; }
|
||||||
|
if ${ac_cv_lib_pthread_main+:} false; then :
|
||||||
|
$as_echo_n "(cached) " >&6
|
||||||
|
else
|
||||||
|
ac_check_lib_save_LIBS=$LIBS
|
||||||
|
LIBS="-lpthread $LIBS"
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
return main ();
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_ACEOF
|
||||||
|
if ac_fn_c_try_link "$LINENO"; then :
|
||||||
|
ac_cv_lib_pthread_main=yes
|
||||||
|
else
|
||||||
|
ac_cv_lib_pthread_main=no
|
||||||
|
fi
|
||||||
|
rm -f core conftest.err conftest.$ac_objext \
|
||||||
|
conftest$ac_exeext conftest.$ac_ext
|
||||||
|
LIBS=$ac_check_lib_save_LIBS
|
||||||
|
fi
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_main" >&5
|
||||||
|
$as_echo "$ac_cv_lib_pthread_main" >&6; }
|
||||||
|
if test "x$ac_cv_lib_pthread_main" = xyes; then :
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define HAVE_LIBPTHREAD 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
LIBS="-lpthread $LIBS"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lmscrt" >&5
|
||||||
$as_echo_n "checking for main in -lmscrt... " >&6; }
|
$as_echo_n "checking for main in -lmscrt... " >&6; }
|
||||||
if ${ac_cv_lib_mscrt_main+:} false; then :
|
if ${ac_cv_lib_mscrt_main+:} false; then :
|
||||||
$as_echo_n "(cached) " >&6
|
$as_echo_n "(cached) " >&6
|
||||||
@ -12102,7 +12143,7 @@ else
|
|||||||
JAVA_TEST=Test.java
|
JAVA_TEST=Test.java
|
||||||
CLASS_TEST=Test.class
|
CLASS_TEST=Test.class
|
||||||
cat << \EOF > $JAVA_TEST
|
cat << \EOF > $JAVA_TEST
|
||||||
/* #line 12105 "configure" */
|
/* #line 12146 "configure" */
|
||||||
public class Test {
|
public class Test {
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
@ -12278,7 +12319,7 @@ EOF
|
|||||||
if uudecode$EXEEXT Test.uue; then
|
if uudecode$EXEEXT Test.uue; then
|
||||||
ac_cv_prog_uudecode_base64=yes
|
ac_cv_prog_uudecode_base64=yes
|
||||||
else
|
else
|
||||||
echo "configure: 12281: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
|
echo "configure: 12322: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
|
||||||
echo "configure: failed file was:" >&5
|
echo "configure: failed file was:" >&5
|
||||||
cat Test.uue >&5
|
cat Test.uue >&5
|
||||||
ac_cv_prog_uudecode_base64=no
|
ac_cv_prog_uudecode_base64=no
|
||||||
@ -12409,7 +12450,7 @@ else
|
|||||||
JAVA_TEST=Test.java
|
JAVA_TEST=Test.java
|
||||||
CLASS_TEST=Test.class
|
CLASS_TEST=Test.class
|
||||||
cat << \EOF > $JAVA_TEST
|
cat << \EOF > $JAVA_TEST
|
||||||
/* #line 12412 "configure" */
|
/* #line 12453 "configure" */
|
||||||
public class Test {
|
public class Test {
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
@ -12444,7 +12485,7 @@ JAVA_TEST=Test.java
|
|||||||
CLASS_TEST=Test.class
|
CLASS_TEST=Test.class
|
||||||
TEST=Test
|
TEST=Test
|
||||||
cat << \EOF > $JAVA_TEST
|
cat << \EOF > $JAVA_TEST
|
||||||
/* [#]line 12447 "configure" */
|
/* [#]line 12488 "configure" */
|
||||||
public class Test {
|
public class Test {
|
||||||
public static void main (String args[]) {
|
public static void main (String args[]) {
|
||||||
System.exit (0);
|
System.exit (0);
|
||||||
|
@ -498,6 +498,9 @@ then
|
|||||||
if test "$cygwin" = "no" -o "$target_os" = "mingw32"
|
if test "$cygwin" = "no" -o "$target_os" = "mingw32"
|
||||||
then
|
then
|
||||||
# locale complaints without this.
|
# locale complaints without this.
|
||||||
|
if test "$threads" = yes; then
|
||||||
|
AC_CHECK_LIB(pthread, main)
|
||||||
|
fi
|
||||||
AC_CHECK_LIB(mscrt,main)
|
AC_CHECK_LIB(mscrt,main)
|
||||||
if test "$target_cpu" = x86_64; then
|
if test "$target_cpu" = x86_64; then
|
||||||
YAP_TARGET=amd64
|
YAP_TARGET=amd64
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id$
|
/* $Id$
|
||||||
|
|
||||||
Part of SWI-Prolog
|
Part of SWI-Prolog
|
||||||
|
|
||||||
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
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
|
#define WINDOWS_LEAN_AND_MEAN 1
|
||||||
@ -43,6 +43,10 @@ typedef enum
|
|||||||
CMD_ANSI
|
CMD_ANSI
|
||||||
} astate;
|
} astate;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{ HDL_CONSOLE = 0,
|
||||||
|
HDL_FILE
|
||||||
|
} htype;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{ int magic;
|
{ int magic;
|
||||||
@ -57,6 +61,7 @@ typedef struct
|
|||||||
int argstat;
|
int argstat;
|
||||||
astate cmdstat; /* State for sequence processing */
|
astate cmdstat; /* State for sequence processing */
|
||||||
WORD def_attr; /* Default attributes */
|
WORD def_attr; /* Default attributes */
|
||||||
|
htype handletype; /* Type of stream handle */
|
||||||
} ansi_stream;
|
} ansi_stream;
|
||||||
|
|
||||||
|
|
||||||
@ -85,11 +90,19 @@ flush_ansi(ansi_stream *as)
|
|||||||
{ BOOL rc;
|
{ BOOL rc;
|
||||||
DWORD done;
|
DWORD done;
|
||||||
|
|
||||||
rc = WriteConsoleW(as->hConsole,
|
if (as->handletype == HDL_CONSOLE)
|
||||||
|
{ rc = WriteConsoleW(as->hConsole,
|
||||||
&as->buffer[written],
|
&as->buffer[written],
|
||||||
(DWORD)(as->buffered-written),
|
(DWORD)(as->buffered-written),
|
||||||
&done,
|
&done,
|
||||||
NULL);
|
NULL);
|
||||||
|
} else
|
||||||
|
{ rc = WriteFile(as->hConsole,
|
||||||
|
&as->buffer[written],
|
||||||
|
(DWORD)(as->buffered-written),
|
||||||
|
&done,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if ( rc )
|
if ( rc )
|
||||||
{ written += done;
|
{ written += done;
|
||||||
@ -347,7 +360,20 @@ control_ansi(void *handle, int op, void *data)
|
|||||||
case SIO_SETENCODING:
|
case SIO_SETENCODING:
|
||||||
return -1; /* We cannot change the encoding! */
|
return -1; /* We cannot change the encoding! */
|
||||||
case SIO_LASTERROR:
|
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:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -402,10 +428,16 @@ error:
|
|||||||
static int
|
static int
|
||||||
wrap_console(HANDLE h, IOSTREAM *s, IOFUNCTIONS *funcs)
|
wrap_console(HANDLE h, IOSTREAM *s, IOFUNCTIONS *funcs)
|
||||||
{ ansi_stream *as;
|
{ ansi_stream *as;
|
||||||
|
DWORD mode;
|
||||||
|
|
||||||
as = PL_malloc(sizeof(*as));
|
as = PL_malloc(sizeof(*as));
|
||||||
memset(as, 0, sizeof(*as));
|
memset(as, 0, sizeof(*as));
|
||||||
|
|
||||||
|
if (GetConsoleMode(h, &mode))
|
||||||
|
as->handletype = HDL_CONSOLE;
|
||||||
|
else
|
||||||
|
as->handletype = HDL_FILE;
|
||||||
|
|
||||||
as->hConsole = h;
|
as->hConsole = h;
|
||||||
as->pStream = s;
|
as->pStream = s;
|
||||||
as->saved_handle = s->handle;
|
as->saved_handle = s->handle;
|
||||||
@ -413,6 +445,7 @@ wrap_console(HANDLE h, IOSTREAM *s, IOFUNCTIONS *funcs)
|
|||||||
s->handle = as;
|
s->handle = as;
|
||||||
s->encoding = ENC_WCHAR;
|
s->encoding = ENC_WCHAR;
|
||||||
s->functions = funcs;
|
s->functions = funcs;
|
||||||
|
s->flags &= ~SIO_FILE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
/* $Id$
|
/* Part of SWI-Prolog
|
||||||
|
|
||||||
Part of SWI-Prolog
|
|
||||||
|
|
||||||
Author: Jan Wielemaker
|
Author: Jan Wielemaker
|
||||||
E-mail: jan@swi.psy.uva.nl
|
E-mail: J.Wielemaker@cs.vu.nl
|
||||||
WWW: http://www.swi-prolog.org
|
WWW: http://www.swi-prolog.org
|
||||||
Copyright (C): 1985-2002, University of Amsterdam
|
Copyright (C): 1985-2013, University of Amsterdam
|
||||||
|
VU University Amsterdam
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
@ -19,9 +18,18 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
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 _UNICODE 1
|
||||||
|
#define UNICODE 1
|
||||||
|
|
||||||
|
#ifdef WIN64
|
||||||
|
#include "config/win64.h"
|
||||||
|
#else
|
||||||
|
#include "config/win32.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
@ -45,19 +53,22 @@
|
|||||||
#define streq(s,q) (strcmp((s), (q)) == 0)
|
#define streq(s,q) (strcmp((s), (q)) == 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _TINT
|
||||||
|
typedef wint_t _TINT;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Main program for running SWI-Prolog from a window. The window provides
|
Main program for running SWI-Prolog from a window. The window provides
|
||||||
X11-xterm like features: scrollback for a predefined number of lines,
|
X11-xterm like features: scrollback for a predefined number of lines,
|
||||||
cut/paste and the GNU readline library for command-line editing.
|
cut/paste and the GNU readline library for command-line editing.
|
||||||
|
|
||||||
This module combines libpl.dll and plterm.dll with some glue to produce
|
This module combines swipl.dll and plterm.dll with some glue to produce
|
||||||
the final executable swipl-win.exe.
|
the final executable swipl-win.exe.
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
__declspec(dllexport) rlc_console PL_current_console();
|
__declspec(dllexport) rlc_console PL_current_console(void);
|
||||||
static int type_error(term_t actual, const char *expected);
|
__declspec(dllexport) int PL_set_menu_thread(void);
|
||||||
static int domain_error(term_t actual, const char *expected);
|
static HWND create_prolog_hidden_window(rlc_console c, int replace);
|
||||||
static HWND create_prolog_hidden_window(rlc_console c);
|
|
||||||
static int get_chars_arg_ex(int a, term_t t, TCHAR **v);
|
static int get_chars_arg_ex(int a, term_t t, TCHAR **v);
|
||||||
|
|
||||||
#define RLC_PROLOG_WINDOW RLC_VALUE(0) /* GetCurrentThreadID() */
|
#define RLC_PROLOG_WINDOW RLC_VALUE(0) /* GetCurrentThreadID() */
|
||||||
@ -67,10 +78,10 @@ static int get_chars_arg_ex(int a, term_t t, TCHAR **v);
|
|||||||
#define RLC_REGISTER RLC_VALUE(4) /* Trap destruction */
|
#define RLC_REGISTER RLC_VALUE(4) /* Trap destruction */
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
* CONSOLE ADM *
|
* CONSOLE ADMIN *
|
||||||
*******************************/
|
*******************************/
|
||||||
|
|
||||||
CRITICAL_SECTION mutex;
|
static CRITICAL_SECTION mutex;
|
||||||
#define LOCK() EnterCriticalSection(&mutex)
|
#define LOCK() EnterCriticalSection(&mutex)
|
||||||
#define UNLOCK() LeaveCriticalSection(&mutex)
|
#define UNLOCK() LeaveCriticalSection(&mutex)
|
||||||
|
|
||||||
@ -125,7 +136,7 @@ registerConsole(rlc_console c)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
closeConsoles()
|
closeConsoles(void)
|
||||||
{ int i;
|
{ int i;
|
||||||
rlc_console *p;
|
rlc_console *p;
|
||||||
|
|
||||||
@ -151,11 +162,12 @@ static ssize_t
|
|||||||
Srlc_read(void *handle, char *buffer, size_t size)
|
Srlc_read(void *handle, char *buffer, size_t size)
|
||||||
{ rlc_console c = handle;
|
{ rlc_console c = handle;
|
||||||
size_t bytes;
|
size_t bytes;
|
||||||
|
int is_user_input = (Suser_input && Suser_input->handle == c);
|
||||||
|
term_t ex;
|
||||||
|
|
||||||
PL_write_prompt(TRUE);
|
PL_write_prompt(TRUE);
|
||||||
|
|
||||||
if ( Suser_input &&
|
if ( is_user_input &&
|
||||||
Suser_input->handle == c &&
|
|
||||||
PL_ttymode(Suser_input) == PL_RAWTTY )
|
PL_ttymode(Suser_input) == PL_RAWTTY )
|
||||||
{ int chr = getkey(c);
|
{ int chr = getkey(c);
|
||||||
TCHAR *tbuf = (TCHAR*)buffer;
|
TCHAR *tbuf = (TCHAR*)buffer;
|
||||||
@ -171,6 +183,11 @@ Srlc_read(void *handle, char *buffer, size_t size)
|
|||||||
bytes *= sizeof(TCHAR);
|
bytes *= sizeof(TCHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( is_user_input && (ex=PL_exception(0)) )
|
||||||
|
{ Sset_exception(Suser_input, ex);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if ( bytes == 0 || buffer[bytes-1] == '\n' )
|
if ( bytes == 0 || buffer[bytes-1] == '\n' )
|
||||||
PL_prompt_next(0);
|
PL_prompt_next(0);
|
||||||
|
|
||||||
@ -186,6 +203,10 @@ The flushing code will remember `half' characters and re-send them as
|
|||||||
more data comes ready. This means however that after a put_byte(X), the
|
more data comes ready. This means however that after a put_byte(X), the
|
||||||
wchar_t stream is out-of-sync and produces unreadable output. We will
|
wchar_t stream is out-of-sync and produces unreadable output. We will
|
||||||
therefore pad it with '?' characters to re-sync the stream.
|
therefore pad it with '?' characters to re-sync the stream.
|
||||||
|
|
||||||
|
The downside of this is that Sputc() and Sputcode() do not work on
|
||||||
|
unbuffered streams and thus Serror must be locked before using these
|
||||||
|
functions.
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
@ -193,18 +214,7 @@ Srlc_write(void *handle, char *buffer, size_t size)
|
|||||||
{ rlc_console c = handle;
|
{ rlc_console c = handle;
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
|
||||||
if (size==1) {
|
|
||||||
TCHAR buf ='\0';
|
|
||||||
char *bufp = (char *)&buf;
|
|
||||||
|
|
||||||
if (!buffer[0]) return 1;
|
|
||||||
bufp[0] = buffer[0];
|
|
||||||
size = sizeof(TCHAR);
|
|
||||||
n = rlc_write(c, &buf, size/sizeof(TCHAR));
|
|
||||||
return (n ? 1 : 0);
|
|
||||||
} else {
|
|
||||||
n = rlc_write(c, (TCHAR*)buffer, size/sizeof(TCHAR));
|
n = rlc_write(c, (TCHAR*)buffer, size/sizeof(TCHAR));
|
||||||
}
|
|
||||||
n *= sizeof(TCHAR);
|
n *= sizeof(TCHAR);
|
||||||
|
|
||||||
if ( n < (ssize_t)size && size-n < sizeof(TCHAR) )
|
if ( n < (ssize_t)size && size-n < sizeof(TCHAR) )
|
||||||
@ -285,6 +295,10 @@ rlc_bind_terminal(rlc_console c)
|
|||||||
Sinput->encoding = ENC_WCHAR;
|
Sinput->encoding = ENC_WCHAR;
|
||||||
Soutput->encoding = ENC_WCHAR;
|
Soutput->encoding = ENC_WCHAR;
|
||||||
Serror->encoding = ENC_WCHAR;
|
Serror->encoding = ENC_WCHAR;
|
||||||
|
|
||||||
|
Sinput->flags &= ~SIO_FILE;
|
||||||
|
Soutput->flags &= ~SIO_FILE;
|
||||||
|
Serror->flags &= ~SIO_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -299,7 +313,7 @@ process_console_options(rlc_console_attr *attr, term_t options)
|
|||||||
int arity;
|
int arity;
|
||||||
|
|
||||||
if ( !PL_get_name_arity(opt, &name, &arity) )
|
if ( !PL_get_name_arity(opt, &name, &arity) )
|
||||||
return type_error(opt, "compound");
|
return PL_type_error("compound", opt);
|
||||||
s = PL_atom_chars(name);
|
s = PL_atom_chars(name);
|
||||||
if ( streq(s, "registry_key") && arity == 1 )
|
if ( streq(s, "registry_key") && arity == 1 )
|
||||||
{ TCHAR *key;
|
{ TCHAR *key;
|
||||||
@ -309,10 +323,10 @@ process_console_options(rlc_console_attr *attr, term_t options)
|
|||||||
|
|
||||||
attr->key = key;
|
attr->key = key;
|
||||||
} else
|
} else
|
||||||
return domain_error(opt, "window_option");
|
return PL_domain_error("window_option", opt);
|
||||||
}
|
}
|
||||||
if ( !PL_get_nil(tail) )
|
if ( !PL_get_nil_ex(tail) )
|
||||||
return type_error(tail, "list");
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -336,15 +350,15 @@ pl_win_open_console(term_t title, term_t input, term_t output, term_t error,
|
|||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
memset(&attr, 0, sizeof(attr));
|
memset(&attr, 0, sizeof(attr));
|
||||||
if ( !PL_get_wchars(title, &len, &s, CVT_ALL|BUF_RING) )
|
if ( !PL_get_wchars(title, &len, &s, CVT_ALL|BUF_RING|CVT_EXCEPTION) )
|
||||||
return type_error(title, "text");
|
return FALSE;
|
||||||
attr.title = (const TCHAR*) s;
|
attr.title = (const TCHAR*) s;
|
||||||
|
|
||||||
if ( !process_console_options(&attr, options) )
|
if ( !process_console_options(&attr, options) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
c = rlc_create_console(&attr);
|
c = rlc_create_console(&attr);
|
||||||
create_prolog_hidden_window(c); /* for sending messages */
|
create_prolog_hidden_window(c, FALSE); /* for sending messages */
|
||||||
registerConsole(c);
|
registerConsole(c);
|
||||||
|
|
||||||
#define STREAM_COMMON (SIO_TEXT| /* text-stream */ \
|
#define STREAM_COMMON (SIO_TEXT| /* text-stream */ \
|
||||||
@ -394,7 +408,7 @@ pl_rl_add_history(term_t text)
|
|||||||
{ atom_t a;
|
{ atom_t a;
|
||||||
static atom_t last = 0;
|
static atom_t last = 0;
|
||||||
|
|
||||||
if ( PL_get_atom(text, &a) )
|
if ( PL_get_atom_ex(text, &a) )
|
||||||
{ if ( a != last )
|
{ if ( a != last )
|
||||||
{ TCHAR *s;
|
{ TCHAR *s;
|
||||||
|
|
||||||
@ -403,8 +417,7 @@ pl_rl_add_history(term_t text)
|
|||||||
last = a;
|
last = a;
|
||||||
PL_register_atom(last);
|
PL_register_atom(last);
|
||||||
|
|
||||||
PL_get_wchars(text, NULL, &s, CVT_ATOM);
|
if ( PL_get_wchars(text, NULL, &s, CVT_ATOM) )
|
||||||
|
|
||||||
rlc_add_history(PL_current_console(), s);
|
rlc_add_history(PL_current_console(), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,6 +428,35 @@ pl_rl_add_history(term_t text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
add_line(void *h, int no, const TCHAR *line)
|
||||||
|
{ term_t tail = (term_t)h;
|
||||||
|
term_t head = PL_new_term_ref();
|
||||||
|
|
||||||
|
if ( !PL_unify_wchars(head, PL_ATOM, (size_t)-1, line) ||
|
||||||
|
!PL_cons_list(tail, head, tail) )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
PL_reset_term_refs(head);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static foreign_t
|
||||||
|
pl_rl_history(term_t list)
|
||||||
|
{ term_t tail = PL_new_term_ref();
|
||||||
|
|
||||||
|
if ( !PL_unify_nil(tail) )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if ( rlc_for_history(PL_current_console(), add_line, (void*)tail) == 0 )
|
||||||
|
return PL_unify(tail, list);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static foreign_t
|
static foreign_t
|
||||||
pl_rl_read_init_file(term_t file)
|
pl_rl_read_init_file(term_t file)
|
||||||
{ PL_succeed;
|
{ PL_succeed;
|
||||||
@ -506,13 +548,26 @@ PL_current_console(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static rlc_console main_console;
|
||||||
|
|
||||||
|
int
|
||||||
|
PL_set_menu_thread(void)
|
||||||
|
{ if ( main_console )
|
||||||
|
{ create_prolog_hidden_window(main_console, TRUE);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
foreign_t
|
foreign_t
|
||||||
pl_window_title(term_t old, term_t new)
|
pl_window_title(term_t old, term_t new)
|
||||||
{ TCHAR buf[256];
|
{ TCHAR buf[256];
|
||||||
TCHAR *n;
|
TCHAR *n;
|
||||||
|
|
||||||
if ( !PL_get_wchars(new, NULL, &n, CVT_ALL) )
|
if ( !PL_get_wchars(new, NULL, &n, CVT_ALL|CVT_EXCEPTION) )
|
||||||
return type_error(new, "atom");
|
return FALSE;
|
||||||
|
|
||||||
rlc_title(PL_current_console(), n, buf, sizeof(buf)/sizeof(TCHAR));
|
rlc_title(PL_current_console(), n, buf, sizeof(buf)/sizeof(TCHAR));
|
||||||
|
|
||||||
@ -520,41 +575,15 @@ pl_window_title(term_t old, term_t new)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
type_error(term_t actual, const char *expected)
|
|
||||||
{ term_t ex = PL_new_term_ref();
|
|
||||||
|
|
||||||
PL_unify_term(ex, PL_FUNCTOR_CHARS, "error", 2,
|
|
||||||
PL_FUNCTOR_CHARS, "type_error", 2,
|
|
||||||
PL_CHARS, expected,
|
|
||||||
PL_TERM, actual,
|
|
||||||
PL_VARIABLE);
|
|
||||||
|
|
||||||
return PL_raise_exception(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
domain_error(term_t actual, const char *expected)
|
|
||||||
{ term_t ex = PL_new_term_ref();
|
|
||||||
|
|
||||||
PL_unify_term(ex, PL_FUNCTOR_CHARS, "error", 2,
|
|
||||||
PL_FUNCTOR_CHARS, "domain_error", 2,
|
|
||||||
PL_CHARS, expected,
|
|
||||||
PL_TERM, actual,
|
|
||||||
PL_VARIABLE);
|
|
||||||
|
|
||||||
return PL_raise_exception(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_chars_arg_ex(int a, term_t t, TCHAR **v)
|
get_chars_arg_ex(int a, term_t t, TCHAR **v)
|
||||||
{ term_t arg = PL_new_term_ref();
|
{ term_t arg = PL_new_term_ref();
|
||||||
|
|
||||||
if ( PL_get_arg(a, t, arg) &&
|
if ( PL_get_arg(a, t, arg) &&
|
||||||
PL_get_wchars(arg, NULL, v, CVT_ALL|BUF_RING) )
|
PL_get_wchars(arg, NULL, v, CVT_ALL|BUF_RING|CVT_EXCEPTION) )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
return type_error(arg, "text");
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -562,11 +591,11 @@ static int
|
|||||||
get_int_arg_ex(int a, term_t t, int *v)
|
get_int_arg_ex(int a, term_t t, int *v)
|
||||||
{ term_t arg = PL_new_term_ref();
|
{ term_t arg = PL_new_term_ref();
|
||||||
|
|
||||||
PL_get_arg(a, t, arg);
|
_PL_get_arg(a, t, arg);
|
||||||
if ( PL_get_integer(arg, v) )
|
if ( PL_get_integer_ex(arg, v) )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
return type_error(arg, "integer");
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -574,11 +603,11 @@ static int
|
|||||||
get_bool_arg_ex(int a, term_t t, int *v)
|
get_bool_arg_ex(int a, term_t t, int *v)
|
||||||
{ term_t arg = PL_new_term_ref();
|
{ term_t arg = PL_new_term_ref();
|
||||||
|
|
||||||
PL_get_arg(a, t, arg);
|
_PL_get_arg(a, t, arg);
|
||||||
if ( PL_get_bool(arg, v) )
|
if ( PL_get_bool_ex(arg, v) )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
return type_error(arg, "boolean");
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -596,7 +625,7 @@ pl_window_pos(term_t options)
|
|||||||
int arity;
|
int arity;
|
||||||
|
|
||||||
if ( !PL_get_name_arity(opt, &name, &arity) )
|
if ( !PL_get_name_arity(opt, &name, &arity) )
|
||||||
return type_error(opt, "compound");
|
return PL_type_error("compound", opt);
|
||||||
s = PL_atom_chars(name);
|
s = PL_atom_chars(name);
|
||||||
if ( streq(s, "position") && arity == 2 )
|
if ( streq(s, "position") && arity == 2 )
|
||||||
{ if ( !get_int_arg_ex(1, opt, &x) ||
|
{ if ( !get_int_arg_ex(1, opt, &x) ||
|
||||||
@ -612,9 +641,9 @@ pl_window_pos(term_t options)
|
|||||||
{ term_t t = PL_new_term_ref();
|
{ term_t t = PL_new_term_ref();
|
||||||
char *v;
|
char *v;
|
||||||
|
|
||||||
PL_get_arg(1, opt, t);
|
_PL_get_arg(1, opt, t);
|
||||||
if ( !PL_get_atom_chars(t, &v) )
|
if ( !PL_get_chars(t, &v, CVT_ATOM|CVT_EXCEPTION) )
|
||||||
return type_error(t, "atom");
|
return FALSE;
|
||||||
if ( streq(v, "top") )
|
if ( streq(v, "top") )
|
||||||
z = HWND_TOP;
|
z = HWND_TOP;
|
||||||
else if ( streq(v, "bottom") )
|
else if ( streq(v, "bottom") )
|
||||||
@ -624,7 +653,7 @@ pl_window_pos(term_t options)
|
|||||||
else if ( streq(v, "notopmost") )
|
else if ( streq(v, "notopmost") )
|
||||||
z = HWND_NOTOPMOST;
|
z = HWND_NOTOPMOST;
|
||||||
else
|
else
|
||||||
return domain_error(t, "hwnd_insert_after");
|
return PL_domain_error("hwnd_insert_after", t);
|
||||||
|
|
||||||
flags &= ~SWP_NOZORDER;
|
flags &= ~SWP_NOZORDER;
|
||||||
} else if ( streq(s, "show") && arity == 1 )
|
} else if ( streq(s, "show") && arity == 1 )
|
||||||
@ -640,10 +669,10 @@ pl_window_pos(term_t options)
|
|||||||
} else if ( streq(s, "activate") && arity == 0 )
|
} else if ( streq(s, "activate") && arity == 0 )
|
||||||
{ flags &= ~SWP_NOACTIVATE;
|
{ flags &= ~SWP_NOACTIVATE;
|
||||||
} else
|
} else
|
||||||
return domain_error(opt, "window_option");
|
return PL_domain_error("window_option", opt);
|
||||||
}
|
}
|
||||||
if ( !PL_get_nil(tail) )
|
if ( !PL_get_nil_ex(tail) )
|
||||||
return type_error(tail, "list");
|
return FALSE;
|
||||||
|
|
||||||
rlc_window_pos(PL_current_console(), z, x, y, w, h, flags);
|
rlc_window_pos(PL_current_console(), z, x, y, w, h, flags);
|
||||||
|
|
||||||
@ -654,12 +683,12 @@ pl_window_pos(term_t options)
|
|||||||
static void
|
static void
|
||||||
call_menu(const TCHAR *name)
|
call_menu(const TCHAR *name)
|
||||||
{ fid_t fid = PL_open_foreign_frame();
|
{ fid_t fid = PL_open_foreign_frame();
|
||||||
predicate_t pred = PL_predicate("on_menu", 1, "system");
|
predicate_t pred = PL_predicate("on_menu", 1, "prolog");
|
||||||
module_t m = PL_new_module(PL_new_atom("system"));
|
module_t m = PL_new_module(PL_new_atom("prolog"));
|
||||||
term_t a0 = PL_new_term_ref();
|
term_t a0 = PL_new_term_ref();
|
||||||
size_t len = _tcslen(name);
|
size_t len = _tcslen(name);
|
||||||
|
|
||||||
PL_unify_wchars(a0, PL_ATOM, len, name);
|
if ( PL_unify_wchars(a0, PL_ATOM, len, name) )
|
||||||
PL_call_predicate(m, PL_Q_NORMAL, pred, a0);
|
PL_call_predicate(m, PL_Q_NORMAL, pred, a0);
|
||||||
|
|
||||||
PL_discard_foreign_frame(fid);
|
PL_discard_foreign_frame(fid);
|
||||||
@ -667,7 +696,7 @@ call_menu(const TCHAR *name)
|
|||||||
|
|
||||||
|
|
||||||
foreign_t
|
foreign_t
|
||||||
pl_win_insert_menu_item(term_t menu, term_t label, term_t before)
|
pl_win_insert_menu_item(foreign_t menu, foreign_t label, foreign_t before)
|
||||||
{ TCHAR *m, *l, *b;
|
{ TCHAR *m, *l, *b;
|
||||||
|
|
||||||
if ( !PL_get_wchars(menu, NULL, &m, CVT_ATOM) ||
|
if ( !PL_get_wchars(menu, NULL, &m, CVT_ATOM) ||
|
||||||
@ -685,7 +714,7 @@ pl_win_insert_menu_item(term_t menu, term_t label, term_t before)
|
|||||||
|
|
||||||
|
|
||||||
foreign_t
|
foreign_t
|
||||||
pl_win_insert_menu(term_t label, term_t before)
|
pl_win_insert_menu(foreign_t label, foreign_t before)
|
||||||
{ TCHAR *l, *b;
|
{ TCHAR *l, *b;
|
||||||
|
|
||||||
if ( !PL_get_wchars(label, NULL, &l, CVT_ATOM) ||
|
if ( !PL_get_wchars(label, NULL, &l, CVT_ATOM) ||
|
||||||
@ -713,8 +742,10 @@ free_interactor(void *closure)
|
|||||||
static void *
|
static void *
|
||||||
run_interactor(void *closure)
|
run_interactor(void *closure)
|
||||||
{ predicate_t pred;
|
{ predicate_t pred;
|
||||||
|
PL_thread_attr_t attr = {0};
|
||||||
|
|
||||||
PL_thread_attach_engine(NULL);
|
attr.flags = PL_THREAD_NO_DEBUG;
|
||||||
|
PL_thread_attach_engine(&attr);
|
||||||
pthread_cleanup_push(free_interactor, NULL);
|
pthread_cleanup_push(free_interactor, NULL);
|
||||||
|
|
||||||
|
|
||||||
@ -765,13 +796,14 @@ pl_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
|
|
||||||
static TCHAR *
|
static TCHAR *
|
||||||
HiddenFrameClass(void)
|
HiddenFrameClass()
|
||||||
{ static TCHAR winclassname[32];
|
{ static TCHAR winclassname[32];
|
||||||
static WNDCLASS wndClass;
|
static WNDCLASS wndClass;
|
||||||
HINSTANCE instance = rlc_hinstance();
|
HINSTANCE instance = rlc_hinstance();
|
||||||
|
|
||||||
if ( !winclassname[0] )
|
if ( !winclassname[0] )
|
||||||
{ _stprintf(winclassname, _T("YAP-hidden-win%d"), instance);
|
{ snwprintf(winclassname, sizeof(winclassname)/sizeof(TCHAR),
|
||||||
|
_T("SWI-Prolog-hidden-win%d"), instance);
|
||||||
|
|
||||||
wndClass.style = 0;
|
wndClass.style = 0;
|
||||||
wndClass.lpfnWndProc = (LPVOID) pl_wnd_proc;
|
wndClass.lpfnWndProc = (LPVOID) pl_wnd_proc;
|
||||||
@ -780,7 +812,7 @@ HiddenFrameClass(void)
|
|||||||
wndClass.hInstance = instance;
|
wndClass.hInstance = instance;
|
||||||
wndClass.hIcon = NULL;
|
wndClass.hIcon = NULL;
|
||||||
wndClass.hCursor = NULL;
|
wndClass.hCursor = NULL;
|
||||||
// wndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
|
wndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
|
||||||
wndClass.lpszMenuName = NULL;
|
wndClass.lpszMenuName = NULL;
|
||||||
wndClass.lpszClassName = winclassname;
|
wndClass.lpszClassName = winclassname;
|
||||||
|
|
||||||
@ -798,11 +830,15 @@ destroy_hidden_window(uintptr_t hwnd)
|
|||||||
|
|
||||||
|
|
||||||
static HWND
|
static HWND
|
||||||
create_prolog_hidden_window(rlc_console c)
|
create_prolog_hidden_window(rlc_console c, int replace)
|
||||||
{ uintptr_t hwnd;
|
{ uintptr_t hwnd;
|
||||||
|
|
||||||
if ( rlc_get(c, RLC_PROLOG_WINDOW, &hwnd) && hwnd )
|
if ( rlc_get(c, RLC_PROLOG_WINDOW, &hwnd) && hwnd )
|
||||||
|
{ if ( replace )
|
||||||
|
DestroyWindow((HWND)hwnd);
|
||||||
|
else
|
||||||
return (HWND)hwnd;
|
return (HWND)hwnd;
|
||||||
|
}
|
||||||
|
|
||||||
hwnd = (uintptr_t)CreateWindow(HiddenFrameClass(),
|
hwnd = (uintptr_t)CreateWindow(HiddenFrameClass(),
|
||||||
_T("YAP hidden window"),
|
_T("YAP hidden window"),
|
||||||
@ -842,7 +878,7 @@ fatalSignal(int sig)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
initSignals(void)
|
initSignals()
|
||||||
{ signal(SIGABRT, fatalSignal);
|
{ signal(SIGABRT, fatalSignal);
|
||||||
signal(SIGFPE, fatalSignal);
|
signal(SIGFPE, fatalSignal);
|
||||||
signal(SIGILL, fatalSignal);
|
signal(SIGILL, fatalSignal);
|
||||||
@ -888,7 +924,7 @@ menu_select(rlc_console c, const TCHAR *name)
|
|||||||
{ uintptr_t hwnd;
|
{ uintptr_t hwnd;
|
||||||
|
|
||||||
if ( rlc_get(c, RLC_PROLOG_WINDOW, &hwnd) )
|
if ( rlc_get(c, RLC_PROLOG_WINDOW, &hwnd) )
|
||||||
PostMessage((HWND)hwnd, WM_MENU, 0, (LONG)name);
|
PostMessage((HWND)hwnd, WM_MENU, 0, (LPARAM)name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -925,7 +961,8 @@ set_window_title(rlc_console c)
|
|||||||
TCHAR *w64 = _T("");
|
TCHAR *w64 = _T("");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_stprintf(title, _T("YAP (%s%sversion %d.%d.%d)"),
|
snwprintf(title, sizeof(title)/sizeof(TCHAR),
|
||||||
|
_T("SWI-Prolog (%s%sversion %d.%d.%d)"),
|
||||||
w64, mt, major, minor, patch);
|
w64, mt, major, minor, patch);
|
||||||
|
|
||||||
rlc_title(c, title, NULL, 0);
|
rlc_title(c, title, NULL, 0);
|
||||||
@ -954,8 +991,12 @@ install_readline(rlc_console c)
|
|||||||
{ rlc_init_history(c, 50);
|
{ rlc_init_history(c, 50);
|
||||||
file_completer = rlc_complete_hook(do_complete);
|
file_completer = rlc_complete_hook(do_complete);
|
||||||
|
|
||||||
PL_register_foreign_in_module("system", "rl_add_history", 1, pl_rl_add_history, 0);
|
PL_register_foreign_in_module(
|
||||||
PL_register_foreign_in_module("system", "rl_read_init_file", 1, pl_rl_read_init_file, 0);
|
"system", "rl_add_history", 1, pl_rl_add_history, 0);
|
||||||
|
PL_register_foreign_in_module(
|
||||||
|
"system", "rl_read_init_file", 1, pl_rl_read_init_file, 0);
|
||||||
|
PL_register_foreign_in_module(
|
||||||
|
"system", "$rl_history", 1, pl_rl_history, 0);
|
||||||
|
|
||||||
PL_set_prolog_flag("tty_control", PL_BOOL, TRUE);
|
PL_set_prolog_flag("tty_control", PL_BOOL, TRUE);
|
||||||
PL_set_prolog_flag("readline", PL_BOOL, TRUE);
|
PL_set_prolog_flag("readline", PL_BOOL, TRUE);
|
||||||
@ -968,7 +1009,7 @@ install_readline(rlc_console c)
|
|||||||
|
|
||||||
static rlc_console main_console;
|
static rlc_console main_console;
|
||||||
|
|
||||||
static void
|
static int
|
||||||
closeWin(int s, void *a)
|
closeWin(int s, void *a)
|
||||||
{ rlc_console c = a;
|
{ rlc_console c = a;
|
||||||
|
|
||||||
@ -978,6 +1019,8 @@ closeWin(int s, void *a)
|
|||||||
{ main_console = NULL;
|
{ main_console = NULL;
|
||||||
rlc_close(c);
|
rlc_close(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_ARGC 100
|
#define MAX_ARGC 100
|
||||||
@ -1002,11 +1045,31 @@ win32main(rlc_console c, int argc, TCHAR **argv)
|
|||||||
{ char *av[MAX_ARGC+1];
|
{ char *av[MAX_ARGC+1];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
main_console = c;
|
||||||
set_window_title(c);
|
set_window_title(c);
|
||||||
rlc_bind_terminal(c);
|
rlc_bind_terminal(c);
|
||||||
|
|
||||||
/* YAP has to initialize before doing anything else */
|
PL_register_extensions_in_module("system", extensions);
|
||||||
#ifdef _YAP_NOT_INSTALLED_
|
install_readline(c);
|
||||||
|
PL_action(PL_ACTION_GUIAPP, TRUE);
|
||||||
|
main_console = c;
|
||||||
|
PL_on_halt(closeWin, c);
|
||||||
|
|
||||||
|
create_prolog_hidden_window(c, FALSE);
|
||||||
|
PL_set_prolog_flag("hwnd", PL_INTEGER, (intptr_t)rlc_hwnd(c));
|
||||||
|
rlc_interrupt_hook(interrupt);
|
||||||
|
rlc_menu_hook(menu_select);
|
||||||
|
rlc_message_hook(message_proc);
|
||||||
|
PL_set_prolog_flag("console_menu", PL_BOOL, TRUE);
|
||||||
|
#ifdef O_PLMT
|
||||||
|
rlc_insert_menu_item(c, _T("&Run"), _T("&New thread"), NULL);
|
||||||
|
#endif
|
||||||
|
#if !defined(O_DEBUG) && !defined(_DEBUG)
|
||||||
|
initSignals();
|
||||||
|
#endif
|
||||||
|
PL_register_foreign_in_module("system", "win_open_console", 5,
|
||||||
|
pl_win_open_console, 0);
|
||||||
|
|
||||||
if ( argc > MAX_ARGC )
|
if ( argc > MAX_ARGC )
|
||||||
argc = MAX_ARGC;
|
argc = MAX_ARGC;
|
||||||
for(i=0; i<argc; i++)
|
for(i=0; i<argc; i++)
|
||||||
@ -1023,30 +1086,7 @@ win32main(rlc_console c, int argc, TCHAR **argv)
|
|||||||
|
|
||||||
if ( !PL_initialise(argc, av) )
|
if ( !PL_initialise(argc, av) )
|
||||||
PL_halt(1);
|
PL_halt(1);
|
||||||
#endif
|
|
||||||
|
|
||||||
PL_register_extensions_in_module("system", extensions);
|
|
||||||
install_readline(c);
|
|
||||||
PL_action(PL_ACTION_GUIAPP, TRUE);
|
|
||||||
main_console = c;
|
|
||||||
PL_on_halt(closeWin, c);
|
|
||||||
|
|
||||||
create_prolog_hidden_window(c);
|
|
||||||
PL_set_prolog_flag("hwnd", PL_INTEGER, (intptr_t)rlc_hwnd(c));
|
|
||||||
rlc_interrupt_hook(interrupt);
|
|
||||||
rlc_menu_hook(menu_select);
|
|
||||||
rlc_message_hook(message_proc);
|
|
||||||
PL_set_prolog_flag("console_menu", PL_BOOL, TRUE);
|
|
||||||
#ifdef O_PLMT
|
|
||||||
rlc_insert_menu_item(c, _T("&Run"), _T("&New thread"), NULL);
|
|
||||||
#endif
|
|
||||||
#if !defined(O_DEBUG) && !defined(_DEBUG)
|
|
||||||
initSignals();
|
|
||||||
#endif
|
|
||||||
PL_register_foreign_in_module("prolog", "win_open_console", 5,
|
|
||||||
pl_win_open_console, 0);
|
|
||||||
|
|
||||||
rlc_bind_terminal(c);
|
|
||||||
PL_halt(PL_toplevel() ? 0 : 1);
|
PL_halt(PL_toplevel() ? 0 : 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1058,10 +1098,10 @@ And this is the real application's main as Windows sees it. See
|
|||||||
console.c for further details.
|
console.c for further details.
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
int WINAPI
|
int PASCAL
|
||||||
wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||||
LPWSTR lpszCmdLine, int nCmdShow)
|
LPSTR lpszCmdLine, int nCmdShow)
|
||||||
{ LPWSTR cmdline;
|
{ LPTSTR cmdline;
|
||||||
|
|
||||||
InitializeCriticalSection(&mutex);
|
InitializeCriticalSection(&mutex);
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ DIALECT_BP= \
|
|||||||
|
|
||||||
all:
|
all:
|
||||||
|
|
||||||
install: $(PROGRAMS) install-examples
|
install: $(PROGRAMS) $(DIALECT_PROGRAMS) $(DIALECT_SWI) $(DIALECT_BP) install-examples
|
||||||
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap
|
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap
|
||||||
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/dialect
|
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/dialect
|
||||||
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/dialect/swi
|
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/dialect/swi
|
||||||
@ -121,3 +121,11 @@ clean:
|
|||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -f *def Makefile
|
rm -f *def Makefile
|
||||||
|
|
||||||
|
|
||||||
|
##########
|
||||||
|
FULL_PATH_PL_SOURCES=$(PROGRAMS) $(DIALECT_PROGRAMS) $(DIALECT_SWI) $(DIALECT_BP)
|
||||||
|
|
||||||
|
TAGS: $(PROGRAMS) $(DIALECT_PROGRAMS) $(DIALECT_SWI) $(DIALECT_BP)
|
||||||
|
etags --append ../TAGS $(FULL_PATH_PL_SOURCES)
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ SOBJS=yap_mpi.@SO@
|
|||||||
|
|
||||||
all: $(SOBJS)
|
all: $(SOBJS)
|
||||||
|
|
||||||
yap_mpi.o: $(srcdir)/yap_mpi.c $(srcdir)/yap_mpi.c
|
yap_mpi.o: $(srcdir)/yap_mpi.c
|
||||||
$(MPI_CC) $(CFLAGS) $(MPICF) -c $(srcdir)/yap_mpi.c -o yap_mpi.o
|
$(MPI_CC) $(CFLAGS) $(MPICF) -c $(srcdir)/yap_mpi.c -o yap_mpi.o
|
||||||
|
|
||||||
prologterms2c.o: $(srcdir)/prologterms2c.c $(srcdir)/prologterms2c.h
|
prologterms2c.o: $(srcdir)/prologterms2c.c $(srcdir)/prologterms2c.h
|
||||||
@ -74,3 +74,10 @@ install-examples:
|
|||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -f Makefile
|
rm -f Makefile
|
||||||
|
|
||||||
|
FULL_PATH_C_SOURCES= $(srcdir)/yap_mpi.c $(srcdir)/prologterms2c.c $(srcdir)/hash.c
|
||||||
|
FULL_PATH_PL_SOURCES=
|
||||||
|
FULL_PATH_HEADERS=$(srcdir)/hash.h $(srcdir)/prologterms2c.h
|
||||||
|
|
||||||
|
TAGS: $(C_SOURCES) $(PL_SOURCES) $(HEADERS)
|
||||||
|
etags --append ../../TAGS $(FULL_PATH_C_SOURCES) $(FULL_PATH_PL_SOURCES) $(FULL_PATH_HEADERS)
|
||||||
|
@ -64,3 +64,4 @@ install-examples:
|
|||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -f Makefile
|
rm -f Makefile
|
||||||
|
|
||||||
|
@ -209,6 +209,7 @@ true :- true.
|
|||||||
'$swi_current_prolog_flag'(break_level, BreakLevel),
|
'$swi_current_prolog_flag'(break_level, BreakLevel),
|
||||||
( Breaklevel \= 0 -> true ; '$pred_exists'(halt(_), user) -> halt(0) ; '$halt'(0) ).
|
( Breaklevel \= 0 -> true ; '$pred_exists'(halt(_), user) -> halt(0) ; '$halt'(0) ).
|
||||||
'$enter_top_level' :-
|
'$enter_top_level' :-
|
||||||
|
flush_output,
|
||||||
'$run_toplevel_hooks',
|
'$run_toplevel_hooks',
|
||||||
prompt1(' ?- '),
|
prompt1(' ?- '),
|
||||||
'$read_toplevel'(Command,Varnames),
|
'$read_toplevel'(Command,Varnames),
|
||||||
|
@ -1,75 +1,53 @@
|
|||||||
#
|
################################################################
|
||||||
# default base directory for YAP installation
|
# Makefile for the SWI-Prolog console window.
|
||||||
# (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@
|
|
||||||
srcdir=@srcdir@
|
srcdir=@srcdir@
|
||||||
|
@VPATH@ @srcdir@
|
||||||
|
|
||||||
SOURCES= \
|
CC=@CC@
|
||||||
$(srcdir)/complete.c $(srcdir)/console.c \
|
LDEXE=@LDEXE@
|
||||||
$(srcdir)/edit.c $(srcdir)/history.c \
|
PLARCH=@PLARCH@
|
||||||
$(srcdir)/menu.c
|
XLIBS=@XLIBS@
|
||||||
HEADERS= \
|
SOEXT=@SO_EXT@
|
||||||
$(srcdir)/common.h $(srcdir)/console.h \
|
|
||||||
$(srcdir)/console_i.h $(srcdir)/history.h \
|
|
||||||
$(srcdir)/menu.h
|
|
||||||
|
|
||||||
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
|
OBJ= complete.o console.o edit.o history.o menu.o
|
||||||
$(CC) $(CFLAGS) -shared -o ../../plterm.dll \
|
OUT= $(PLHOME)/lib/$(PLARCH)/plterm.$(SOEXT)
|
||||||
-Wl,--export-all-symbols \
|
INCLDIR=$(PLHOME)/include
|
||||||
-Wl,--enable-auto-import \
|
HDR= $(INCLDIR)/console.h
|
||||||
-Wl,--whole-archive libplterm.a \
|
|
||||||
-Wl,--no-whole-archive $(LIBS) $(LDFLAGS)
|
|
||||||
|
|
||||||
libplterm.a: $(OBJECTS) $(SOURCES) $(HEADERS)
|
all: $(OUT) $(HDR)
|
||||||
-rm -f libplterm.a
|
|
||||||
$(AR) rc libplterm.a $(OBJECTS)
|
|
||||||
$(RANLIB) libplterm.a
|
|
||||||
|
|
||||||
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:
|
clean:
|
||||||
rm -f *.o *~ *.dll
|
rm -f *.o
|
||||||
|
rm -f *~
|
||||||
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
|
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
rm -f $(PLHOME)/lib/$(PLARCH)/plterm.$(SOEXT)
|
||||||
|
rm -f $(PLHOME)/lib/$(PLARCH)/plterm.$(SOEXT).a
|
||||||
|
rm -f $(INCLDIR)/console.h
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: common.h,v 1.1 2008-04-01 08:50:48 vsc Exp $
|
/* $Id$
|
||||||
|
|
||||||
Part of SWI-Prolog
|
Part of SWI-Prolog
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
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
|
#define IMODE_SWITCH_CHAR -2
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: complete.c,v 1.1 2008-03-27 00:41:33 vsc Exp $
|
/* $Id$
|
||||||
|
|
||||||
Part of SWI-Prolog
|
Part of SWI-Prolog
|
||||||
|
|
||||||
@ -19,21 +19,21 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
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 <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
|
||||||
#ifndef __TCHAR_DEFINED
|
|
||||||
typedef wint_t _TINT;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EOS
|
#ifndef EOS
|
||||||
#define EOS 0
|
#define EOS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _TINT
|
||||||
|
typedef wint_t _TINT;
|
||||||
|
#endif
|
||||||
|
|
||||||
static TCHAR *completion_chars = TEXT("~:\\/-.");
|
static TCHAR *completion_chars = TEXT("~:\\/-.");
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
/* $Id: console.c,v 1.1 2008-03-27 00:41:33 vsc Exp $
|
/* Part of SWI-Prolog
|
||||||
|
|
||||||
Part of SWI-Prolog
|
|
||||||
|
|
||||||
Author: Jan Wielemaker
|
Author: Jan Wielemaker
|
||||||
E-mail: jan@swi.psy.uva.nl
|
E-mail: J.Wielemaker@vu.nl
|
||||||
WWW: http://www.swi-prolog.org
|
WWW: http://www.swi-prolog.org
|
||||||
Copyright (C): 1985-2002, University of Amsterdam
|
Copyright (C): 1985-2012, University of Amsterdam
|
||||||
|
VU University Amsterdam
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
@ -19,7 +18,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
@ -88,7 +87,7 @@ static void initHeapDebug(void);
|
|||||||
#define UNICODE_NOCHAR 0xFFFF
|
#define UNICODE_NOCHAR 0xFFFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (_MSC_VER < 1400) && !_WIN64
|
#if (_MSC_VER < 1400) && !defined(__MINGW32__)
|
||||||
typedef DWORD DWORD_PTR;
|
typedef DWORD DWORD_PTR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -182,6 +181,7 @@ static HICON _rlc_hicon; /* Global icon */
|
|||||||
|
|
||||||
static LRESULT WINAPI rlc_wnd_proc(HWND win, UINT msg, WPARAM wP, LPARAM lP);
|
static LRESULT WINAPI rlc_wnd_proc(HWND win, UINT msg, WPARAM wP, LPARAM lP);
|
||||||
|
|
||||||
|
static void rcl_setup_ansi_colors(RlcData b);
|
||||||
static void rlc_place_caret(RlcData b);
|
static void rlc_place_caret(RlcData b);
|
||||||
static void rlc_resize_pixel_units(RlcData b, int w, int h);
|
static void rlc_resize_pixel_units(RlcData b, int w, int h);
|
||||||
static RlcData rlc_make_buffer(int w, int h);
|
static RlcData rlc_make_buffer(int w, int h);
|
||||||
@ -200,6 +200,8 @@ static int rlc_add_lines(RlcData b, int here, int add);
|
|||||||
static void rlc_start_selection(RlcData b, int x, int y);
|
static void rlc_start_selection(RlcData b, int x, int y);
|
||||||
static void rlc_extend_selection(RlcData b, int x, int y);
|
static void rlc_extend_selection(RlcData b, int x, int y);
|
||||||
static void rlc_word_selection(RlcData b, int x, int y);
|
static void rlc_word_selection(RlcData b, int x, int y);
|
||||||
|
static int rlc_has_selection(RlcData b);
|
||||||
|
static void rlc_set_selection(RlcData b, int sl, int sc, int el, int ec);
|
||||||
static void rlc_copy(RlcData b);
|
static void rlc_copy(RlcData b);
|
||||||
static void rlc_destroy(RlcData b);
|
static void rlc_destroy(RlcData b);
|
||||||
static void rlc_request_redraw(RlcData b);
|
static void rlc_request_redraw(RlcData b);
|
||||||
@ -207,7 +209,8 @@ static void rlc_redraw(RlcData b);
|
|||||||
static int rlc_breakargs(TCHAR *line, TCHAR **argv);
|
static int rlc_breakargs(TCHAR *line, TCHAR **argv);
|
||||||
static void rlc_resize(RlcData b, int w, int h);
|
static void rlc_resize(RlcData b, int w, int h);
|
||||||
static void rlc_adjust_line(RlcData b, int line);
|
static void rlc_adjust_line(RlcData b, int line);
|
||||||
static int text_width(RlcData b, HDC hdc, const TCHAR *text, int len);
|
static int text_width(RlcData b, HDC hdc, const text_char *text, int len);
|
||||||
|
static int tchar_width(RlcData b, HDC hdc, const TCHAR *text, int len);
|
||||||
static void rlc_queryfont(RlcData b);
|
static void rlc_queryfont(RlcData b);
|
||||||
static void rlc_do_write(RlcData b, TCHAR *buf, int count);
|
static void rlc_do_write(RlcData b, TCHAR *buf, int count);
|
||||||
static void rlc_reinit_line(RlcData b, int line);
|
static void rlc_reinit_line(RlcData b, int line);
|
||||||
@ -216,12 +219,10 @@ static int rlc_between(RlcData b, int f, int t, int v);
|
|||||||
static void free_user_data(RlcData b);
|
static void free_user_data(RlcData b);
|
||||||
|
|
||||||
static RlcQueue rlc_make_queue(int size);
|
static RlcQueue rlc_make_queue(int size);
|
||||||
static void rlc_free_queue(RlcQueue q);
|
|
||||||
static int rlc_from_queue(RlcQueue q);
|
static int rlc_from_queue(RlcQueue q);
|
||||||
static int rlc_is_empty_queue(RlcQueue q);
|
static int rlc_is_empty_queue(RlcQueue q);
|
||||||
static void rlc_empty_queue(RlcQueue q);
|
|
||||||
|
|
||||||
extern int main(void);
|
extern int main();
|
||||||
|
|
||||||
static RlcUpdateHook _rlc_update_hook;
|
static RlcUpdateHook _rlc_update_hook;
|
||||||
static RlcTimerHook _rlc_timer_hook;
|
static RlcTimerHook _rlc_timer_hook;
|
||||||
@ -345,9 +346,10 @@ rlc_window_class(HICON icon)
|
|||||||
HINSTANCE instance = _rlc_hinstance;
|
HINSTANCE instance = _rlc_hinstance;
|
||||||
|
|
||||||
if ( !winclassname[0] )
|
if ( !winclassname[0] )
|
||||||
{ if ( !GetEnvironmentVariable(TEXT("PLTERM_CLASS"),
|
{ if ( !GetEnvironmentVariable(_T("PLTERM_CLASS"),
|
||||||
winclassname, sizeof(winclassname)) )
|
winclassname, sizeof(winclassname)) )
|
||||||
_stprintf(winclassname, TEXT("PlTerm-%d"), instance);
|
snwprintf(winclassname, sizeof(winclassname)/sizeof(TCHAR),
|
||||||
|
_T("PlTerm-%d"), instance);
|
||||||
|
|
||||||
wndClass.lpszClassName = winclassname;
|
wndClass.lpszClassName = winclassname;
|
||||||
wndClass.style = CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;
|
wndClass.style = CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;
|
||||||
@ -487,7 +489,7 @@ rlc_create_window(RlcData b)
|
|||||||
NULL, NULL, _rlc_hinstance, NULL);
|
NULL, NULL, _rlc_hinstance, NULL);
|
||||||
|
|
||||||
b->window = hwnd;
|
b->window = hwnd;
|
||||||
SetWindowLong(hwnd, GWL_DATA, (LONG) b);
|
SetWindowLongPtr(hwnd, GWL_DATA, (LONG_PTR) b);
|
||||||
SetScrollRange(hwnd, SB_VERT, 0, b->sb_lines, FALSE);
|
SetScrollRange(hwnd, SB_VERT, 0, b->sb_lines, FALSE);
|
||||||
SetScrollPos(hwnd, SB_VERT, b->sb_start, TRUE);
|
SetScrollPos(hwnd, SB_VERT, b->sb_start, TRUE);
|
||||||
|
|
||||||
@ -495,6 +497,7 @@ rlc_create_window(RlcData b)
|
|||||||
b->sb_lines = rlc_count_lines(b, b->first, b->last);
|
b->sb_lines = rlc_count_lines(b, b->first, b->last);
|
||||||
b->sb_start = rlc_count_lines(b, b->first, b->window_start);
|
b->sb_start = rlc_count_lines(b, b->first, b->window_start);
|
||||||
|
|
||||||
|
rcl_setup_ansi_colors(b);
|
||||||
b->foreground = GetSysColor(COLOR_WINDOWTEXT);
|
b->foreground = GetSysColor(COLOR_WINDOWTEXT);
|
||||||
b->background = GetSysColor(COLOR_WINDOW);
|
b->background = GetSysColor(COLOR_WINDOW);
|
||||||
b->sel_foreground = GetSysColor(COLOR_HIGHLIGHTTEXT);
|
b->sel_foreground = GetSysColor(COLOR_HIGHLIGHTTEXT);
|
||||||
@ -551,13 +554,14 @@ rlc_kill_wnd_proc(HWND hwnd, UINT message, UINT wParam, LONG lParam)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static TCHAR *
|
static TCHAR *
|
||||||
rlc_kill_window_class(void)
|
rlc_kill_window_class()
|
||||||
{ static TCHAR winclassname[32];
|
{ static TCHAR winclassname[32];
|
||||||
static WNDCLASS wndClass;
|
static WNDCLASS wndClass;
|
||||||
HINSTANCE instance = _rlc_hinstance;
|
HINSTANCE instance = _rlc_hinstance;
|
||||||
|
|
||||||
if ( !winclassname[0] )
|
if ( !winclassname[0] )
|
||||||
{ _stprintf(winclassname, _T("Console-hidden-win%d"), instance);
|
{ snwprintf(winclassname, sizeof(winclassname)/sizeof(TCHAR),
|
||||||
|
_T("Console-hidden-win%d"), instance);
|
||||||
|
|
||||||
wndClass.style = 0;
|
wndClass.style = 0;
|
||||||
wndClass.lpfnWndProc = (LPVOID) rlc_kill_wnd_proc;
|
wndClass.lpfnWndProc = (LPVOID) rlc_kill_wnd_proc;
|
||||||
@ -837,6 +841,59 @@ rlc_breakargs(TCHAR *line, TCHAR **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************
|
||||||
|
* ANSI COLORS *
|
||||||
|
*******************************/
|
||||||
|
|
||||||
|
/* See http://en.wikipedia.org/wiki/ANSI_escape_code */
|
||||||
|
|
||||||
|
static void
|
||||||
|
rcl_setup_ansi_colors(RlcData b)
|
||||||
|
{ b->sgr_flags = TF_DEFAULT;
|
||||||
|
|
||||||
|
#ifdef ANSI_VGA_COLORS
|
||||||
|
/* normal versions */
|
||||||
|
b->ansi_color[0] = RGB( 0, 0, 0); /* black */
|
||||||
|
b->ansi_color[1] = RGB(170, 0, 0); /* red */
|
||||||
|
b->ansi_color[2] = RGB(0, 170, 0); /* green */
|
||||||
|
b->ansi_color[3] = RGB(170, 85, 0); /* yellow */
|
||||||
|
b->ansi_color[4] = RGB( 0, 0,170); /* blue */
|
||||||
|
b->ansi_color[5] = RGB(170, 0,170); /* magenta */
|
||||||
|
b->ansi_color[6] = RGB( 0,170,170); /* cyan */
|
||||||
|
b->ansi_color[7] = RGB(170,170,170); /* white */
|
||||||
|
/* bright/light versions */
|
||||||
|
b->ansi_color[8] = RGB( 85, 85, 85); /* black */
|
||||||
|
b->ansi_color[9] = RGB(255, 85, 85); /* red */
|
||||||
|
b->ansi_color[10] = RGB( 85,255, 85); /* green */
|
||||||
|
b->ansi_color[11] = RGB(255,255, 85); /* yellow */
|
||||||
|
b->ansi_color[12] = RGB( 85, 85,255); /* blue */
|
||||||
|
b->ansi_color[13] = RGB(255, 85,255); /* magenta */
|
||||||
|
b->ansi_color[14] = RGB( 85,255,255); /* cyan */
|
||||||
|
b->ansi_color[15] = RGB(255,255,255); /* white */
|
||||||
|
#else /*XTERM*/
|
||||||
|
/* normal versions */
|
||||||
|
b->ansi_color[0] = RGB( 0, 0, 0); /* black */
|
||||||
|
b->ansi_color[1] = RGB(205, 0, 0); /* red */
|
||||||
|
b->ansi_color[2] = RGB(0, 205, 0); /* green */
|
||||||
|
b->ansi_color[3] = RGB(205,205, 0); /* yellow */
|
||||||
|
b->ansi_color[4] = RGB( 0, 0,238); /* blue */
|
||||||
|
b->ansi_color[5] = RGB(205, 0,205); /* magenta */
|
||||||
|
b->ansi_color[6] = RGB( 0,205,205); /* cyan */
|
||||||
|
b->ansi_color[7] = RGB(229,229,229); /* white */
|
||||||
|
/* bright/light versions */
|
||||||
|
b->ansi_color[8] = RGB(127,127,127); /* black */
|
||||||
|
b->ansi_color[9] = RGB(255, 0, 0); /* red */
|
||||||
|
b->ansi_color[10] = RGB( 0,255, 0); /* green */
|
||||||
|
b->ansi_color[11] = RGB(255,255, 0); /* yellow */
|
||||||
|
b->ansi_color[12] = RGB( 92, 92,255); /* blue */
|
||||||
|
b->ansi_color[13] = RGB(255, 0,255); /* magenta */
|
||||||
|
b->ansi_color[14] = RGB( 0,255,255); /* cyan */
|
||||||
|
b->ansi_color[15] = RGB(255,255,255); /* white */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
* ATTRIBUTES *
|
* ATTRIBUTES *
|
||||||
*******************************/
|
*******************************/
|
||||||
@ -931,7 +988,14 @@ rlc_interrupt(RlcData b)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
typed_char(RlcData b, int chr)
|
typed_char(RlcData b, int chr)
|
||||||
{ if ( chr == Control('C') )
|
{ if ( chr == Control('C') && rlc_has_selection(b) )
|
||||||
|
{ rlc_copy(b);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rlc_set_selection(b, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
if ( chr == Control('C') )
|
||||||
rlc_interrupt(b);
|
rlc_interrupt(b);
|
||||||
else if ( chr == Control('V') || chr == Control('Y') )
|
else if ( chr == Control('V') || chr == Control('Y') )
|
||||||
rlc_paste(b);
|
rlc_paste(b);
|
||||||
@ -964,7 +1028,7 @@ IsDownKey(code)
|
|||||||
|
|
||||||
static LRESULT WINAPI
|
static LRESULT WINAPI
|
||||||
rlc_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
rlc_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{ RlcData b = (RlcData) GetWindowLong(hwnd, GWL_DATA);
|
{ RlcData b = (RlcData) GetWindowLongPtr(hwnd, GWL_DATA);
|
||||||
|
|
||||||
switch(message)
|
switch(message)
|
||||||
{ case WM_CREATE:
|
{ case WM_CREATE:
|
||||||
@ -1019,6 +1083,7 @@ rlc_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
rlc_paste(b);
|
rlc_paste(b);
|
||||||
return 0;
|
return 0;
|
||||||
case IDM_COPY:
|
case IDM_COPY:
|
||||||
|
rlc_copy(b);
|
||||||
return 0; /* no op: already done */
|
return 0; /* no op: already done */
|
||||||
case IDM_CUT:
|
case IDM_CUT:
|
||||||
break; /* TBD: cut */
|
break; /* TBD: cut */
|
||||||
@ -1056,6 +1121,7 @@ rlc_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
case VK_DOWN: chr = Control('N'); break;
|
case VK_DOWN: chr = Control('N'); break;
|
||||||
case VK_HOME: chr = Control('A'); break;
|
case VK_HOME: chr = Control('A'); break;
|
||||||
case VK_END: chr = Control('E'); break;
|
case VK_END: chr = Control('E'); break;
|
||||||
|
case VK_CANCEL: rlc_interrupt(b); return 0;
|
||||||
|
|
||||||
case VK_PRIOR: /* page up */
|
case VK_PRIOR: /* page up */
|
||||||
{ int maxdo = rlc_count_lines(b, b->first, b->window_start);
|
{ int maxdo = rlc_count_lines(b, b->first, b->window_start);
|
||||||
@ -1383,7 +1449,7 @@ rlc_yield()
|
|||||||
*******************************/
|
*******************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rlc_init_word_chars(void)
|
rlc_init_word_chars()
|
||||||
{ int i;
|
{ int i;
|
||||||
|
|
||||||
for(i=0; i<CHAR_MAX; i++)
|
for(i=0; i<CHAR_MAX; i++)
|
||||||
@ -1521,7 +1587,7 @@ rlc_translate_mouse(RlcData b, int x, int y, int *line, int *chr)
|
|||||||
} else if ( tl->size == 0 )
|
} else if ( tl->size == 0 )
|
||||||
{ *chr = 0;
|
{ *chr = 0;
|
||||||
} else
|
} else
|
||||||
{ TCHAR *s = tl->text;
|
{ text_char *s = tl->text;
|
||||||
HDC hdc = GetDC(b->window);
|
HDC hdc = GetDC(b->window);
|
||||||
int f = 0;
|
int f = 0;
|
||||||
int t = tl->size;
|
int t = tl->size;
|
||||||
@ -1537,7 +1603,7 @@ rlc_translate_mouse(RlcData b, int x, int y, int *line, int *chr)
|
|||||||
if ( x > w )
|
if ( x > w )
|
||||||
{ int cw;
|
{ int cw;
|
||||||
|
|
||||||
GetCharWidth32(hdc, s[m], s[m], &cw);
|
GetCharWidth32(hdc, s[m].code, s[m].code, &cw);
|
||||||
if ( x < w+cw )
|
if ( x < w+cw )
|
||||||
{ *chr = m;
|
{ *chr = m;
|
||||||
return;
|
return;
|
||||||
@ -1565,19 +1631,6 @@ rlc_start_selection(RlcData b, int x, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
rlc_end_selection(RlcData b, int x, int y)
|
|
||||||
{ int l, c;
|
|
||||||
|
|
||||||
rlc_translate_mouse(b, x, y, &l, &c);
|
|
||||||
if ( SelLT(l, c, b->sel_org_line, b->sel_org_char) )
|
|
||||||
rlc_set_selection(b, l, c, b->sel_org_line, b->sel_org_char);
|
|
||||||
else if ( SelLT(b->sel_org_line, b->sel_org_char, l, c) )
|
|
||||||
rlc_set_selection(b, b->sel_org_line, b->sel_org_char, l, c);
|
|
||||||
rlc_set_selection(b, l, c, l, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int /* v >= f && v <= t */
|
static int /* v >= f && v <= t */
|
||||||
rlc_between(RlcData b, int f, int t, int v)
|
rlc_between(RlcData b, int f, int t, int v)
|
||||||
{ int h = rlc_count_lines(b, b->first, v);
|
{ int h = rlc_count_lines(b, b->first, v);
|
||||||
@ -1598,12 +1651,12 @@ rlc_word_selection(RlcData b, int x, int y)
|
|||||||
if ( rlc_between(b, b->first, b->last, l) )
|
if ( rlc_between(b, b->first, b->last, l) )
|
||||||
{ TextLine tl = &b->lines[l];
|
{ TextLine tl = &b->lines[l];
|
||||||
|
|
||||||
if ( c < tl->size && rlc_is_word_char(tl->text[c]) )
|
if ( c < tl->size && rlc_is_word_char(tl->text[c].code) )
|
||||||
{ int f, t;
|
{ int f, t;
|
||||||
|
|
||||||
for(f=c; f>0 && rlc_is_word_char(tl->text[f-1]); f--)
|
for(f=c; f>0 && rlc_is_word_char(tl->text[f-1].code); f--)
|
||||||
;
|
;
|
||||||
for(t=c; t<tl->size && rlc_is_word_char(tl->text[t]); t++)
|
for(t=c; t<tl->size && rlc_is_word_char(tl->text[t].code); t++)
|
||||||
;
|
;
|
||||||
rlc_set_selection(b, l, f, l, t);
|
rlc_set_selection(b, l, f, l, t);
|
||||||
}
|
}
|
||||||
@ -1616,6 +1669,8 @@ rlc_word_selection(RlcData b, int x, int y)
|
|||||||
static void
|
static void
|
||||||
rlc_extend_selection(RlcData b, int x, int y)
|
rlc_extend_selection(RlcData b, int x, int y)
|
||||||
{ int l, c;
|
{ int l, c;
|
||||||
|
int el = b->sel_org_line;
|
||||||
|
int ec = b->sel_org_char;
|
||||||
|
|
||||||
rlc_translate_mouse(b, x, y, &l, &c);
|
rlc_translate_mouse(b, x, y, &l, &c);
|
||||||
if ( SelLT(l, c, b->sel_org_line, b->sel_org_char) )
|
if ( SelLT(l, c, b->sel_org_line, b->sel_org_char) )
|
||||||
@ -1623,25 +1678,39 @@ rlc_extend_selection(RlcData b, int x, int y)
|
|||||||
{ if ( rlc_between(b, b->first, b->last, l) )
|
{ if ( rlc_between(b, b->first, b->last, l) )
|
||||||
{ TextLine tl = &b->lines[l];
|
{ TextLine tl = &b->lines[l];
|
||||||
|
|
||||||
if ( c < tl->size && rlc_is_word_char(tl->text[c]) )
|
if ( c < tl->size && rlc_is_word_char(tl->text[c].code) )
|
||||||
for(; c > 0 && rlc_is_word_char(tl->text[c-1]); c--)
|
for(; c > 0 && rlc_is_word_char(tl->text[c-1].code); c--)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
if ( rlc_between(b, b->first, b->last, el) )
|
||||||
|
{ TextLine tl = &b->lines[el];
|
||||||
|
|
||||||
|
if ( ec < tl->size && rlc_is_word_char(tl->text[ec].code) )
|
||||||
|
for(; ec < tl->size && rlc_is_word_char(tl->text[ec].code); ec++)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} else if ( b->sel_unit == SEL_LINE )
|
} else if ( b->sel_unit == SEL_LINE )
|
||||||
c = 0;
|
c = 0;
|
||||||
rlc_set_selection(b, l, c, b->sel_end_line, b->sel_end_char);
|
rlc_set_selection(b, l, c, el, ec);
|
||||||
} else if ( SelLT(b->sel_org_line, b->sel_org_char, l, c) )
|
} else if ( SelLT(b->sel_org_line, b->sel_org_char, l, c) )
|
||||||
{ if ( b->sel_unit == SEL_WORD )
|
{ if ( b->sel_unit == SEL_WORD )
|
||||||
{ if ( rlc_between(b, b->first, b->last, l) )
|
{ if ( rlc_between(b, b->first, b->last, l) )
|
||||||
{ TextLine tl = &b->lines[l];
|
{ TextLine tl = &b->lines[l];
|
||||||
|
|
||||||
if ( c < tl->size && rlc_is_word_char(tl->text[c]) )
|
if ( c < tl->size && rlc_is_word_char(tl->text[c].code) )
|
||||||
for(; c < tl->size && rlc_is_word_char(tl->text[c]); c++)
|
for(; c < tl->size && rlc_is_word_char(tl->text[c].code); c++)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
if ( rlc_between(b, b->first, b->last, el) )
|
||||||
|
{ TextLine tl = &b->lines[el];
|
||||||
|
|
||||||
|
if ( ec < tl->size && rlc_is_word_char(tl->text[ec].code) )
|
||||||
|
for(; ec > 0 && rlc_is_word_char(tl->text[ec-1].code); ec--)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} else if ( b->sel_unit == SEL_LINE )
|
} else if ( b->sel_unit == SEL_LINE )
|
||||||
c = b->width;
|
c = b->width;
|
||||||
rlc_set_selection(b, b->sel_start_line, b->sel_start_char, l, c);
|
rlc_set_selection(b, el, ec, l, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1666,22 +1735,22 @@ rlc_read_from_window(RlcData b, int sl, int sc, int el, int ec)
|
|||||||
e = tl->size;
|
e = tl->size;
|
||||||
|
|
||||||
while(sc < e)
|
while(sc < e)
|
||||||
{ if ( i >= bufsize )
|
{ if ( i+1 >= bufsize )
|
||||||
{ bufsize *= 2;
|
{ bufsize *= 2;
|
||||||
if ( !(buf = rlc_realloc(buf, bufsize * sizeof(TCHAR))) )
|
if ( !(buf = rlc_realloc(buf, bufsize * sizeof(TCHAR))) )
|
||||||
return NULL; /* not enough memory */
|
return NULL; /* not enough memory */
|
||||||
}
|
}
|
||||||
buf[i++] = tl->text[sc++];
|
buf[i++] = tl->text[sc++].code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( sl == el || sl == b->last )
|
if ( sl == el || sl == b->last )
|
||||||
{ buf[i++] = '\0';
|
{ buf[i++] = '\0'; /* Always room for the 0 */
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( tl && !tl->softreturn )
|
if ( tl && !tl->softreturn )
|
||||||
{ if ( i+1 >= bufsize )
|
{ if ( i+2 >= bufsize )
|
||||||
{ bufsize *= 2;
|
{ bufsize *= 2;
|
||||||
if ( !(buf = rlc_realloc(buf, bufsize * sizeof(TCHAR))) )
|
if ( !(buf = rlc_realloc(buf, bufsize * sizeof(TCHAR))) )
|
||||||
return NULL; /* not enough memory */
|
return NULL; /* not enough memory */
|
||||||
@ -1693,15 +1762,22 @@ rlc_read_from_window(RlcData b, int sl, int sc, int el, int ec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static TCHAR *
|
static int
|
||||||
rlc_selection(RlcData b)
|
rlc_has_selection(RlcData b)
|
||||||
{ if ( SelEQ(b->sel_start_line, b->sel_start_char,
|
{ if ( SelEQ(b->sel_start_line, b->sel_start_char,
|
||||||
b->sel_end_line, b->sel_end_char) )
|
b->sel_end_line, b->sel_end_char) )
|
||||||
return NULL;
|
return FALSE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static TCHAR *
|
||||||
|
rlc_selection(RlcData b)
|
||||||
|
{ if ( rlc_has_selection(b) )
|
||||||
return rlc_read_from_window(b,
|
return rlc_read_from_window(b,
|
||||||
b->sel_start_line, b->sel_start_char,
|
b->sel_start_line, b->sel_start_char,
|
||||||
b->sel_end_line, b->sel_end_char);
|
b->sel_end_line, b->sel_end_char);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1755,16 +1831,16 @@ rlc_place_caret(RlcData b)
|
|||||||
{ SetCaretPos((b->caret_x + 1) * b->cw, line * b->ch);
|
{ SetCaretPos((b->caret_x + 1) * b->cw, line * b->ch);
|
||||||
} else
|
} else
|
||||||
{ HDC hdc = GetDC(b->window);
|
{ HDC hdc = GetDC(b->window);
|
||||||
SIZE tsize;
|
int tw;
|
||||||
TextLine tl = &b->lines[b->caret_y];
|
TextLine tl = &b->lines[b->caret_y];
|
||||||
HFONT old;
|
HFONT old;
|
||||||
|
|
||||||
old = SelectObject(hdc, b->hfont);
|
old = SelectObject(hdc, b->hfont);
|
||||||
GetTextExtentPoint32(hdc, tl->text, b->caret_x, &tsize);
|
tw = text_width(b, hdc, tl->text, b->caret_x);
|
||||||
SelectObject(hdc, old);
|
SelectObject(hdc, old);
|
||||||
ReleaseDC(b->window, hdc);
|
ReleaseDC(b->window, hdc);
|
||||||
|
|
||||||
SetCaretPos(b->cw + tsize.cx, line * b->ch);
|
SetCaretPos(b->cw + tw, line * b->ch);
|
||||||
}
|
}
|
||||||
if ( !b->caret_is_shown )
|
if ( !b->caret_is_shown )
|
||||||
{ ShowCaret(b->window);
|
{ ShowCaret(b->window);
|
||||||
@ -1802,6 +1878,80 @@ rlc_update_scrollbar(RlcData b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
rcl_paint_text(RlcData b, HDC hdc,
|
||||||
|
TextLine tl, int from, int to,
|
||||||
|
int ty, int *cx, int insel)
|
||||||
|
{ text_char *chars, *s;
|
||||||
|
text_char buf[MAXLINE];
|
||||||
|
TCHAR text[MAXLINE];
|
||||||
|
TCHAR *t;
|
||||||
|
int len = to-from;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if ( len <= 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( tl->text && to <= tl->size )
|
||||||
|
{ chars = &tl->text[from];
|
||||||
|
} else
|
||||||
|
{ text_char *o;
|
||||||
|
int copy;
|
||||||
|
|
||||||
|
o = chars = buf;
|
||||||
|
s = &tl->text[from];
|
||||||
|
copy = tl->text ? tl->size-from : 0;
|
||||||
|
for(i=0; i<copy; i++)
|
||||||
|
*o++ = *s++;
|
||||||
|
for(; i<len; i++, o++)
|
||||||
|
{ o->code = ' ';
|
||||||
|
o->flags = TF_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(t=text, s=chars, i=0; i < len; i++, t++, s++)
|
||||||
|
*t = s->code;
|
||||||
|
|
||||||
|
if ( insel ) /* TBD: Cache */
|
||||||
|
{ SetBkColor(hdc, b->sel_background);
|
||||||
|
SetTextColor(hdc, b->sel_foreground);
|
||||||
|
TextOut(hdc, *cx, ty, text, len);
|
||||||
|
*cx += tchar_width(b, hdc, text, len);
|
||||||
|
} else
|
||||||
|
{ int start, segment;
|
||||||
|
|
||||||
|
for(start=0, s=chars, t=text;
|
||||||
|
start<len;
|
||||||
|
start+=segment, s+=segment, t+=segment)
|
||||||
|
{ text_flags flags = s->flags;
|
||||||
|
int left = len-start;
|
||||||
|
|
||||||
|
for(segment=0; s[segment].flags == flags && segment<left; segment++)
|
||||||
|
;
|
||||||
|
|
||||||
|
if ( TF_FG(flags) == ANSI_COLOR_DEFAULT )
|
||||||
|
SetTextColor(hdc, b->foreground);
|
||||||
|
else
|
||||||
|
SetTextColor(hdc, b->ansi_color[TF_FG(flags)]);
|
||||||
|
|
||||||
|
if ( TF_BG(flags) == ANSI_COLOR_DEFAULT )
|
||||||
|
SetBkColor(hdc, b->background);
|
||||||
|
else
|
||||||
|
SetBkColor(hdc, b->ansi_color[TF_BG(flags)]);
|
||||||
|
|
||||||
|
TextOut(hdc, *cx, ty, t, segment);
|
||||||
|
if ( TF_BOLD(flags) )
|
||||||
|
{ SetBkMode(hdc, TRANSPARENT);
|
||||||
|
TextOut(hdc, (*cx)+1, ty, t, segment);
|
||||||
|
TextOut(hdc, *cx, ty+1, t, segment);
|
||||||
|
SetBkMode(hdc, OPAQUE);
|
||||||
|
}
|
||||||
|
*cx += tchar_width(b, hdc, t, segment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rlc_redraw(RlcData b)
|
rlc_redraw(RlcData b)
|
||||||
{ PAINTSTRUCT ps;
|
{ PAINTSTRUCT ps;
|
||||||
@ -1845,27 +1995,9 @@ rlc_redraw(RlcData b)
|
|||||||
|
|
||||||
for(; pl <= el; l = NextLine(b, l), pl++)
|
for(; pl <= el; l = NextLine(b, l), pl++)
|
||||||
{ TextLine tl = &b->lines[l];
|
{ TextLine tl = &b->lines[l];
|
||||||
TCHAR text[MAXLINE];
|
|
||||||
int ty = b->ch * pl;
|
int ty = b->ch * pl;
|
||||||
int cx = b->cw;
|
int cx = b->cw;
|
||||||
|
|
||||||
if ( !tl->text )
|
|
||||||
{ int i;
|
|
||||||
TCHAR *t;
|
|
||||||
|
|
||||||
tl->size = 0;
|
|
||||||
for(i=0, t=text; i<b->width; i++)
|
|
||||||
*t++ = ' ';
|
|
||||||
} else
|
|
||||||
{ int i;
|
|
||||||
TCHAR *t, *s;
|
|
||||||
|
|
||||||
for(i=0, t=text, s=tl->text; i<tl->size; i++)
|
|
||||||
*t++ = *s++;
|
|
||||||
for(; i<b->width; i++)
|
|
||||||
*t++ = ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
rect.top = ty;
|
rect.top = ty;
|
||||||
rect.bottom = rect.top + b->ch;
|
rect.bottom = rect.top + b->ch;
|
||||||
|
|
||||||
@ -1874,34 +2006,23 @@ rlc_redraw(RlcData b)
|
|||||||
{ int cf = b->sel_start_char;
|
{ int cf = b->sel_start_char;
|
||||||
int ce = (b->sel_end_line != b->sel_start_line ? b->width
|
int ce = (b->sel_end_line != b->sel_start_line ? b->width
|
||||||
: b->sel_end_char);
|
: b->sel_end_char);
|
||||||
if ( cf > 0 )
|
|
||||||
{ TextOut(hdc, cx, ty, text, cf);
|
rcl_paint_text(b, hdc, tl, 0, cf, ty, &cx, insel);
|
||||||
cx += text_width(b, hdc, text, cf);
|
insel = TRUE;
|
||||||
}
|
rcl_paint_text(b, hdc, tl, cf, ce, ty, &cx, insel);
|
||||||
SetBkColor(hdc, b->sel_background);
|
|
||||||
SetTextColor(hdc, b->sel_foreground);
|
|
||||||
TextOut(hdc, cx, ty, &text[cf], ce-cf);
|
|
||||||
cx += text_width(b, hdc, &text[cf], ce-cf);
|
|
||||||
if ( l == b->sel_end_line )
|
if ( l == b->sel_end_line )
|
||||||
{ SetBkColor(hdc, b->background);
|
{ insel = FALSE;
|
||||||
SetTextColor(hdc, b->foreground);
|
rcl_paint_text(b, hdc, tl, ce, b->width, ty, &cx, insel);
|
||||||
TextOut(hdc, cx, ty, &text[ce], b->width - ce);
|
|
||||||
cx += text_width(b, hdc, &text[ce], b->width - ce);
|
|
||||||
} else
|
} else
|
||||||
insel = TRUE;
|
insel = TRUE;
|
||||||
} else if ( l == b->sel_end_line ) /* end of selection */
|
} else if ( l == b->sel_end_line ) /* end of selection */
|
||||||
{ int ce = b->sel_end_char;
|
{ int ce = b->sel_end_char;
|
||||||
|
|
||||||
|
rcl_paint_text(b, hdc, tl, 0, ce, ty, &cx, insel);
|
||||||
insel = FALSE;
|
insel = FALSE;
|
||||||
TextOut(hdc, cx, ty, text, ce);
|
rcl_paint_text(b, hdc, tl, ce, b->width, ty, &cx, insel);
|
||||||
cx += text_width(b, hdc, text, ce);
|
|
||||||
SetBkColor(hdc, b->background);
|
|
||||||
SetTextColor(hdc, b->foreground);
|
|
||||||
TextOut(hdc, cx, ty, &text[ce], b->width - ce);
|
|
||||||
cx += text_width(b, hdc, &text[ce], b->width - ce);
|
|
||||||
} else /* entire line in/out selection */
|
} else /* entire line in/out selection */
|
||||||
{ TextOut(hdc, cx, ty, text, b->width);
|
{ rcl_paint_text(b, hdc, tl, 0, b->width, ty, &cx, insel);
|
||||||
cx += text_width(b, hdc, text, b->width);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clear remainder of line */
|
/* clear remainder of line */
|
||||||
@ -1947,7 +2068,6 @@ rlc_request_redraw(RlcData b)
|
|||||||
int y = 0;
|
int y = 0;
|
||||||
RECT rect;
|
RECT rect;
|
||||||
int first = TRUE;
|
int first = TRUE;
|
||||||
int clear = FALSE;
|
|
||||||
|
|
||||||
rect.left = b->cw;
|
rect.left = b->cw;
|
||||||
rect.right = (b->width+1) * b->cw;
|
rect.right = (b->width+1) * b->cw;
|
||||||
@ -1962,16 +2082,13 @@ rlc_request_redraw(RlcData b)
|
|||||||
first = FALSE;
|
first = FALSE;
|
||||||
} else
|
} else
|
||||||
rect.bottom = (y+1) * b->ch;
|
rect.bottom = (y+1) * b->ch;
|
||||||
|
|
||||||
if ( l->changed & CHG_CLEAR )
|
|
||||||
clear = TRUE;
|
|
||||||
}
|
}
|
||||||
if ( i == b->last )
|
if ( i == b->last )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !first && b->window )
|
if ( !first && b->window )
|
||||||
InvalidateRect(b->window, &rect, FALSE); /*clear);*/
|
InvalidateRect(b->window, &rect, FALSE);
|
||||||
else if ( b->changed & CHG_CARET )
|
else if ( b->changed & CHG_CARET )
|
||||||
rlc_place_caret(b);
|
rlc_place_caret(b);
|
||||||
}
|
}
|
||||||
@ -2070,7 +2187,25 @@ rlc_init_text_dimensions(RlcData b, HFONT font)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
text_width(RlcData b, HDC hdc, const TCHAR *text, int len)
|
text_width(RlcData b, HDC hdc, const text_char *text, int len)
|
||||||
|
{ if ( b->fixedfont )
|
||||||
|
{ return len * b->cw;
|
||||||
|
} else
|
||||||
|
{ SIZE size;
|
||||||
|
TCHAR tmp[MAXLINE];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i=0; i<len; i++)
|
||||||
|
tmp[i] = text[i].code;
|
||||||
|
|
||||||
|
GetTextExtentPoint32(hdc, tmp, len, &size);
|
||||||
|
return size.cx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
tchar_width(RlcData b, HDC hdc, const TCHAR *text, int len)
|
||||||
{ if ( b->fixedfont )
|
{ if ( b->fixedfont )
|
||||||
{ return len * b->cw;
|
{ return len * b->cw;
|
||||||
} else
|
} else
|
||||||
@ -2241,15 +2376,15 @@ rlc_resize(RlcData b, int w, int h)
|
|||||||
DEBUG(Dprint_lines(b, b->first, b->first));
|
DEBUG(Dprint_lines(b, b->first, b->first));
|
||||||
DEBUG(Dprintf(_T("b->first = %d, b->last = %d\n"), b->first, b->last));
|
DEBUG(Dprintf(_T("b->first = %d, b->last = %d\n"), b->first, b->last));
|
||||||
pl = &b->lines[PrevLine(b, i)]; /* this is the moved line */
|
pl = &b->lines[PrevLine(b, i)]; /* this is the moved line */
|
||||||
tl->text = rlc_malloc((pl->size - w)*sizeof(TCHAR));
|
tl->text = rlc_malloc((pl->size - w)*sizeof(text_char));
|
||||||
memmove(tl->text, &pl->text[w], (pl->size - w)*sizeof(TCHAR));
|
memmove(tl->text, &pl->text[w], (pl->size - w)*sizeof(text_char));
|
||||||
DEBUG(Dprintf(_T("Copied %d chars from line %d to %d\n"),
|
DEBUG(Dprintf(_T("Copied %d chars from line %d to %d\n"),
|
||||||
pl->size - w, pl - b->lines, i));
|
pl->size - w, pl - b->lines, i));
|
||||||
tl->size = pl->size - w;
|
tl->size = pl->size - w;
|
||||||
tl->adjusted = TRUE;
|
tl->adjusted = TRUE;
|
||||||
tl->softreturn = FALSE;
|
tl->softreturn = FALSE;
|
||||||
pl->softreturn = TRUE;
|
pl->softreturn = TRUE;
|
||||||
pl->text = rlc_realloc(pl->text, w * sizeof(TCHAR));
|
pl->text = rlc_realloc(pl->text, w * sizeof(text_char));
|
||||||
pl->size = w;
|
pl->size = w;
|
||||||
pl->adjusted = TRUE;
|
pl->adjusted = TRUE;
|
||||||
i = (int)(pl - b->lines);
|
i = (int)(pl - b->lines);
|
||||||
@ -2261,9 +2396,9 @@ rlc_resize(RlcData b, int w, int h)
|
|||||||
if ( i == b->last )
|
if ( i == b->last )
|
||||||
rlc_add_line(b);
|
rlc_add_line(b);
|
||||||
nl = &b->lines[NextLine(b, i)];
|
nl = &b->lines[NextLine(b, i)];
|
||||||
nl->text = rlc_realloc(nl->text, (nl->size + move)*sizeof(TCHAR));
|
nl->text = rlc_realloc(nl->text, (nl->size + move)*sizeof(text_char));
|
||||||
memmove(&nl->text[move], nl->text, nl->size*sizeof(TCHAR));
|
memmove(&nl->text[move], nl->text, nl->size*sizeof(text_char));
|
||||||
memmove(nl->text, &tl->text[w], move*sizeof(TCHAR));
|
memmove(nl->text, &tl->text[w], move*sizeof(text_char));
|
||||||
nl->size += move;
|
nl->size += move;
|
||||||
tl->size = w;
|
tl->size = w;
|
||||||
}
|
}
|
||||||
@ -2274,9 +2409,9 @@ rlc_resize(RlcData b, int w, int h)
|
|||||||
rlc_add_line(b);
|
rlc_add_line(b);
|
||||||
nl = &b->lines[NextLine(b, i)];
|
nl = &b->lines[NextLine(b, i)];
|
||||||
|
|
||||||
nl->text = rlc_realloc(nl->text, (nl->size + tl->size)*sizeof(TCHAR));
|
nl->text = rlc_realloc(nl->text, (nl->size + tl->size)*sizeof(text_char));
|
||||||
memmove(&nl->text[tl->size], nl->text, nl->size*sizeof(TCHAR));
|
memmove(&nl->text[tl->size], nl->text, nl->size*sizeof(text_char));
|
||||||
memmove(nl->text, tl->text, tl->size*sizeof(TCHAR));
|
memmove(nl->text, tl->text, tl->size*sizeof(text_char));
|
||||||
nl->size += tl->size;
|
nl->size += tl->size;
|
||||||
nl->adjusted = TRUE;
|
nl->adjusted = TRUE;
|
||||||
rlc_shift_lines_up(b, i);
|
rlc_shift_lines_up(b, i);
|
||||||
@ -2330,8 +2465,8 @@ rlc_adjust_line(RlcData b, int line)
|
|||||||
|
|
||||||
if ( tl->text && !tl->adjusted )
|
if ( tl->text && !tl->adjusted )
|
||||||
{ tl->text = rlc_realloc(tl->text, tl->size == 0
|
{ tl->text = rlc_realloc(tl->text, tl->size == 0
|
||||||
? sizeof(TCHAR)
|
? sizeof(text_char)
|
||||||
: tl->size * sizeof(TCHAR));
|
: tl->size * sizeof(text_char));
|
||||||
tl->adjusted = TRUE;
|
tl->adjusted = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2343,11 +2478,11 @@ rlc_unadjust_line(RlcData b, int line)
|
|||||||
|
|
||||||
if ( tl->text )
|
if ( tl->text )
|
||||||
{ if ( tl->adjusted )
|
{ if ( tl->adjusted )
|
||||||
{ tl->text = rlc_realloc(tl->text, (b->width + 1)*sizeof(TCHAR));
|
{ tl->text = rlc_realloc(tl->text, (b->width + 1)*sizeof(text_char));
|
||||||
tl->adjusted = FALSE;
|
tl->adjusted = FALSE;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{ tl->text = rlc_malloc((b->width + 1)*sizeof(TCHAR));
|
{ tl->text = rlc_malloc((b->width + 1)*sizeof(text_char));
|
||||||
tl->adjusted = FALSE;
|
tl->adjusted = FALSE;
|
||||||
tl->size = 0;
|
tl->size = 0;
|
||||||
}
|
}
|
||||||
@ -2365,7 +2500,7 @@ rlc_open_line(RlcData b)
|
|||||||
b->first = NextLine(b, b->first);
|
b->first = NextLine(b, b->first);
|
||||||
}
|
}
|
||||||
|
|
||||||
b->lines[i].text = rlc_malloc((b->width + 1)*sizeof(TCHAR));
|
b->lines[i].text = rlc_malloc((b->width + 1)*sizeof(text_char));
|
||||||
b->lines[i].adjusted = FALSE;
|
b->lines[i].adjusted = FALSE;
|
||||||
b->lines[i].size = 0;
|
b->lines[i].size = 0;
|
||||||
b->lines[i].softreturn = FALSE;
|
b->lines[i].softreturn = FALSE;
|
||||||
@ -2491,7 +2626,11 @@ rlc_tab(RlcData b)
|
|||||||
{ rlc_unadjust_line(b, b->caret_y);
|
{ rlc_unadjust_line(b, b->caret_y);
|
||||||
|
|
||||||
while ( tl->size < b->caret_x )
|
while ( tl->size < b->caret_x )
|
||||||
tl->text[tl->size++] = ' ';
|
{ text_char *tc = &tl->text[tl->size++];
|
||||||
|
|
||||||
|
tc->code = ' ';
|
||||||
|
tc->flags = b->sgr_flags;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
b->changed |= CHG_CARET;
|
b->changed |= CHG_CARET;
|
||||||
@ -2553,14 +2692,45 @@ rlc_erase_line(RlcData b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
rlc_sgr(RlcData b, int sgr)
|
||||||
|
{ if ( sgr == 0 )
|
||||||
|
{ b->sgr_flags = TF_DEFAULT;
|
||||||
|
} else if ( sgr >= 30 && sgr <= 39 )
|
||||||
|
{ b->sgr_flags = TF_SET_FG(b->sgr_flags,
|
||||||
|
sgr == 39 ? ANSI_COLOR_DEFAULT : sgr-30);
|
||||||
|
} else if ( sgr >= 40 && sgr <= 49 )
|
||||||
|
{ b->sgr_flags = TF_SET_BG(b->sgr_flags,
|
||||||
|
sgr == 49 ? ANSI_COLOR_DEFAULT : sgr-40);
|
||||||
|
} else if ( sgr >= 90 && sgr <= 99 )
|
||||||
|
{ b->sgr_flags = TF_SET_FG(b->sgr_flags,
|
||||||
|
sgr == 99 ? ANSI_COLOR_DEFAULT : sgr-90+8);
|
||||||
|
} else if ( sgr >= 100 && sgr <= 109 )
|
||||||
|
{ b->sgr_flags = TF_SET_BG(b->sgr_flags,
|
||||||
|
sgr == 109 ? ANSI_COLOR_DEFAULT : sgr-100+8);
|
||||||
|
} else if ( sgr == 1 )
|
||||||
|
{ b->sgr_flags = TF_SET_BOLD(b->sgr_flags, 1);
|
||||||
|
} else if ( sgr == 4 )
|
||||||
|
{ b->sgr_flags = TF_SET_UNDERLINE(b->sgr_flags, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rlc_put(RlcData b, int chr)
|
rlc_put(RlcData b, int chr)
|
||||||
{ TextLine tl = &b->lines[b->caret_y];
|
{ TextLine tl = &b->lines[b->caret_y];
|
||||||
|
text_char *tc;
|
||||||
|
|
||||||
rlc_unadjust_line(b, b->caret_y);
|
rlc_unadjust_line(b, b->caret_y);
|
||||||
while( tl->size < b->caret_x )
|
while( tl->size < b->caret_x )
|
||||||
tl->text[tl->size++] = ' ';
|
{ tc = &tl->text[tl->size++];
|
||||||
tl->text[b->caret_x] = chr;
|
|
||||||
|
tc->code = ' ';
|
||||||
|
tc->flags = b->sgr_flags;
|
||||||
|
}
|
||||||
|
tc = &tl->text[b->caret_x];
|
||||||
|
tc->code = chr;
|
||||||
|
tc->flags = b->sgr_flags;
|
||||||
if ( tl->size <= b->caret_x )
|
if ( tl->size <= b->caret_x )
|
||||||
tl->size = b->caret_x + 1;
|
tl->size = b->caret_x + 1;
|
||||||
tl->changed |= CHG_CHANGED;
|
tl->changed |= CHG_CHANGED;
|
||||||
@ -2642,7 +2812,7 @@ rlc_putansi(RlcData b, int chr)
|
|||||||
}
|
}
|
||||||
switch(chr)
|
switch(chr)
|
||||||
{ case ';':
|
{ case ';':
|
||||||
break; /* wait for more args */
|
return; /* wait for more args */
|
||||||
case 'H':
|
case 'H':
|
||||||
case 'f':
|
case 'f':
|
||||||
rlc_need_arg(b, 1, 0);
|
rlc_need_arg(b, 1, 0);
|
||||||
@ -2678,6 +2848,14 @@ rlc_putansi(RlcData b, int chr)
|
|||||||
case 'K':
|
case 'K':
|
||||||
CMD(rlc_erase_line(b));
|
CMD(rlc_erase_line(b));
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
{ int i;
|
||||||
|
rlc_need_arg(b, 1, 0);
|
||||||
|
|
||||||
|
for(i=0; i<b->argc; i++)
|
||||||
|
CMD(rlc_sgr(b, b->argv[i]));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
b->cmdstat = CMD_INITIAL;
|
b->cmdstat = CMD_INITIAL;
|
||||||
}
|
}
|
||||||
@ -3032,16 +3210,6 @@ rlc_make_queue(int size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
rlc_free_queue(RlcQueue q)
|
|
||||||
{ if ( q )
|
|
||||||
{ if ( q->buffer )
|
|
||||||
rlc_free(q->buffer);
|
|
||||||
rlc_free(q);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rlc_resize_queue(RlcQueue q, int size)
|
rlc_resize_queue(RlcQueue q, int size)
|
||||||
{ TCHAR *newbuf;
|
{ TCHAR *newbuf;
|
||||||
@ -3098,12 +3266,6 @@ rlc_is_empty_queue(RlcQueue q)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
rlc_empty_queue(RlcQueue q)
|
|
||||||
{ q->first = q->last = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rlc_from_queue(RlcQueue q)
|
rlc_from_queue(RlcQueue q)
|
||||||
{ if ( q->first != q->last )
|
{ if ( q->first != q->last )
|
||||||
@ -3354,8 +3516,6 @@ rlc_clearprompt(rlc_console c)
|
|||||||
* MISC STUFF *
|
* MISC STUFF *
|
||||||
*******************************/
|
*******************************/
|
||||||
|
|
||||||
static TCHAR current_title[RLC_TITLE_MAX];
|
|
||||||
|
|
||||||
void
|
void
|
||||||
rlc_title(rlc_console c, TCHAR *title, TCHAR *old, int size)
|
rlc_title(rlc_console c, TCHAR *title, TCHAR *old, int size)
|
||||||
{ RlcData b = rlc_get_data(c);
|
{ RlcData b = rlc_get_data(c);
|
||||||
@ -3375,11 +3535,7 @@ rlc_title(rlc_console c, TCHAR *title, TCHAR *old, int size)
|
|||||||
void
|
void
|
||||||
rlc_icon(rlc_console c, HICON icon)
|
rlc_icon(rlc_console c, HICON icon)
|
||||||
{
|
{
|
||||||
#ifdef WIN64
|
SetClassLongPtr(rlc_hwnd(c), GCLP_HICON, (LONG_PTR) icon);
|
||||||
SetClassLong(rlc_hwnd(c), GCLP_HICON, (LONG) icon);
|
|
||||||
#else
|
|
||||||
SetClassLong(rlc_hwnd(c), GCL_HICON, (LONG) icon);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3634,7 +3790,7 @@ Dprintf(const TCHAR *fmt, ...)
|
|||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
_vstprintf(buf, fmt, args);
|
vswprintf(buf, sizeof(buf)/sizeof(TCHAR), fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
OutputDebugString(buf);
|
OutputDebugString(buf);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: console.h,v 1.1 2008-04-01 08:45:42 vsc Exp $
|
/* $Id$
|
||||||
|
|
||||||
Part of SWI-Prolog
|
Part of SWI-Prolog
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
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
|
#ifndef _CONSOLE_H_INCLUDED
|
||||||
@ -41,13 +41,13 @@
|
|||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#if __GNUC__
|
#ifdef _MSC_VER
|
||||||
#include <stdint.h>
|
|
||||||
#else
|
|
||||||
#if (_MSC_VER < 1300)
|
#if (_MSC_VER < 1300)
|
||||||
typedef long intptr_t;
|
typedef long intptr_t;
|
||||||
typedef unsigned long uintptr_t;
|
typedef unsigned long uintptr_t;
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define RLC_APPTIMER_ID 100 /* >=100: application timer */
|
#define RLC_APPTIMER_ID 100 /* >=100: application timer */
|
||||||
@ -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 (*RlcMenuHook)(rlc_console, const TCHAR *id); /* Hook for menu-selection */
|
||||||
typedef void (*RlcFreeDataHook)(uintptr_t data); /* release data */
|
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, ...) */
|
/* rlc_color(which, ...) */
|
||||||
#define RLC_WINDOW (0) /* window background */
|
#define RLC_WINDOW (0) /* window background */
|
||||||
#define RLC_TEXT (1) /* text color */
|
#define RLC_TEXT (1) /* text color */
|
||||||
@ -116,7 +116,7 @@ typedef LRESULT (*RlcMessageHook)(HWND hwnd, UINT message,
|
|||||||
WPARAM wParam, LPARAM lParam);
|
WPARAM wParam, LPARAM lParam);
|
||||||
_export RlcMessageHook rlc_message_hook(RlcMessageHook hook);
|
_export RlcMessageHook rlc_message_hook(RlcMessageHook hook);
|
||||||
|
|
||||||
#endif /*_WINDOWS_*/
|
#endif /*__WINDOWS__*/
|
||||||
|
|
||||||
_export RlcUpdateHook rlc_update_hook(RlcUpdateHook updatehook);
|
_export RlcUpdateHook rlc_update_hook(RlcUpdateHook updatehook);
|
||||||
_export RlcTimerHook rlc_timer_hook(RlcTimerHook timerhook);
|
_export RlcTimerHook rlc_timer_hook(RlcTimerHook timerhook);
|
||||||
@ -199,6 +199,8 @@ typedef struct _line
|
|||||||
#define COMPLETE_ENUMERATE 1
|
#define COMPLETE_ENUMERATE 1
|
||||||
#define COMPLETE_CLOSE 2
|
#define COMPLETE_CLOSE 2
|
||||||
|
|
||||||
|
struct _complete_data;
|
||||||
|
|
||||||
typedef int (*RlcCompleteFunc)(struct _complete_data *);
|
typedef int (*RlcCompleteFunc)(struct _complete_data *);
|
||||||
|
|
||||||
typedef 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_init_history(rlc_console c, int size);
|
||||||
_export void rlc_add_history(rlc_console c, const TCHAR *line);
|
_export void rlc_add_history(rlc_console c, const TCHAR *line);
|
||||||
_export int rlc_bind(int chr, const char *fname);
|
_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 */
|
#endif /* _CONSOLE_H_INCLUDED */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: console_i.h,v 1.1 2008-04-01 08:50:44 vsc Exp $
|
/* $Id$
|
||||||
|
|
||||||
Part of SWI-Prolog
|
Part of SWI-Prolog
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
@ -53,8 +53,29 @@ typedef struct lqueued
|
|||||||
struct lqueued* next; /* Next in queue */
|
struct lqueued* next; /* Next in queue */
|
||||||
} lqueued, *LQueued;
|
} 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
|
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 short size; /* #characters in line */
|
||||||
unsigned adjusted : 1; /* line has been adjusted? */
|
unsigned adjusted : 1; /* line has been adjusted? */
|
||||||
unsigned changed : 1; /* line needs redraw */
|
unsigned changed : 1; /* line needs redraw */
|
||||||
@ -100,6 +121,8 @@ typedef struct
|
|||||||
COLORREF background; /* Background color */
|
COLORREF background; /* Background color */
|
||||||
COLORREF sel_foreground; /* Selection foreground */
|
COLORREF sel_foreground; /* Selection foreground */
|
||||||
COLORREF sel_background; /* Selection background */
|
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 cw; /* character width */
|
||||||
int ch; /* character height */
|
int ch; /* character height */
|
||||||
int cb; /* baseline */
|
int cb; /* baseline */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: edit.c,v 1.1 2008-03-27 00:41:33 vsc Exp $
|
/* $Id$
|
||||||
|
|
||||||
Part of SWI-Prolog
|
Part of SWI-Prolog
|
||||||
|
|
||||||
@ -19,13 +19,13 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
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 <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
#define _MAKE_DLL 1
|
||||||
|
#undef _export
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "console_i.h"
|
#include "console_i.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: history.c,v 1.1 2008-03-27 00:41:33 vsc Exp $
|
/* $Id$
|
||||||
|
|
||||||
Part of SWI-Prolog
|
Part of SWI-Prolog
|
||||||
|
|
||||||
@ -19,13 +19,13 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
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 <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
#define _MAKE_DLL 1
|
||||||
|
#undef _export
|
||||||
#include "console.h" /* public stuff */
|
#include "console.h" /* public stuff */
|
||||||
#include "console_i.h" /* internal stuff */
|
#include "console_i.h" /* internal stuff */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -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
|
int
|
||||||
rlc_at_head_history(RlcData b)
|
rlc_at_head_history(RlcData b)
|
||||||
{ return b->history.current == -1 ? TRUE : FALSE;
|
{ return b->history.current == -1 ? TRUE : FALSE;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: history.h,v 1.1 2008-04-01 08:52:50 vsc Exp $
|
/* $Id$
|
||||||
|
|
||||||
Part of SWI-Prolog
|
Part of SWI-Prolog
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
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 */
|
/* history.c */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: menu.c,v 1.1 2008-03-27 00:41:33 vsc Exp $
|
/* $Id$
|
||||||
|
|
||||||
Part of SWI-Prolog
|
Part of SWI-Prolog
|
||||||
|
|
||||||
@ -19,12 +19,13 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
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 <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#define _MAKE_DLL
|
#define _MAKE_DLL 1
|
||||||
|
#undef _export
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "console_i.h"
|
#include "console_i.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
@ -204,10 +205,10 @@ rlc_add_menu_bar(HWND cwin)
|
|||||||
|
|
||||||
append_builtin(run, IDM_BREAK);
|
append_builtin(run, IDM_BREAK);
|
||||||
|
|
||||||
AppendMenu(menu, MF_POPUP, (UINT)file, _T("&File"));
|
AppendMenu(menu, MF_POPUP, (UINT_PTR)file, _T("&File"));
|
||||||
AppendMenu(menu, MF_POPUP, (UINT)edit, _T("&Edit"));
|
AppendMenu(menu, MF_POPUP, (UINT_PTR)edit, _T("&Edit"));
|
||||||
AppendMenu(menu, MF_POPUP, (UINT)settings, _T("&Settings"));
|
AppendMenu(menu, MF_POPUP, (UINT_PTR)settings, _T("&Settings"));
|
||||||
AppendMenu(menu, MF_POPUP, (UINT)run, _T("&Run"));
|
AppendMenu(menu, MF_POPUP, (UINT_PTR)run, _T("&Run"));
|
||||||
|
|
||||||
SetMenu(cwin, menu);
|
SetMenu(cwin, menu);
|
||||||
}
|
}
|
||||||
@ -218,6 +219,15 @@ rlc_add_menu_bar(HWND cwin)
|
|||||||
|
|
||||||
#define MEN_MAGIC 0x6c4a58e0
|
#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
|
void
|
||||||
rlc_menu_action(rlc_console c, menu_data *data)
|
rlc_menu_action(rlc_console c, menu_data *data)
|
||||||
{ RlcData b = rlc_get_data(c);
|
{ RlcData b = rlc_get_data(c);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: menu.h,v 1.1 2008-04-01 08:50:44 vsc Exp $
|
/* $Id$
|
||||||
|
|
||||||
Part of SWI-Prolog
|
Part of SWI-Prolog
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
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 */
|
/* see also console.c */
|
||||||
@ -35,14 +35,7 @@
|
|||||||
#define IDM_BREAK 14
|
#define IDM_BREAK 14
|
||||||
#define IDM_FONT 15
|
#define IDM_FONT 15
|
||||||
|
|
||||||
typedef struct menu_data
|
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;
|
|
||||||
|
|
||||||
|
|
||||||
const TCHAR *lookupMenuId(UINT id);
|
const TCHAR *lookupMenuId(UINT id);
|
||||||
void rlc_add_menu_bar(HWND win);
|
void rlc_add_menu_bar(HWND win);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: registry.c,v 1.1 2008-03-27 00:41:33 vsc Exp $
|
/* $Id$
|
||||||
|
|
||||||
Part of SWI-Prolog
|
Part of SWI-Prolog
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
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 <windows.h>
|
||||||
|
Reference in New Issue
Block a user