From f97fff8524c8f5a024d007871da7388a153a71b1 Mon Sep 17 00:00:00 2001 From: Ianos Gnatiuc Date: Wed, 26 Oct 2005 00:28:43 +0000 Subject: [PATCH] Added new macros: @pad{FAN}{T} --- docs/notework.txt | 9 +++++++++ golded3/gemsgs.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/docs/notework.txt b/docs/notework.txt index ad6a7a3..b1ae2cf 100644 --- a/docs/notework.txt +++ b/docs/notework.txt @@ -10,6 +10,15 @@ ______________________________________________________________________ Notes for GoldED+ 1.1.5, /snapshot/ ______________________________________________________________________ ++ Added new macros: @pad{FAN}{T} + + Where: F - a fill char, that will be used when length(T) < N + A - type of text alignment (C - center, L - left, R - right) + N - size of pad area (N >= 0) + T - any text and/or macroses without parameters + + Example: @pad{=C79}{ @OEcho (@ODesc) } + - Pick string windows will be resized to title length also. + Added @daddr to built-in template for netmail areas. diff --git a/golded3/gemsgs.cpp b/golded3/gemsgs.cpp index 3dc87e6..e676804 100644 --- a/golded3/gemsgs.cpp +++ b/golded3/gemsgs.cpp @@ -420,6 +420,54 @@ char* TokenXlat(int mode, char* input, GMsg* msg, GMsg* oldmsg, int __origarea) continue; } + char *ptr1, *ptr2; + if (strnieql(dst, "@pad{", 5) && + ((ptr1 = strstr(dst+5, "}{")) != NULL) && + ((ptr1-dst-5) > 2) && + ((ptr2 = strchr(ptr1+2, '}')) != NULL) + ) + { + char buff[1024]; + char token[1024]; + char fill = dst[5]; + char align = toupper(dst[6]); + int size = atoi(dst+7); + + if (strchr("CLR", align)) + { + memcpy(token, dst, ptr2-dst+1); + memcpy(buff, ptr1+2, ptr2-ptr1-2); + token[ptr2-dst+1] = buff[ptr2-ptr1-2] = 0; + + TokenXlat(mode, buff, msg, oldmsg, __origarea); + buff[size] = 0; + + size_t length = strlen(buff); + if (length != size) + { + size_t diff = size - length; + switch (align) + { + case 'C': + memmove(&buff[diff/2], buff, length); + memset(buff, fill, diff/2); + memset(&buff[diff/2+length], fill, diff-diff/2); + break; + case 'L': + memset(&buff[length], fill, diff); + break; + case 'R': + memmove(&buff[diff], buff, length); + memset(buff, fill, diff); + break; + } + } + + if (tokenxchg(dst, token, buff)) + continue; + } + } + dst++; } }