Newsboat: Escaped tabs do not display properly

Created on 12 Nov 2017  Â·  4Comments  Â·  Source: newsboat/newsboat

Newsboat version: newsboat 2.10.1

Steps to reproduce the issue:

  1. Set feedlist-format "%U \t %t", or replace \t with a literal tab character.

  2. Open to feed list and see 1 � xkcd, etc. for each feed item

This bug exists on macOS in Terminal.app and in iTerm.app (also tested the issue in a Debian virtual machine, found the bug also exists in at least a tty running newsbeuter 2.9.)

bug to consider

Most helpful comment

If someone wanna dive into STFL to know how it work with \t and what is wrong, this example illustrate problem with \t:

example.cpp

#include "stfl.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

#include <langinfo.h>
#include <locale.h>

int main()
{
    if (!setlocale(LC_ALL,""))
        fprintf(stderr, "WARING: Can't set locale!\n");
    struct stfl_ipool *ipool = stfl_ipool_create(nl_langinfo(CODESET));
    struct stfl_form *f = stfl_create(L"<example.stfl>");

        stfl_modify(f, L"lol", L"replace_inner", stfl_ipool_towc(ipool, "{list {listitem[0] text:\"show that\"}{listitem[1] text:\"and show\tthat\"}}"));
    stfl_ipool_flush(ipool);

    const wchar_t *event = 0;
    while (1) {
        event = stfl_run(f, 0);
        if (event) {
            if (!wcscmp(event, L"ESC"))
                break;
            else if (!wcscmp(event, L"^L"))
                stfl_redraw();
        }
    }

    stfl_reset();
    stfl_ipool_flush(ipool);

    stfl_free(f);
    stfl_ipool_destroy(ipool);

    return 0;
}

example.stfl

vbox
  !list[lol]
    .expand:vh
    richtext:1
    style_normal:bg=white,fg=black
    style_focus:fg=yellow,bg=blue,attr=bold

Move this to one directory and compile with <your compiler> -lstfl example.cpp

All 4 comments

Terminals are capable of displaying escaped tabs, as shown by the indented output of echo -n "\t".

I found out that static method utils::clean_nonprintable_characters(std::wstring) just replace \t to \uFFFD.
But when I didn't replace, all after \t in feeditem was lost(see pictures).
Before:
am-0
After:
am-0

I don't know why this happens, maybe it's limitation of stfl.
Who have any ideas about why this happens?

A workaround: use %-8U %t instead. See the docs on format strings.

@spiridoncha: I got the same result as you did, and it does look like STFL's limitation. Will have to dive into the library's code to find out what specifically is wrong with tabs.

If someone wanna dive into STFL to know how it work with \t and what is wrong, this example illustrate problem with \t:

example.cpp

#include "stfl.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

#include <langinfo.h>
#include <locale.h>

int main()
{
    if (!setlocale(LC_ALL,""))
        fprintf(stderr, "WARING: Can't set locale!\n");
    struct stfl_ipool *ipool = stfl_ipool_create(nl_langinfo(CODESET));
    struct stfl_form *f = stfl_create(L"<example.stfl>");

        stfl_modify(f, L"lol", L"replace_inner", stfl_ipool_towc(ipool, "{list {listitem[0] text:\"show that\"}{listitem[1] text:\"and show\tthat\"}}"));
    stfl_ipool_flush(ipool);

    const wchar_t *event = 0;
    while (1) {
        event = stfl_run(f, 0);
        if (event) {
            if (!wcscmp(event, L"ESC"))
                break;
            else if (!wcscmp(event, L"^L"))
                stfl_redraw();
        }
    }

    stfl_reset();
    stfl_ipool_flush(ipool);

    stfl_free(f);
    stfl_ipool_destroy(ipool);

    return 0;
}

example.stfl

vbox
  !list[lol]
    .expand:vh
    richtext:1
    style_normal:bg=white,fg=black
    style_focus:fg=yellow,bg=blue,attr=bold

Move this to one directory and compile with <your compiler> -lstfl example.cpp

Was this page helpful?
0 / 5 - 0 ratings