Skip to content

Commit

Permalink
Use the new Glk event kind
Browse files Browse the repository at this point in the history
  • Loading branch information
curiousdannii committed Aug 11, 2024
1 parent 6eb1a09 commit 0d43239
Show file tree
Hide file tree
Showing 16 changed files with 455 additions and 362 deletions.
130 changes: 60 additions & 70 deletions inform7/Internal/Extensions/Graham Nelson/Basic Inform.i7x
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ To fill/redraw the/-- status bar/line/window with (new status table - a table-na
if once only:
now the status window table is the old status window table;

To move the status bar/line/window cursor to row (row - number) and/-- column (col - number):
To move the status bar/line/window cursor to row (row - number) and/-- column/col (col - number):
(- VM_MoveCursorInStatusLine({row}, {col}); -).

To set the status bar/line/window to (rows - number) row/rows:
Expand Down Expand Up @@ -1724,7 +1724,7 @@ To decide what version number is the interpreter version number/--:

Chapter - Glk windows

A glk window is a kind of abstract object.
A Glk window is a kind of abstract object.
The glk window kind is accessible to Inter as "K_Glk_Window".
The specification of a glk window is "Models the Glk window system."

Expand Down Expand Up @@ -1773,81 +1773,71 @@ To decide what number is the width of (win - a glk window)
(documented at ph_glkwindowwidth):
(- WindowGetSize({win}, 0) -).

To set (win - a glk window) cursor to row (row - a number) and/-- column (col - a number)
To set (win - a glk window) cursor to row (row - a number) and/-- column/col (col - a number)
(documented at ph_glksetcursor):
(- WindowMoveCursor({win}, {col}, {row}); -).

Chapter - Glk events

The glk event handling rules is a glk event based rulebook.
To decide what glk event is (evtype - glk event type) glk event:
(- GLK_EVENT_TY_New({-new: glk event}, {evtype}) -).

To decide what glk event is a/-- character event for/of/with (C - unicode character):
(- GLK_EVENT_TY_New({-new: glk event}, evtype_CharInput, 0, MapUnicodeToGlkKeyCode({C})) -).
To decide what glk event is a/-- character event for/of/with (C - unicode character) in (win - glk window):
(- GLK_EVENT_TY_New({-new: glk event}, evtype_CharInput, {win}, MapUnicodeToGlkKeyCode({C})) -).

To decide what glk event is a/-- line event for/of/with (T - text):
(- GLK_EVENT_TY_New({-new: glk event}, evtype_LineInput, 0, 0, 0, {-by-reference:T}) -).
To decide what glk event is a/-- line event for/of/with (T - text) in (win - glk window):
(- GLK_EVENT_TY_New({-new: glk event}, evtype_LineInput, {win}, 0, 0, {-by-reference:T}) -).

To decide what glk event is a/-- mouse event for/of/with x (x - number) and/-- y (y - a number) coordinates/--:
(- GLK_EVENT_TY_New({-new: glk event}, evtype_MouseInput, 0, {x}, {y}) -).
To decide what glk event is a/-- mouse event for/of/with x (x - number) and/-- y (y - a number) coordinates/-- in (win - glk window):
(- GLK_EVENT_TY_New({-new: glk event}, evtype_MouseInput, {win}, {x}, {y}) -).
To decide what glk event is a/-- mouse event for/of/with row (y - number) and/-- column/col (x - a number):
(- GLK_EVENT_TY_New({-new: glk event}, evtype_MouseInput, 0, {x}, {y}) -).
To decide what glk event is a/-- mouse event for/of/with row (y - number) and/-- column/col (x - a number) in (win - glk window):
(- GLK_EVENT_TY_New({-new: glk event}, evtype_MouseInput, {win}, {x}, {y}) -).

To decide what glk event is a/-- hyperlink event for/of/with (val - number):
(- GLK_EVENT_TY_New({-new: glk event}, evtype_Hyperlink, 0, {val}) -).
To decide what glk event is a/-- hyperlink event for/of/with (val - number) in (win - glk window):
(- GLK_EVENT_TY_New({-new: glk event}, evtype_Hyperlink, {win}, {val}) -).

To decide what glk event type is type of (ev - glk event):
(- GLK_EVENT_TY_Type({ev}) -).

To decide what glk window is window of (ev - glk event):
(- GLK_EVENT_TY_Window({ev}) -).

To decide what unicode character is the character value of (ev - glk event):
(- GLK_EVENT_TY_Value1({ev}) -).

To decide what number is the x coordinate of (ev - glk event):
(- GLK_EVENT_TY_Value1({ev}) -).
To decide what number is the y coordinate of (ev - glk event):
(- GLK_EVENT_TY_Value2({ev}) -).
To decide what number is the row of (ev - glk event):
(- GLK_EVENT_TY_Value2({ev}) -).
To decide what number is the column of (ev - glk event):
(- GLK_EVENT_TY_Value1({ev}) -).

To decide what number is the hyperlink value of (ev - glk event):
(- GLK_EVENT_TY_Value1({ev}) -).

To decide what text is the text of (ev - glk event):
(- GLK_EVENT_TY_Text({ev}, {-new: text}) -).

The glk event handling rules is a glk event type based rulebook.
The glk event handling rules is accessible to Inter as "GLK_EVENT_HANDLING_RB".

To decide what glk window is the glk event window:
(- Glk_Event_Struct_win -).

To decide what unicode character is the character event value:
(- (CheckEventType(evtype_CharInput), MapGlkKeyCodeToUnicode(Glk_Event_Struct_val1)) -).

To decide what number is the mouse event x coordinate:
(- (CheckEventType(evtype_MouseInput), Glk_Event_Struct_val1 + (Glk_Event_Struct_win.glk_window_type == wintype_TextGrid)) -).
To decide what number is the mouse event y coordinate:
(- (CheckEventType(evtype_MouseInput), Glk_Event_Struct_val2 + (Glk_Event_Struct_win.glk_window_type == wintype_TextGrid)) -).
To decide what number is the mouse event row:
(- (CheckEventType(evtype_MouseInput), Glk_Event_Struct_val2 + (Glk_Event_Struct_win.glk_window_type == wintype_TextGrid)) -).
To decide what number is the mouse event column:
(- (CheckEventType(evtype_MouseInput), Glk_Event_Struct_val1 + (Glk_Event_Struct_win.glk_window_type == wintype_TextGrid)) -).

To decide what number is the hyperlink event value:
(- (CheckEventType(evtype_Hyperlink), Glk_Event_Struct_val1) -).

To process a null event:
(- ProcessGlkEvent(evtype_None); rtrue; -).

To process a timer event:
(- ProcessGlkEvent(evtype_Timer); rtrue; -).

To process a character event for/of/with (C - unicode character):
(- ProcessGlkEvent(evtype_CharInput, 0, MapUnicodeToGlkKeyCode({C})); rtrue; -).
To process a character event for/of/with (C - unicode character) in (win - glk window):
(- ProcessGlkEvent(evtype_CharInput, {win}, MapUnicodeToGlkKeyCode({C})); rtrue; -).

To process a line event:
(- ProcessGlkEvent(evtype_LineInput); rtrue; -).
To process a line event in (win - glk window):
(- ProcessGlkEvent(evtype_LineInput, {win}); rtrue; -).

To process a mouse event for x (x - number) and/-- y (y - a number) coordinates:
(- ProcessGlkEvent(evtype_MouseInput, 0, {x}, {y}); rtrue; -).
To process a mouse event for x (x - number) and/-- y (y - a number) coordinates in (win - glk window):
(- ProcessGlkEvent(evtype_MouseInput, {win}, {x}, {y}); rtrue; -).
To process a mouse event for row (y - number) and/-- column (x - a number):
(- ProcessGlkEvent(evtype_MouseInput, 0, {x}, {y}); rtrue; -).
To process a mouse event for row (y - number) and/-- column (x - a number) in (win - glk window):
(- ProcessGlkEvent(evtype_MouseInput, {win}, {x}, {y}); rtrue; -).

To process a hyperlink event for/of/with (val - number):
(- ProcessGlkEvent(evtype_Hyperlink, 0, {val}); rtrue; -).
To process a hyperlink event for/of/with (val - number) in (win - glk window):
(- ProcessGlkEvent(evtype_Hyperlink, {win}, {val}); rtrue; -).

To process a screen resize event:
(- ProcessGlkEvent(evtype_Arrange); rtrue; -).

To process a graphics window lost event:
(- ProcessGlkEvent(evtype_Redraw); rtrue; -).

To process a sound notification event:
(- ProcessGlkEvent(evtype_SoundNotify); rtrue; -).

To process a volume event:
(- ProcessGlkEvent(evtype_VolumeNotify); rtrue; -).

First glk event handling rule for a glk event (called the event) (this is the update input requests rule):
[ It was too risky to set the text input status here, in case the author also sets a first glk event handling rule, so that property is reset within glk_select. ]
if the event is hyperlink event:
now the glk event window is not requesting hyperlink input;
if the event is mouse event:
now the glk event window is not requesting mouse input;
The current glk event is a glk event variable.
The current glk event variable is defined by Inter as "current_glk_event".

To process (ev - glk event):
(- GLK_EVENT_TY_Process({ev}); rtrue; -).

Glk event handling rule for a screen resize event (this is the redraw the status line rule):
redraw the status window;
Expand Down
1 change: 0 additions & 1 deletion inform7/Internal/Inter/Architecture32Kit/Contents.w
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Sections
Capabilities
InfGlk
Glk
Glk Events
Startup
State
Mathematics
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Event is on unknown Glk window

A Glk event has occurred which references a window we don't know about. This could be caused by old extensions which created their own windows in Inform 6. Inform now requires such extensions to also create a `glk window` object and keep it updated, so that the events system can track all windows.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Glk event phrase called for wrong event type

A Glk event phrase was used for the wrong event type, for example `the mouse event x coordinate` was used with a hyperlink event.
A Glk event phrase was used for the wrong event type, for example `x coordinate` was used with a hyperlink event.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Glk event created for window of wrong type

Glk events can only be created for the appropriate window type. For example, line events can't be created for graphics window, mouse events can't be created for buffer windows. In particular, note that if you create an event without explicitly specifying the window, the main window will be used, which is usually a buffer window.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Cannot set current line input of a window with active line input

The `set the current line input` phrase cannot be used for a window which currently has active line input; there'd be no point as the text you set would be overwritten once the player submitted their input. You should only use `set the current line input` while handling a line event, or after using `suspend text input`.

This file was deleted.

96 changes: 0 additions & 96 deletions inform7/Internal/Inter/Architecture32Kit/Sections/Glk Events.i6t

This file was deleted.

Loading

0 comments on commit 0d43239

Please sign in to comment.