Current Terminal Screen:
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
>
>             # EL+rewrite: CR + \n*dr + ESC[2K + row
>             cost_erase = 1 + abs(r - (cursor_r - 1)) + 4 + w
>
>             # Run-based: CR + \n*dr + sum(CUF + run_len)
>             cost_runs = 1 + abs(r - (cursor_r - 1))
>             for start, end in runs:
>                 cost_runs += 4 + len(str(start)) + (end-start+1)
>
>             if cost_erase < cost_runs:
>                 out.append('\r')
>                 dr = r - (cursor_r - 1)
>                 if dr > 0:
>                     out.append('\n' * dr)
>                 else:
>                     out.append(f'\x1b[{-dr}A')
>                 out.append('\x1b[2K')
>                 out.append(curr_row.decode('latin1'))
>                 cursor_r, cursor_c = r+1, w+1
>             else:
>                 out.append('\r')
>                 dr = r - (cursor_r - 1)
>                 if dr > 0:
>                     out.append('\n' * dr)
>                 else:
>                     out.append(f'\x1b[{-dr}A')
>                 for start, end in runs:
>                     if start > 0:
>                         out.append(f'\x1b[{start}C')
>                     out.append(curr_row[start:end+1].decode('latin1'))
>                 cursor_r, cursor_c = r+1, w+1
>
>         out.append('\x1e')
>
>     sys.stdout.write(''.join(out))
>
> if __name__ == '__main__':
>     main()
> EOF
root@f3f8d6319494:/app#
