Skip to content

Commit

Permalink
kernel: move EndLineHook to only file using it
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Dec 22, 2022
1 parent f563a36 commit bcdfe8d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
7 changes: 4 additions & 3 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ static Obj IsOutputStringStream;
static Obj PositionStream;
static Obj SeekPositionStream;

// 'PrintPromptHook' is a GAP-level variable which can be set to a function
// for printing the GAP prompt. If not bound, 'STATE(Prompt)' is printed.
static Obj PrintPromptHook = 0;
Obj EndLineHook = 0;

static Obj PrintFormattingStatus;
static Obj SetPrintFormattingStatus;

Expand Down Expand Up @@ -1060,7 +1062,7 @@ static Char GetLine(TypInputFile * input)

// if file is '*stdin*' or '*errin*' print the prompt and flush it
// if the GAP function `PrintPromptHook' is defined then it is called
// for printing the prompt, see also `EndLineHook'
// for printing the prompt
if (!input->stream) {
if (input->file == 0 && SyQuiet) {
Pr("%c", (Int)'\03', 0);
Expand Down Expand Up @@ -2061,7 +2063,6 @@ static Int InitKernel (
ImportFuncFromLibrary( "PositionStream", &PositionStream );
ImportFuncFromLibrary( "SeekPositionStream", &SeekPositionStream );
InitCopyGVar( "PrintPromptHook", &PrintPromptHook );
InitCopyGVar( "EndLineHook", &EndLineHook );
InitFopyGVar( "PrintFormattingStatus", &PrintFormattingStatus);
InitFopyGVar( "SetPrintFormattingStatus", &SetPrintFormattingStatus);

Expand Down
11 changes: 0 additions & 11 deletions src/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,6 @@ UInt CloseInputLog(void);
*/
void SetPrompt(const char * prompt);

/****************************************************************************
**
*V PrintPromptHook . . . . . . . . . . . . . . function for printing prompt
*V EndLineHook . . . . . . . . . . . function called at end of command line
**
** These functions can be set on GAP-level. If they are not bound the
** default is: Instead of 'PrintPromptHook' the 'Prompt' is printed and
** instead of 'EndLineHook' nothing is done.
*/
// TL: extern Obj PrintPromptHook;
extern Obj EndLineHook;

/****************************************************************************
**
Expand Down
9 changes: 7 additions & 2 deletions src/sysfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ typedef void sig_handler_t ( int );
#include <sys/utsname.h>


// 'EndLineHook' is a GAP-level variable which can be set to a function to be
// called at end of each command line (i.e. after the user presses enter).
// If not bound, nothing is done.
static Obj EndLineHook = 0;

/****************************************************************************
**
*V syBuf . . . . . . . . . . . . . . buffer and other info for files, local
Expand Down Expand Up @@ -3517,9 +3522,9 @@ static Int InitKernel(
InitCopyGVar("OnCharReadHookExcFuncs",&OnCharReadHookExcFuncs);
#endif

InitCopyGVar("EndLineHook", &EndLineHook);

return 0;

return 0;
}

/****************************************************************************
Expand Down

0 comments on commit bcdfe8d

Please sign in to comment.