theZiz / aha

Ansi HTML Adapter
Other
907 stars 88 forks source link

need help explaining htop fix #100

Open joe42 opened 1 year ago

joe42 commented 1 year ago

Hi, Could you help me understand how the htop fix works? I don't quite get the code. I can't install aha on a server, but need to parse htop output and the only part I am still missing is how to replace the "newlines" in the output. I would love to have an example akin to `echo "weird htop newline"|sed command to replace with \n``

if (opts.htop_fix) //a little dirty ...
{
    elem=parseInsert(buffer);
    pelem second=elem->next;
    if (second==NULL)
        second=elem;
    newline=second->digit[0]-1;
    if (second->digitcount>1)
        newline=(newline+1)*10+second->digit[1]-1;
    if (second->digitcount>2)
        newline=(newline+1)*10+second->digit[2]-1;
    deleteParse(elem);
    if (newline<line)
        opts.line_break=1;
}