Files
sibo-playground/code/SIBOSDK/demo/hcshell.c
2026-07-06 18:01:36 +01:00

71 lines
1.6 KiB
C

/*
HCSHELL.C - Sample shell for the HC
*/
#include <plib.h>
#include <wlib.h>
GLREF_D UINT wMainGc;
GLREF_D WSERV_SPEC wSpec;
LOCAL_D INT FontHeight;
LOCAL_D INT FontAscent;
LOCAL_C VOID SetFontHeight(VOID)
{
G_FONT_INFO info;
gFontInfo(WS_FONT_SYSTEM,0,&info);
FontHeight=info.height;
FontAscent=info.ascent;
}
LOCAL_C VOID CDECL PrintLine(INT line,INT align,TEXT *fmt,...)
{
INT len;
P_RECT box;
TEXT b[80];
box.tl.x=4;
box.br.x=wSpec.conn.info.pixels.x-4;
box.tl.y=FontHeight*line+4;
box.br.y=box.tl.y+FontHeight;
len=p_atob(&b[0],fmt,&fmt+1);
gPrintBoxText(&box,FontAscent,align,0,&b[0],len);
}
LOCAL_C VOID HandleKeyPress(WMSG_KEY *pk)
{
PrintLine(2,G_TEXT_ALIGN_CENTRE,"code:%02x mod:%02x count:%02x",
pk->keycode,pk->modifiers,pk->count);
}
LOCAL_C VOID MainEventLoop(VOID)
{
WS_EV event;
SetFontHeight();
gBorder(W_BORD_SHADOW_D|W_BORD_SHADOW_ON);
PrintLine(0,G_TEXT_ALIGN_LEFT,"Free memory: %dKbytes",p_sgfree()>>6);
for (;;)
{
wGetEventWait(&event);
if (event.type==WM_KEY)
HandleKeyPress(&event.p.key);
}
}
GLDEF_C INT main(VOID)
{
INT NotifierPid;
wStartup();
wSystem(WSERV_FLAG_NO_NOTIFIER_REBOOT,0xffff);
if ((NotifierPid=p_pidfind("SYS$NTFY.*"))>0)
p_pterminate(NotifierPid,0);
wSystem(WSERV_FLAG_HOOK_NOTIFIER|WSERV_FLAG_LOW_BATTERY_WARNINGS|WSERV_FLAG_HUNG_UP_SW,
WSERV_FLAG_HOOK_NOTIFIER|WSERV_FLAG_LOW_BATTERY_WARNINGS|WSERV_FLAG_HUNG_UP_SW);
MainEventLoop();
return(0);
}