Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #135030

Re: The joy of formatting

Date 2026-05-01 09:57 +1000
Subject Re: The joy of formatting
Newsgroups comp.lang.forth
References <nnd$7b365bf7$7124ac52@50f873c72dd8fb98> <69f2ba42$1@news.ausics.net> <nnd$5188275e$5d740caa@15d7ec6ab0bb7dfb> <69f36016$1@news.ausics.net> <nnd$36020a68$7d940848@8c5641d01ac9a818>
From dxf <dxforth@gmail.com>
Message-ID <69f3ec53$1@news.ausics.net> (permalink)
Organization Ausics - https://newsgroups.ausics.net

Show all headers | View raw


On 1/05/2026 2:11 am, albert@spenarnc.xs4all.nl wrote:
> In article <69f36016$1@news.ausics.net>, dxf  <dxforth@gmail.com> wrote:
>> On 30/04/2026 7:11 pm, albert@spenarnc.xs4all.nl wrote:
>>> In article <69f2ba42$1@news.ausics.net>, dxf  <dxforth@gmail.com> wrote:
>>>> On 29/04/2026 11:41 pm, albert@spenarnc.xs4all.nl wrote:
>>>>> Formerly I had this clunky handling of colors.
>>>>> ...
>>>>> Now if you have FORMAT this becomes a lot less clunky.
>>>>
>>>> I agree the original was clunky.  But whether FORMAT was necessary,
>>>> I'm less certain.  Naturally, I'm too lazy to show an alternative.
>>>> But I can for your last example, as I'm sure can others ...
>>>>
>>>>> : default-bw "%e [00m" FORMAT TYPE ;
>>>>
>>>> : default-bw ." \1b[00m" ;
>>>>
>>> Now consider this:
>>> : AT-XY   1+ SWAP 1+ SWAP "%e [%d ;%d H" .FORMAT ; \ ISO
>>
>> What if the digits field had to be exactly 2 or 3 digits to suit
>> a specific terminal?  You would have to code for it.  Worst case
>> is something like Turbo Pascal which handled almost any terminal.
>> In DX-Forth for CP/M, here's how that looks:
>>
>> https://pastebin.com/EvZvaaCw
>>
> 
> You have to code, but it is not hard.  <# # #> are your friends.
> 
> You have to be careful, because there is only one hold area.
> : prepare 1+ 0 <# # # # #> ;
> : AT-XY   SWAP prepare "%e [%s " .FORMAT prepare ";%s H" .FORMAT ; \ ISO
> I wonder how you handle that with escapes in a regular string.
> 
> Or if you have an ALLOCATE available, you can make strings permanent.
> : prepare 1+ 0 <# # # # #>  >permanent ;
> and it is even easier.
> 
> : >permanent   DUP CELL+ ALLOCATE THROW >R R@ $! R> @$ ;

From a Gforth include:

: pn    ( n -- )  0 <# # # #> type ;
: ;pn   [char] ; emit pn ;
: ESC[  27 emit [char] [ emit ;
: at-xy 1+ 1 under+ ESC[ pn ;pn [char] H emit ;

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

The joy of formatting albert@spenarnc.xs4all.nl - 2026-04-29 15:41 +0200
  Re: The joy of formatting dxf <dxforth@gmail.com> - 2026-04-30 12:11 +1000
    Re: The joy of formatting Hans Bezemer <the.beez.speaks@gmail.com> - 2026-04-30 09:48 +0200
    Re: The joy of formatting albert@spenarnc.xs4all.nl - 2026-04-30 11:06 +0200
      Re: The joy of formatting Hans Bezemer <the.beez.speaks@gmail.com> - 2026-04-30 23:34 +0200
    Re: The joy of formatting albert@spenarnc.xs4all.nl - 2026-04-30 11:11 +0200
      Re: The joy of formatting dxf <dxforth@gmail.com> - 2026-04-30 23:58 +1000
        Re: The joy of formatting albert@spenarnc.xs4all.nl - 2026-04-30 18:11 +0200
          Re: The joy of formatting dxf <dxforth@gmail.com> - 2026-05-01 09:57 +1000
            Re: The joy of formatting anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-01 06:03 +0000
              Re: The joy of formatting dxf <dxforth@gmail.com> - 2026-05-03 23:09 +1000
                Re: The joy of formatting anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-03 14:11 +0000
                Re: The joy of formatting dxf <dxforth@gmail.com> - 2026-05-04 11:02 +1000
      Re: The joy of formatting minforth <minforth@gmx.net> - 2026-04-30 20:47 +0200
        Re: The joy of formatting Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-05-03 09:07 -0500

csiph-web