From 36cd3b555274d009bb3e9e02acb013a3c9c4af62 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Tue, 1 Sep 2015 03:19:42 +0000 Subject: [PATCH] Create a C version of sbbs_t::ansi(), call it ansi_attr() and DLL-export it. --- src/sbbs3/ansiterm.cpp | 13 +++++++++---- src/sbbs3/sbbs.h | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/sbbs3/ansiterm.cpp b/src/sbbs3/ansiterm.cpp index 5a2d492fae..b17dec387f 100644 --- a/src/sbbs3/ansiterm.cpp +++ b/src/sbbs3/ansiterm.cpp @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -98,14 +98,14 @@ const char *sbbs_t::ansi(int atr) } /* insure str is at least 14 bytes in size! */ -char* sbbs_t::ansi(int atr, int curatr, char* str) +extern "C" char* ansi_attr(int atr, int curatr, char* str, BOOL color) { - if(!term_supports(COLOR)) { /* eliminate colors if user doesn't have them */ + if(!color) { /* eliminate colors if terminal doesn't support them */ if(atr&LIGHTGRAY) /* if any foreground bits set, set all */ atr|=LIGHTGRAY; if(atr&BG_LIGHTGRAY) /* if any background bits set, set all */ atr|=BG_LIGHTGRAY; - if(atr&LIGHTGRAY && atr&BG_LIGHTGRAY) + if((atr&LIGHTGRAY) && (atr&BG_LIGHTGRAY)) atr&=~LIGHTGRAY; /* if background is solid, foreground is black */ if(!atr) atr|=LIGHTGRAY; /* don't allow black on black */ @@ -193,6 +193,11 @@ char* sbbs_t::ansi(int atr, int curatr, char* str) return str; } +char* sbbs_t::ansi(int atr, int curatr, char* str) +{ + return ::ansi_attr(atr, curatr, str, term_supports(COLOR) ? TRUE:FALSE); +} + void sbbs_t::ansi_getlines() { if(sys_status&SS_USERON && useron.misc&ANSI && !useron.rows /* Auto-detect rows */ diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index 457c3d4b73..20badbde39 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -982,6 +982,8 @@ public: #ifdef __cplusplus extern "C" { #endif + /* ansiterm.cpp */ + DLLEXPORT char* DLLCALL ansi_attr(int attr, int curattr, char* str, BOOL color); /* main.cpp */ DLLEXPORT int DLLCALL sbbs_random(int); -- GitLab