*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
*
* You should have received a copy of the GNU General Public License
* along with this program; 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
*/
/*
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
glk_stylehint_set(wintype_AllTypes, style_Preformatted, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_Preformatted, stylehint_Weight, 0);
glk_stylehint_set(wintype_AllTypes, style_Preformatted, stylehint_Oblique, 0);
- glk_stylehint_set(wintype_TextGrid, style_Preformatted, stylehint_ReverseColor, 1);
/* monob */
glk_stylehint_set(wintype_AllTypes, style_Subheader, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_Subheader, stylehint_Weight, 1);
glk_stylehint_set(wintype_AllTypes, style_Subheader, stylehint_Oblique, 0);
- glk_stylehint_set(wintype_TextGrid, style_Subheader, stylehint_ReverseColor, 1);
/* monoi */
glk_stylehint_set(wintype_AllTypes, style_Alert, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_Alert, stylehint_Weight, 0);
glk_stylehint_set(wintype_AllTypes, style_Alert, stylehint_Oblique, 1);
- glk_stylehint_set(wintype_TextGrid, style_Alert, stylehint_ReverseColor, 1);
/* monoz */
glk_stylehint_set(wintype_AllTypes, style_BlockQuote, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_BlockQuote, stylehint_Weight, 1);
glk_stylehint_set(wintype_AllTypes, style_BlockQuote, stylehint_Oblique, 1);
- glk_stylehint_set(wintype_TextGrid, style_BlockQuote, stylehint_ReverseColor, 1);
/* propr */
glk_stylehint_set(wintype_TextBuffer, style_Normal, stylehint_Proportional, 1);
glk_stylehint_set(wintype_TextGrid, style_Normal, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_Weight, 0);
glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_Oblique, 0);
- glk_stylehint_set(wintype_TextGrid, style_Normal, stylehint_ReverseColor, 1);
/* propb */
glk_stylehint_set(wintype_TextBuffer, style_Header, stylehint_Proportional, 1);
glk_stylehint_set(wintype_TextGrid, style_Header, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_Header, stylehint_Weight, 1);
glk_stylehint_set(wintype_AllTypes, style_Header, stylehint_Oblique, 0);
- glk_stylehint_set(wintype_TextGrid, style_Header, stylehint_ReverseColor, 1);
/* propi */
glk_stylehint_set(wintype_TextBuffer, style_Emphasized, stylehint_Proportional, 1);
glk_stylehint_set(wintype_TextGrid, style_Emphasized, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_Emphasized, stylehint_Weight, 0);
glk_stylehint_set(wintype_AllTypes, style_Emphasized, stylehint_Oblique, 1);
- glk_stylehint_set(wintype_TextGrid, style_Emphasized, stylehint_ReverseColor, 1);
/* propi */
glk_stylehint_set(wintype_TextBuffer, style_Note, stylehint_Proportional, 1);
glk_stylehint_set(wintype_TextGrid, style_Note, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_Note, stylehint_Weight, 1);
glk_stylehint_set(wintype_AllTypes, style_Note, stylehint_Oblique, 1);
- glk_stylehint_set(wintype_TextGrid, style_Note, stylehint_ReverseColor, 1);
gos_lower = glk_window_open(0, 0, 0, wintype_TextGrid, 0);
if (!gos_lower)
glk_set_window(gos_upper);
gos_curwin = gos_upper;
+#ifdef GARGLK
+ garglk_set_reversevideo(TRUE);
+#endif /* GARGLK */
+
curx = cury = 1;
glk_window_move_cursor(gos_upper, 0, 0);
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
*
* You should have received a copy of the GNU General Public License
* along with this program; 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
*/
/*
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "frotz.h"
# Automatically generate version.h
MAJOR = 1
MINOR = 2
-PATCH = 8
+PATCH = 9
version.h: Makefile.am
$(AM_V_GEN)echo "// Automatically generated file -- do not edit!" > version.h
$(AM_V_at)echo "#define GIT_MAJOR" $(MAJOR) >> version.h
Git is an interpreter for the Glulx virtual machine. Its homepage is here:\r
\r
- http://diden.net/if/git\r
+http://ifarchive.org/indexes/if-archiveXprogrammingXglulxXinterpretersXgit.html\r
\r
Git's main goal in life is to be fast. It's about five times faster than Glulxe,\r
and about twice as fast as Frotz (using the same Inform source compiled for the\r
\r
Have fun, and let me know what you think!\r
\r
- Iain Merrick\r
+ Iain Merrick (Original author)\r
iain@diden.net\r
\r
+ David Kinder (Current maintainer)\r
+ davidk.kinder@virgin.net\r
+\r
--------------------------------------------------------------------------------\r
\r
* Building and installing Git\r
to be able to display graphics and play sounds. To find a suitable Glk library,\r
look here:\r
\r
- http://eblong.com/zarf/glk\r
+http://eblong.com/zarf/glk/\r
+http://ifarchive.org/indexes/if-archiveXprogrammingXglkXimplementations.html\r
\r
Exactly how you build and link everything depends on what platform you're on and\r
which Glk library you're using. The supplied Makefile should work on any Unix\r
\r
It should be possible to build Git with any C compiler, but it works best with\r
GCC, because that has a non-standard extension that Git can use for a big speed\r
-boost. GCC 2.95 actually generates faster code than GCC 3, so if you have a\r
-choice, use the former. (On OS X, this means compiling with 'gcc2'.)\r
+boost. GCC 2.95 actually generates faster code than later versions, so if you\r
+have a choice, use the former. (On OS X, this means compiling with 'gcc2'.)\r
\r
--------------------------------------------------------------------------------\r
\r
\r
GCC 3 has bigger problems than I thought. On PowerPC, the direct threading\r
option results in much slower code; and on x86, terp.c crashes GCC itself if\r
-direct threading is used. Therefore, I recommend that you use GCC 2.95 if\r
-possible. If you only have GCC 3, don't define USE_DIRECT_THREADING, at least\r
-until the compiler bug is fixed.\r
-\r
-Since the previous update, GCC 4 has been released, but I haven't evaluated it\r
-yet. If you want to give it a try, let me know how you get on!\r
+direct threading is used. GCC 4 seems to work, given some very limited testing,\r
+but still results in slow code. Therefore, I recommend that you use GCC 2.95 if\r
+possible. If you only have GCC 3, don't define USE_DIRECT_THREADING.\r
\r
Some Glk libraries, such as xglk, can't deal with memory-mapped files. You can\r
tell that this is happening if Git can open .ulx files, but complains that .blb\r
memory stream. If you're using the git_unix.c startup file, just make sure\r
USE_MMAP isn't defined.\r
\r
-1-byte and 2-byte local variables are not implemented yet. This means git can't\r
-currently play games created with the Superglus system. This will be fixed at\r
-some point.\r
+1-byte and 2-byte local variables are not implemented. This means git can't\r
+play games created with old versions of the Superglus system. As these small\r
+local variables now deprecated, it is unlikely that this will be fixed.\r
\r
In the search opcodes, direct keys don't work unless they're exactly 4 bytes\r
long.\r
\r
* Version History\r
\r
+1.2.9 2011-08-28 Fixed a bug in glkop.c dispatching, to do with optional\r
+ array arguments, following a similar fix in Glulxe.\r
+ Glk array and string operations are now checked for memory\r
+ overflows (though not for ROM writing), following a similar\r
+ fix in Glulxe.\r
+\r
1.2.8 2010-08-25 Fixed a problem with 'undo' when compiled as 64 bit,\r
contributed by Ben Cressey.\r
Fixed a sign problem for the @fceil opcode, following a\r
Added gitWithStream() as a workaround for xglk\r
\r
1.0 2003-10-18 First public release\r
+\r
extern int git_init_dispatch();
extern glui32 git_perform_glk(glui32 funcnum, glui32 numargs, glui32 *arglist);
extern strid_t git_find_stream_by_id(glui32 id);
+extern glui32 git_find_id_for_stream(strid_t str);
// git_search.c
directly -- instead of bothering with the whole prototype
mess. */
+ case 0x0047: /* stream_set_current */
+ if (numargs != 1)
+ goto WrongArgNum;
+ glk_stream_set_current(git_find_stream_by_id(arglist[0]));
+ break;
+ case 0x0048: /* stream_get_current */
+ if (numargs != 0)
+ goto WrongArgNum;
+ retval = git_find_id_for_stream(glk_stream_get_current());
+ break;
case 0x0080: /* put_char */
if (numargs != 1)
goto WrongArgNum;
goto WrongArgNum;
retval = glk_char_to_upper(arglist[0] & 0xFF);
break;
+ case 0x0128: /* put_char_uni */
+ if (numargs != 1)
+ goto WrongArgNum;
+ glk_put_char_uni(arglist[0]);
+ break;
+ case 0x012B: /* put_char_stream_uni */
+ if (numargs != 2)
+ goto WrongArgNum;
+ glk_put_char_stream_uni(git_find_stream_by_id(arglist[0]), arglist[1]);
+ break;
WrongArgNum:
fatalError("Wrong number of arguments to Glk function.");
/* Go through the full dispatcher prototype foo. */
char *proto, *cx;
dispatch_splot_t splot;
- int argnum;
+ int argnum, argnum2;
/* Grab the string. */
proto = gidispatch_prototype(funcnum);
gidispatch_call(funcnum, argnum, splot.garglist);
/* Phase 3. */
- argnum = 0;
+ argnum2 = 0;
cx = proto;
- unparse_glk_args(&splot, &cx, 0, &argnum, 0, 0);
+ unparse_glk_args(&splot, &cx, 0, &argnum2, 0, 0);
+ if (argnum != argnum2)
+ fatalError("Argument counts did not match.");
break;
}
switch (typeclass) {
case 'C':
+ /* This test checks for a giant array length, and cuts it down to
+ something reasonable. Future releases of this interpreter may
+ treat this case as a fatal error. */
+ if (varglist[ix+1] > gEndMem || varglist[ix]+varglist[ix+1] > gEndMem)
+ varglist[ix+1] = gEndMem - varglist[ix];
+
garglist[gargnum].array = (void*) AddressOfArray(varglist[ix]);
gargnum++;
ix++;
cx++;
break;
case 'I':
+ /* See comment above. */
+ if (varglist[ix+1] > gEndMem/4 || varglist[ix+1] > (gEndMem-varglist[ix])/4)
+ varglist[ix+1] = (gEndMem - varglist[ix]) / 4;
+
garglist[gargnum].array = CaptureIArray(varglist[ix], varglist[ix+1], passin);
gargnum++;
ix++;
}
else {
cx++;
+ if (isarray)
+ ix++;
}
}
}
}
else {
cx++;
+ if (isarray)
+ ix++;
}
}
}
return classes_get(1, objid);
}
+/* find_id_for_stream():
+ The converse of find_stream_by_id().
+ This is only needed in this file, so it's static.
+*/
+glui32 git_find_id_for_stream(strid_t str)
+{
+ gidispatch_rock_t objrock;
+
+ if (!str)
+ return 0;
+
+ objrock = gidispatch_get_objrock(str, 1);
+ return ((classref_t *)objrock.ptr)->id;
+}
+
/* Build a hash table to hold a set of Glk objects. */
static classtable_t *new_classtable(glui32 firstid)
{
int floatCompare(git_sint32 L1, git_sint32 L2, git_sint32 L3)
{
- git_float F1, F2;\r
-\r
- if (((L3 & 0x7F800000) == 0x7F800000) && ((L3 & 0x007FFFFF) != 0))\r
- return 0;\r
- if ((L1 == 0x7F800000 || L1 == 0xFF800000) && (L2 == 0x7F800000 || L2 == 0xFF800000))\r
- return (L1 == L2);\r
-\r
- F1 = DECODE_FLOAT(L2) - DECODE_FLOAT(L1);\r
- F2 = fabs(DECODE_FLOAT(L3));\r
- return ((F1 <= F2) && (F1 >= -F2));\r
+ git_float F1, F2;
+
+ if (((L3 & 0x7F800000) == 0x7F800000) && ((L3 & 0x007FFFFF) != 0))
+ return 0;
+ if ((L1 == 0x7F800000 || L1 == 0xFF800000) && (L2 == 0x7F800000 || L2 == 0xFF800000))
+ return (L1 == L2);
+
+ F1 = DECODE_FLOAT(L2) - DECODE_FLOAT(L1);
+ F2 = fabs(DECODE_FLOAT(L3));
+ return ((F1 <= F2) && (F1 >= -F2));
}
-#ifdef USE_OWN_POWF\r
-float git_powf(float x, float y)\r
-{\r
- if (x == 1.0f)\r
- return 1.0f;\r
- else if ((y == 0.0f) || (y == -0.0f))\r
- return 1.0f;\r
- else if ((x == -1.0f) && isinf(y))\r
- return 1.0f;\r
- return powf(x,y);\r
-}\r
+#ifdef USE_OWN_POWF
+float git_powf(float x, float y)
+{
+ if (x == 1.0f)
+ return 1.0f;
+ else if ((y == 0.0f) || (y == -0.0f))
+ return 1.0f;
+ else if ((x == -1.0f) && isinf(y))
+ return 1.0f;
+ return powf(x,y);
+}
#endif
// -------------------------------------------------------------
L6 = memRead8(L1++); // LocalType
L5 = memRead8(L1++); // LocalCount
if (L6 != 4 && L6 != 0) // We only support 4-byte locals.
- fatalError("Local variable wasn't 4 bytes wide");
+ {
+ if (L6 == 1 || L6 == 2)
+ fatalError("Short local variables are not supported, use Glulxe");
+ else
+ fatalError("Local variable wasn't 4 bytes wide");
+ }
L4 += L5; // Cumulative local count.
}
while (L5 != 0);
PEEPHOLE_STORE(fadd, F1 = DECODE_FLOAT(L1) + DECODE_FLOAT(L2); S1 = ENCODE_FLOAT(F1));
PEEPHOLE_STORE(fsub, F1 = DECODE_FLOAT(L1) - DECODE_FLOAT(L2); S1 = ENCODE_FLOAT(F1));
PEEPHOLE_STORE(fmul, F1 = DECODE_FLOAT(L1) * DECODE_FLOAT(L2); S1 = ENCODE_FLOAT(F1));
- PEEPHOLE_STORE(fdiv, F1 = DECODE_FLOAT(L1) / DECODE_FLOAT(L2); S1 = ENCODE_FLOAT(F1));\r
+ PEEPHOLE_STORE(fdiv, F1 = DECODE_FLOAT(L1) / DECODE_FLOAT(L2); S1 = ENCODE_FLOAT(F1));
#define PEEPHOLE_LOAD(tag,reg) \
do_ ## tag ## _ ## reg ## _const: reg = READ_PC; goto do_ ## tag; \
// Floating point (new with glulx spec 3.1.2)
- do_numtof:\r
- F1 = (git_float) L1;\r
- S1 = ENCODE_FLOAT(F1);\r
- NEXT;\r
-\r
- do_ftonumz:\r
- F1 = DECODE_FLOAT(L1);\r
- if (!signbit(F1)) {\r
- if (isnan(F1) || isinf(F1) || (F1 > 2147483647.0))\r
- S1 = 0x7FFFFFFF;\r
- else\r
- S1 = (git_sint32) truncf(F1);\r
- } else {\r
- if (isnan(F1) || isinf(F1) || (F1 < -2147483647.0))\r
- S1 = 0x80000000;\r
- else\r
- S1 = (git_sint32) truncf(F1);\r
- }\r
- NEXT;\r
-\r
- do_ftonumn:\r
- F1 = DECODE_FLOAT(L1);\r
- if (!signbit(F1)) {\r
- if (isnan(F1) || isinf(F1) || (F1 > 2147483647.0))\r
- S1 = 0x7FFFFFFF;\r
- else\r
- S1 = (git_sint32) roundf(F1);\r
- } else {\r
- if (isnan(F1) || isinf(F1) || (F1 < -2147483647.0))\r
- S1 = 0x80000000;\r
- else\r
- S1 = (git_sint32) roundf(F1);\r
- }\r
- NEXT;\r
-\r
- do_ceil:\r
- F1 = ceilf(DECODE_FLOAT(L1));\r
- L2 = ENCODE_FLOAT(F1);\r
- if ((L2 == 0x0) || (L2 == 0x80000000))\r
- L2 = L1 & 0x80000000;\r
- S1 = L2;\r
- NEXT;\r
-\r
- do_floor:\r
- F1 = floorf(DECODE_FLOAT(L1));\r
- S1 = ENCODE_FLOAT(F1);\r
- NEXT;\r
-\r
- do_sqrt:\r
- F1 = sqrtf(DECODE_FLOAT(L1));\r
- S1 = ENCODE_FLOAT(F1);\r
- NEXT;\r
-\r
- do_exp:\r
- F1 = expf(DECODE_FLOAT(L1));\r
- S1 = ENCODE_FLOAT(F1);\r
- NEXT;\r
-\r
- do_log:\r
- F1 = logf(DECODE_FLOAT(L1));\r
- S1 = ENCODE_FLOAT(F1);\r
- NEXT;\r
-\r
- do_pow:\r
-#ifdef USE_OWN_POWF\r
- F1 = git_powf(DECODE_FLOAT(L1), DECODE_FLOAT(L2));\r
-#else\r
- F1 = powf(DECODE_FLOAT(L1), DECODE_FLOAT(L2));\r
-#endif\r
- S1 = ENCODE_FLOAT(F1);\r
- NEXT;\r
-\r
- do_atan2:\r
- F1 = atan2f(DECODE_FLOAT(L1), DECODE_FLOAT(L2));\r
- S1 = ENCODE_FLOAT(F1);\r
- NEXT;\r
-\r
- do_fmod:\r
- F1 = DECODE_FLOAT(L1);\r
- F2 = DECODE_FLOAT(L2);\r
- F3 = fmodf(F1, F2);\r
- F4 = (F1 - F3) / F2;\r
- L4 = ENCODE_FLOAT(F4);\r
- if ((L4 == 0) || (L4 == 0x80000000))\r
- L4 = (L1 ^ L2) & 0x80000000;\r
- S1 = ENCODE_FLOAT(F3);\r
- S2 = L4;\r
- NEXT;\r
-\r
- do_sin:\r
- F1 = sinf(DECODE_FLOAT(L1));\r
- S1 = ENCODE_FLOAT(F1);\r
- NEXT;\r
-\r
- do_cos:\r
- F1 = cosf(DECODE_FLOAT(L1));\r
- S1 = ENCODE_FLOAT(F1);\r
- NEXT;\r
-\r
- do_tan:\r
- F1 = tanf(DECODE_FLOAT(L1));\r
- S1 = ENCODE_FLOAT(F1);\r
- NEXT;\r
-\r
- do_asin:\r
- F1 = asinf(DECODE_FLOAT(L1));\r
- S1 = ENCODE_FLOAT(F1);\r
- NEXT;\r
-\r
- do_acos:\r
- F1 = acosf(DECODE_FLOAT(L1));\r
- S1 = ENCODE_FLOAT(F1);\r
- NEXT;\r
-\r
- do_atan:\r
- F1 = atanf(DECODE_FLOAT(L1));\r
- S1 = ENCODE_FLOAT(F1);\r
- NEXT;\r
+ do_numtof:
+ F1 = (git_float) L1;
+ S1 = ENCODE_FLOAT(F1);
+ NEXT;
+
+ do_ftonumz:
+ F1 = DECODE_FLOAT(L1);
+ if (!signbit(F1)) {
+ if (isnan(F1) || isinf(F1) || (F1 > 2147483647.0))
+ S1 = 0x7FFFFFFF;
+ else
+ S1 = (git_sint32) truncf(F1);
+ } else {
+ if (isnan(F1) || isinf(F1) || (F1 < -2147483647.0))
+ S1 = 0x80000000;
+ else
+ S1 = (git_sint32) truncf(F1);
+ }
+ NEXT;
+
+ do_ftonumn:
+ F1 = DECODE_FLOAT(L1);
+ if (!signbit(F1)) {
+ if (isnan(F1) || isinf(F1) || (F1 > 2147483647.0))
+ S1 = 0x7FFFFFFF;
+ else
+ S1 = (git_sint32) roundf(F1);
+ } else {
+ if (isnan(F1) || isinf(F1) || (F1 < -2147483647.0))
+ S1 = 0x80000000;
+ else
+ S1 = (git_sint32) roundf(F1);
+ }
+ NEXT;
+
+ do_ceil:
+ F1 = ceilf(DECODE_FLOAT(L1));
+ L2 = ENCODE_FLOAT(F1);
+ if ((L2 == 0x0) || (L2 == 0x80000000))
+ L2 = L1 & 0x80000000;
+ S1 = L2;
+ NEXT;
+
+ do_floor:
+ F1 = floorf(DECODE_FLOAT(L1));
+ S1 = ENCODE_FLOAT(F1);
+ NEXT;
+
+ do_sqrt:
+ F1 = sqrtf(DECODE_FLOAT(L1));
+ S1 = ENCODE_FLOAT(F1);
+ NEXT;
+
+ do_exp:
+ F1 = expf(DECODE_FLOAT(L1));
+ S1 = ENCODE_FLOAT(F1);
+ NEXT;
+
+ do_log:
+ F1 = logf(DECODE_FLOAT(L1));
+ S1 = ENCODE_FLOAT(F1);
+ NEXT;
+
+ do_pow:
+#ifdef USE_OWN_POWF
+ F1 = git_powf(DECODE_FLOAT(L1), DECODE_FLOAT(L2));
+#else
+ F1 = powf(DECODE_FLOAT(L1), DECODE_FLOAT(L2));
+#endif
+ S1 = ENCODE_FLOAT(F1);
+ NEXT;
+
+ do_atan2:
+ F1 = atan2f(DECODE_FLOAT(L1), DECODE_FLOAT(L2));
+ S1 = ENCODE_FLOAT(F1);
+ NEXT;
+
+ do_fmod:
+ F1 = DECODE_FLOAT(L1);
+ F2 = DECODE_FLOAT(L2);
+ F3 = fmodf(F1, F2);
+ F4 = (F1 - F3) / F2;
+ L4 = ENCODE_FLOAT(F4);
+ if ((L4 == 0) || (L4 == 0x80000000))
+ L4 = (L1 ^ L2) & 0x80000000;
+ S1 = ENCODE_FLOAT(F3);
+ S2 = L4;
+ NEXT;
+
+ do_sin:
+ F1 = sinf(DECODE_FLOAT(L1));
+ S1 = ENCODE_FLOAT(F1);
+ NEXT;
+
+ do_cos:
+ F1 = cosf(DECODE_FLOAT(L1));
+ S1 = ENCODE_FLOAT(F1);
+ NEXT;
+
+ do_tan:
+ F1 = tanf(DECODE_FLOAT(L1));
+ S1 = ENCODE_FLOAT(F1);
+ NEXT;
+
+ do_asin:
+ F1 = asinf(DECODE_FLOAT(L1));
+ S1 = ENCODE_FLOAT(F1);
+ NEXT;
+
+ do_acos:
+ F1 = acosf(DECODE_FLOAT(L1));
+ S1 = ENCODE_FLOAT(F1);
+ NEXT;
+
+ do_atan:
+ F1 = atanf(DECODE_FLOAT(L1));
+ S1 = ENCODE_FLOAT(F1);
+ NEXT;
// Special Git opcodes
// Automatically generated file -- do not edit!
#define GIT_MAJOR 1
#define GIT_MINOR 2
-#define GIT_PATCH 8
+#define GIT_PATCH 9
http://eblong.com/zarf/glulx/index.html
*/
-#include <string.h>
#include "glk.h"
#include "glulxe.h"
#include "glkstart.h" /* This comes with the Glk library. */
+#include <string.h>
-/* The only command-line argument is the filename. And the profiling switch,
- if that's compiled in. The only *two* command-line arguments are...
-*/
+/* The only command-line argument is the filename. */
glkunix_argumentlist_t glkunix_arguments[] = {
-
-#if VM_PROFILING
- { "--profile", glkunix_arg_ValueFollows, "Generate profiling information to a file." },
-#endif /* VM_PROFILING */
-
{ "", glkunix_arg_ValueFollows, "filename: The game file to load." },
-
{ NULL, glkunix_arg_End, NULL }
};
{
/* It turns out to be more convenient if we return TRUE from here, even
when an error occurs, and display an error in glk_main(). */
- int ix;
- char *filename = NULL;
+ char *cx;
unsigned char buf[12];
int res;
#ifdef GARGLK
- char *cx;
garglk_set_program_name("Glulxe 0.4.7");
garglk_set_program_info("Glulxe 0.4.7 by Andrew Plotkin");
#endif
- /* Parse out the arguments. They've already been checked for validity,
- and the library-specific ones stripped out.
- As usual for Unix, the zeroth argument is the executable name. */
- for (ix=1; ix<data->argc; ix++) {
-
-#if VM_PROFILING
- if (!strcmp(data->argv[ix], "--profile")) {
- ix++;
- if (ix<data->argc) {
- strid_t profstr = glkunix_stream_open_pathname_gen(data->argv[ix], TRUE, FALSE, 1);
- if (!profstr) {
- init_err = "Unable to open profile output file.";
- init_err2 = data->argv[ix];
- return TRUE;
- }
- setup_profile(profstr, NULL);
- }
- continue;
- }
-#endif /* VM_PROFILING */
-
- if (filename) {
- init_err = "You must supply exactly one game file.";
- return TRUE;
- }
- filename = data->argv[ix];
- }
-
- if (!filename) {
+ if (data->argc <= 1) {
init_err = "You must supply the name of a game file.";
#ifdef GARGLK
return TRUE; /* Hack! but I want error message in glk window */
#endif
return FALSE;
}
+ cx = data->argv[1];
- gamefile = glkunix_stream_open_pathname(filename, FALSE, 1);
+ gamefile = glkunix_stream_open_pathname(cx, FALSE, 1);
if (!gamefile) {
init_err = "The game file could not be opened.";
- init_err2 = filename;
+ init_err2 = cx;
return TRUE;
}
#ifdef GARGLK
- cx = strrchr(filename, '/');
- if (!cx) cx = strrchr(filename, '\\');
- garglk_set_story_name(cx ? cx + 1 : filename);
+ cx = strrchr(data->argv[1], '/');
+ if (!cx) cx = strrchr(data->argv[1], '\\');
+ garglk_set_story_name(cx ? cx + 1 : data->argv[1]);
#endif
/* Now we have to check to see if it's a Blorb file. */
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at ecr+@andrew.cmu.edu
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The author can be reached at nitfol@my-deja.com
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached at nitfol@deja.com
*/
/* Hashtable containing the current styles set by CSS and GLK */
struct StyleSet *styles;
struct StyleSet *glk_styles;
- PangoAttrList *pager_attr_list;
/* Final message displayed when game exits */
gchar *final_message;
/* Image cache */
priv->protect = FALSE;
priv->styles = g_new0(StyleSet,1);
priv->glk_styles = g_new0(StyleSet,1);
- priv->pager_attr_list = pango_attr_list_new();
priv->final_message = g_strdup("[ The game has finished ]");
priv->running = FALSE;
priv->program = NULL;
g_hash_table_destroy(priv->styles->text_grid);
g_hash_table_destroy(priv->glk_styles->text_buffer);
g_hash_table_destroy(priv->glk_styles->text_grid);
- pango_attr_list_unref(priv->pager_attr_list);
-
+
/* Free the event queue */
g_mutex_lock(priv->event_lock);
g_queue_foreach(priv->event_queue, (GFunc)g_free, NULL);
return style_get_tag_names();
}
-/**
- * chimara_glk_update_style:
- * @glk: a #ChimaraGlk widget
- *
- * Processes style updates and updates the widget to reflect the new style.
- * Call this every time you change a property of a #GtkTextTag retrieved by
- * chimara_glk_get_tag().
- */
-void
-chimara_glk_update_style(ChimaraGlk *glk)
-{
- CHIMARA_GLK_USE_PRIVATE(glk, priv);
- style_update(glk);
-
- /* Schedule a redraw */
- g_mutex_lock(priv->arrange_lock);
- priv->needs_rearrange = TRUE;
- priv->ignore_next_arrange_event = TRUE;
- g_mutex_unlock(priv->arrange_lock);
- gtk_widget_queue_resize( GTK_WIDGET(priv->self) );
-}
-
/**
* chimara_glk_set_resource_load_callback:
* @glk: a #ChimaraGlk widget
#include "pager.h"
+/* Not sure if necessary, but this is the margin within which the pager will
+stop paging if it's close to the end of the text buffer */
+#define PAGER_FUZZINESS 1.0
+
/* Helper function: move the pager to the last visible position in the buffer,
and return the distance between the pager and the end of the buffer in buffer
coordinates */
gtk_text_view_get_iter_location(textview, &newpager, &pagerpos);
gtk_text_view_get_iter_location(textview, &end, &endpos);
- /*
- g_printerr("View height = %d\n", visiblerect.height);
- g_printerr("End - Pager = %d - %d = %d\n", endpos.y, pagerpos.y, endpos.y - pagerpos.y);
- */
-
*view_height = visiblerect.height;
*scroll_distance = endpos.y - pagerpos.y;
}
start_paging(winid_t win)
{
win->currently_paging = TRUE;
- g_signal_handler_unblock(win->widget, win->pager_expose_handler);
+ gtk_widget_show(win->pager);
g_signal_handler_unblock(win->widget, win->pager_keypress_handler);
}
stop_paging(winid_t win)
{
win->currently_paging = FALSE;
- g_signal_handler_block(win->widget, win->pager_expose_handler);
+ gtk_widget_hide(win->pager);
g_signal_handler_block(win->widget, win->pager_keypress_handler);
}
+/* Helper function: If the adjustment is at its maximum value, stop paging */
+static void
+check_paging(GtkAdjustment *adj, winid_t win)
+{
+ double page_size, upper, value;
+ g_object_get(adj,
+ "page-size", &page_size,
+ "upper", &upper,
+ "value", &value,
+ NULL);
+ if(value + PAGER_FUZZINESS >= upper - page_size && win->currently_paging)
+ stop_paging(win);
+}
+
+void
+pager_on_clicked(GtkButton *pager, winid_t win)
+{
+ GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(win->scrolledwindow) );
+ double upper = gtk_adjustment_get_upper(adj);
+ gtk_adjustment_set_value(adj, upper);
+ check_paging(adj, win);
+ /* Give the focus back to the text view */
+ gtk_widget_grab_focus(win->widget);
+}
+
/* When the user scrolls up in a textbuffer, start paging. */
void
pager_after_adjustment_changed(GtkAdjustment *adj, winid_t win)
move_pager_and_get_scroll_distance( GTK_TEXT_VIEW(win->widget), &view_height, &scroll_distance, TRUE );
if(scroll_distance > 0 && !win->currently_paging)
+ {
start_paging(win);
+ return;
+ }
else if(scroll_distance == 0 && win->currently_paging)
+ {
stop_paging(win);
-
- /* Refresh the widget so that any extra "more" prompts disappear */
- gtk_widget_queue_draw(win->widget);
+ return;
+ }
+
+ check_paging(adj, win);
}
/* Handle key press events in the textview while paging is active */
gboolean
pager_on_key_press_event(GtkTextView *textview, GdkEventKey *event, winid_t win)
{
- GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(win->frame) );
+ GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(win->scrolledwindow) );
gdouble page_size, upper, lower, value;
g_object_get(adj,
"page-size", &page_size,
case GDK_KEY_Page_Down: case GDK_KEY_KP_Page_Down:
case GDK_KEY_Return: case GDK_KEY_KP_Enter:
gtk_adjustment_set_value(adj, CLAMP(value + page_size, lower, upper - page_size));
+ check_paging(adj, win);
return TRUE;
case GDK_KEY_Page_Up: case GDK_KEY_KP_Page_Up:
gtk_adjustment_set_value(adj, CLAMP(value - page_size, lower, upper - page_size));
+ check_paging(adj, win);
+ return TRUE;
+ case GDK_KEY_End: case GDK_KEY_KP_End:
+ gtk_adjustment_set_value(adj, upper - page_size);
+ check_paging(adj, win);
return TRUE;
/* don't handle "up" and "down", they're used for input history */
}
return FALSE; /* if the key wasn't handled here, pass it to other handlers */
}
-/* Draw the "more" prompt on top of the buffer, after the regular draw event has run */
-gboolean
-pager_on_draw(GtkTextView *textview, cairo_t *cr, winid_t win)
-{
- /* Calculate the position of the 'more' tag */
- gint promptwidth, promptheight;
- pango_layout_get_pixel_size(win->pager_layout, &promptwidth, &promptheight);
-
- int winwidth = gtk_widget_get_allocated_width( GTK_WIDGET(textview) );
- int winheight = gtk_widget_get_allocated_height( GTK_WIDGET(textview) );
-
- /* Draw the 'more' tag */
- cairo_move_to(cr, winwidth - promptwidth, winheight - promptheight);
- pango_cairo_show_layout(cr, win->pager_layout);
-
- return FALSE; /* Propagate event further */
-}
-
/* Check whether paging should be done. This function is called after the
* textview has finished validating text positions. */
void
/* Scroll past text already read by user. This is automatic scrolling, so disable the pager_ajustment_handler
* first, that acts on the belief the scolling is performed by the user. */
- GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(win->frame));
+ GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(win->scrolledwindow));
g_signal_handler_block(adj, win->pager_adjustment_handler);
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(win->widget));
GtkTextMark *pager_position = gtk_text_buffer_get_mark(buffer, "pager_position");
#include "glk.h"
#include "window.h"
-G_GNUC_INTERNAL gboolean pager_on_draw(GtkTextView *textview, cairo_t *cr, winid_t win);
+G_GNUC_INTERNAL void pager_on_clicked(GtkButton *pager, winid_t win);
G_GNUC_INTERNAL gboolean pager_on_key_press_event(GtkTextView *textview, GdkEventKey *event, winid_t win);
G_GNUC_INTERNAL void pager_after_adjustment_changed(GtkAdjustment *adj, winid_t win);
G_GNUC_INTERNAL void pager_after_size_allocate(GtkTextView *textview, GdkRectangle *allocation, winid_t win);
"user1",
"user2",
"hyperlink",
- "pager",
"default"
};
str->glk_style = (gchar*) get_glk_tag_name(styl);
}
-/* Internal function: call this to initialize the layout of the 'more' prompt. */
-void
-style_init_more_prompt(winid_t win)
-{
- ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
-
- win->pager_layout = gtk_widget_create_pango_layout(win->widget, "More");
- pango_layout_set_attributes(win->pager_layout, glk_data->pager_attr_list);
-}
-
/* Internal function: call this to initialize the default styles to a textbuffer. */
void
style_init_textbuffer(GtkTextBuffer *buffer)
g_object_set(tag, "foreground", "#0000ff", "foreground-set", TRUE, "underline", PANGO_UNDERLINE_SINGLE, "underline-set", TRUE, NULL);
g_hash_table_insert(default_text_buffer_styles, "hyperlink", tag);
- GtkTextTag *pager_tag = gtk_text_tag_new("pager");
- g_object_set(pager_tag, "family", "Monospace", "family-set", TRUE, "foreground", "#ffffff", "foreground-set", TRUE, "background", "#000000", "background-set", TRUE, NULL);
- g_hash_table_insert(default_text_buffer_styles, "pager", pager_tag);
- text_tag_to_attr_list(pager_tag, priv->pager_attr_list);
-
priv->styles->text_grid = default_text_grid_styles;
priv->styles->text_buffer = default_text_buffer_styles;
-
/* Initialize the GLK styles to empty tags */
int i;
for(i=0; i<style_NUMSTYLES; i++) {
}
g_scanner_destroy(scanner);
-
- /* Update the pager prompt to the new style */
- style_update(glk);
}
/* Internal function: parses a token */
}
}
-/* Update pager tag */
-void
-style_update(ChimaraGlk *glk)
-{
- CHIMARA_GLK_USE_PRIVATE(glk, priv);
-
- GtkTextTag *pager_tag = GTK_TEXT_TAG( g_hash_table_lookup(priv->styles->text_buffer, "pager") );
- text_tag_to_attr_list(pager_tag, priv->pager_attr_list);
-}
-
/* Determine the current colors used to render the text for a given stream.
* This can be set in a number of places */
static void
G_GNUC_INTERNAL void style_init_textbuffer(GtkTextBuffer *buffer);
G_GNUC_INTERNAL void style_init_textgrid(GtkTextBuffer *buffer);
-G_GNUC_INTERNAL void style_init_more_prompt(winid_t win);
G_GNUC_INTERNAL void style_init(ChimaraGlk *glk);
-G_GNUC_INTERNAL void style_update(ChimaraGlk *glk);
G_GNUC_INTERNAL const gchar** style_get_tag_names();
G_GNUC_INTERNAL void reset_default_styles(ChimaraGlk *glk);
G_GNUC_INTERNAL GScanner *create_css_file_scanner(void);
GHashTable *text_buffer;
} StyleSet;
-#define CHIMARA_NUM_STYLES 13
+#define CHIMARA_NUM_STYLES 12
//#define DEBUG_STYLES
g_hash_table_destroy(win->hyperlinks);
g_free(win->current_hyperlink);
- if(win->pager_layout)
- g_object_unref(win->pager_layout);
if(win->backing_store)
cairo_surface_destroy(win->backing_store);
case wintype_TextBuffer:
{
+ GtkWidget *overlay = gtk_overlay_new();
GtkWidget *scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
GtkWidget *textview = gtk_text_view_new();
+ GtkWidget *pager = gtk_button_new_with_label("More");
+ GtkWidget *image = gtk_image_new_from_stock(GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON);
GtkTextBuffer *textbuffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(textview) );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
-
+
+ gtk_button_set_image( GTK_BUTTON(pager), image );
+ gtk_widget_set_halign(pager, GTK_ALIGN_END);
+ gtk_widget_set_valign(pager, GTK_ALIGN_END);
+ gtk_widget_set_no_show_all(pager, TRUE);
+
gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW(textview), GTK_WRAP_WORD_CHAR );
gtk_text_view_set_editable( GTK_TEXT_VIEW(textview), FALSE );
gtk_text_view_set_pixels_inside_wrap( GTK_TEXT_VIEW(textview), 3 );
gtk_text_view_set_right_margin( GTK_TEXT_VIEW(textview), 20 );
gtk_container_add( GTK_CONTAINER(scrolledwindow), textview );
- gtk_widget_show_all(scrolledwindow);
+ gtk_container_add( GTK_CONTAINER(overlay), scrolledwindow );
+ gtk_overlay_add_overlay( GTK_OVERLAY(overlay), pager );
+ gtk_widget_show_all(overlay);
win->widget = textview;
- win->frame = scrolledwindow;
-
+ win->scrolledwindow = scrolledwindow;
+ win->pager = pager;
+ win->frame = overlay;
+
/* Create the styles available to the window stream */
style_init_textbuffer(textbuffer);
- style_init_more_prompt(win);
gtk_widget_modify_font( textview, get_current_font(wintype) );
-
+
/* Determine the size of a "0" character in pixels */
PangoLayout *zero = gtk_widget_create_pango_layout(textview, "0");
pango_layout_set_font_description( zero, get_current_font(wintype) );
/* Pager */
g_signal_connect_after( textview, "size-allocate", G_CALLBACK(pager_after_size_allocate), win );
- win->pager_expose_handler = g_signal_connect_after( textview, "draw", G_CALLBACK(pager_on_draw), win );
- g_signal_handler_block(textview, win->pager_expose_handler);
win->pager_keypress_handler = g_signal_connect( textview, "key-press-event", G_CALLBACK(pager_on_key_press_event), win );
g_signal_handler_block(textview, win->pager_keypress_handler);
GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrolledwindow));
win->pager_adjustment_handler = g_signal_connect_after(adj, "value-changed", G_CALLBACK(pager_after_adjustment_changed), win);
+ g_signal_connect(pager, "clicked", G_CALLBACK(pager_on_clicked), win);
/* Char and line input */
win->char_input_keypress_handler = g_signal_connect( textview, "key-press-event", G_CALLBACK(on_char_input_key_press_event), win );
/* "frame" is the widget that is the child of the ChimaraGlk container, such
as a scroll window. It may be the same as "widget". */
GtkWidget *frame;
+ /* In text buffer windows, the scrolled window and the pager are extra
+ widgets that are neither "widget" nor "frame" */
+ GtkWidget *scrolledwindow;
+ GtkWidget *pager;
/* Width and height of the window's size units, in pixels */
int unit_width;
int unit_height;
gulong shutdown_keypress_handler;
gulong button_press_event_handler;
gulong size_allocate_handler;
- gulong pager_expose_handler;
gulong pager_keypress_handler;
gulong pager_adjustment_handler;
/* Window buffer */
cairo_surface_t *backing_store;
/* Pager (textbuffer only) */
gboolean currently_paging;
- PangoLayout *pager_layout;
};
#endif
if( !gtk_toggle_button_get_active(button) )
return;
g_object_set(current_tag, "justification", GTK_JUSTIFY_LEFT, "justification-set", TRUE, NULL);
- chimara_glk_update_style(glk);
}
void
if( !gtk_toggle_button_get_active(button) )
return;
g_object_set(current_tag, "justification", GTK_JUSTIFY_CENTER, "justification-set", TRUE, NULL);
- chimara_glk_update_style(glk);
}
void
if( !gtk_toggle_button_get_active(button) )
return;
g_object_set(current_tag, "justification", GTK_JUSTIFY_RIGHT, "justification-set", TRUE, NULL);
- chimara_glk_update_style(glk);
}
void
if( !gtk_toggle_button_get_active(button) )
return;
g_object_set(current_tag, "justification", GTK_JUSTIFY_FILL, "justification-set", TRUE, NULL);
- chimara_glk_update_style(glk);
}
void
g_object_set(current_tag, "weight", PANGO_WEIGHT_BOLD, "weight-set", TRUE, NULL);
else
g_object_set(current_tag, "weight", PANGO_WEIGHT_NORMAL, "weight-set", TRUE, NULL);
-
- chimara_glk_update_style(glk);
}
void
g_object_set(current_tag, "style", PANGO_STYLE_ITALIC, "style-set", TRUE, NULL);
else
g_object_set(current_tag, "style", PANGO_STYLE_NORMAL, "style-set", TRUE, NULL);
-
- chimara_glk_update_style(glk);
}
void
g_object_set(current_tag, "underline", PANGO_UNDERLINE_SINGLE, "underline-set", TRUE, NULL);
else
g_object_set(current_tag, "underline", PANGO_UNDERLINE_NONE, "underline-set", TRUE, NULL);
-
- chimara_glk_update_style(glk);
}
void
GdkColor color;
gtk_color_button_get_color(button, &color);
g_object_set(current_tag, "foreground-gdk", &color, "foreground-set", TRUE, NULL);
- chimara_glk_update_style(glk);
}
void
GdkColor color;
gtk_color_button_get_color(button, &color);
g_object_set(current_tag, "background-gdk", &color, "background-set", TRUE, NULL);
- chimara_glk_update_style(glk);
}
void
const gchar *font_name = gtk_font_button_get_font_name(button);
PangoFontDescription *font_description = pango_font_description_from_string(font_name);
g_object_set(current_tag, "font-desc", font_description, NULL);
- chimara_glk_update_style(glk);
}
void
buffer.user2 {
}
-
-buffer.pager {
- color: #ffffff;
- background-color: #303030;
-}