From 0ad2c4a2cb47f80d46e2234229407f22833c60c9 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Thu, 11 Apr 2019 10:01:49 +0000 Subject: [PATCH] Define and use sbbs_t::msghdr_tos (exposed via JS as console.msghdr_top_of_screen): a hack to let scripts know whether the most-recently displayed message header was displayed on the top of the terminal screen (or not). This allows us to show avatars at the top of the screen when the header is up there, rather than relevative to the bottom of the header (the pos can vary, depending on stuff). --- src/sbbs3/getmsg.cpp | 1 + src/sbbs3/js_bbs.cpp | 9 +++++++++ src/sbbs3/js_console.cpp | 2 +- src/sbbs3/main.cpp | 4 +++- src/sbbs3/sbbs.h | 3 ++- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/sbbs3/getmsg.cpp b/src/sbbs3/getmsg.cpp index eec6149d80..98b5f6fd7b 100644 --- a/src/sbbs3/getmsg.cpp +++ b/src/sbbs3/getmsg.cpp @@ -137,6 +137,7 @@ void sbbs_t::show_msghdr(smb_t* smb, smbmsg_t* msg) else CRLF; } + msghdr_tos = tos; if(!menu("msghdr", P_NOERROR)) { bprintf(text[MsgSubj],msg->subj); if(msg->tags && *msg->tags) diff --git a/src/sbbs3/js_bbs.cpp b/src/sbbs3/js_bbs.cpp index e809d532c0..0b8f308813 100644 --- a/src/sbbs3/js_bbs.cpp +++ b/src/sbbs3/js_bbs.cpp @@ -145,6 +145,8 @@ enum { ,BBS_PROP_MSG_REPLY_ID ,BBS_PROP_MSG_DELIVERY_ATTEMPTS + ,BBS_PROP_MSGHDR_TOS + /* READ ONLY */ ,BBS_PROP_BATCH_UPLOAD_TOTAL ,BBS_PROP_BATCH_DNLOAD_TOTAL @@ -268,6 +270,8 @@ enum { ,"message replied-to identifier" ,"message delivery attempt counter" + ,"message header displayed at top-of-screen" + ,"file name" ,"file description" ,"file directory (number)" @@ -691,6 +695,9 @@ static JSBool js_bbs_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp) else p=sbbs->current_msg->reply_id; break; + case BBS_PROP_MSGHDR_TOS: + val = sbbs->msghdr_tos; + break; /* Currently Displayed File (sbbs.current_file) */ case BBS_PROP_FILE_NAME: @@ -1082,6 +1089,8 @@ static jsSyncPropertySpec js_bbs_properties[] = { { "msg_delivery_attempts" ,BBS_PROP_MSG_DELIVERY_ATTEMPTS ,PROP_READONLY ,310}, + { "msghdr_top_of_screen" ,BBS_PROP_MSGHDR_TOS ,PROP_READONLY ,31702}, + { "file_name" ,BBS_PROP_FILE_NAME ,PROP_READONLY ,317}, { "file_description" ,BBS_PROP_FILE_DESC ,PROP_READONLY ,317}, { "file_dir_number" ,BBS_PROP_FILE_DIR ,PROP_READONLY ,317}, diff --git a/src/sbbs3/js_console.cpp b/src/sbbs3/js_console.cpp index 83b7d319d1..9c56f20f15 100644 --- a/src/sbbs3/js_console.cpp +++ b/src/sbbs3/js_console.cpp @@ -234,7 +234,7 @@ static JSBool js_console_set(JSContext *cx, JSObject *obj, jsid id, JSBool stric JS_RESUMEREQUEST(cx, rc); break; case CON_PROP_TOS: - sbbs->tos=val; + sbbs->tos = val ? true : false; break; case CON_PROP_ROWS: if(val >= TERM_ROWS_MIN && val <= TERM_ROWS_MAX) diff --git a/src/sbbs3/main.cpp b/src/sbbs3/main.cpp index 8669ca1d17..3f9e092760 100644 --- a/src/sbbs3/main.cpp +++ b/src/sbbs3/main.cpp @@ -3403,8 +3403,10 @@ sbbs_t::sbbs_t(ushort node_num, union xp_sockaddr *addr, size_t addr_len, const telnet_ack_event=CreateEvent(NULL, /* Manual Reset: */FALSE,/* InitialState */FALSE,NULL); listInit(&savedlines, /* flags: */0); + sys_status=lncntr=criterrs=0L; + tos = false; + msghdr_tos = false; listInit(&smb_list, /* flags: */0); - sys_status=lncntr=tos=criterrs=0L; column=0; tabstop=8; lastlinelen=0; diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index 1b79a910ed..c443fb4083 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -467,7 +467,8 @@ public: uchar attr_stack[64]; /* Saved attributes (stack) */ int attr_sp; /* Attribute stack pointer */ long lncntr; /* Line Counter - for PAUSE */ - long tos; /* Top of Screen */ + bool tos; /* Cursor is currently at the Top of Screen */ + bool msghdr_tos; /* Message header was displayed at Top of Screen */ long rows; /* Current number of Rows for User */ long cols; /* Current number of Columns for User */ long column; /* Current column counter (for line counter) */ -- GitLab