AdaCore / AdaCore/gnatcoll-core

Surplus output in function 'Screen.Clear_To_End_Of_Line' ?

Open
#78 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ada
Stars
55
Forks
36
PR merge metrics
No merged PRs in 30d

Description

Hi

UPDATED: the output described below only appears (so far) on the GNAT Studio messages window when using Build and run. The extra part described is not showing up in Gnome Terminal for example when the binary is run there using zsh.

In my Ada program I am calling the follow code:

--  prior code excluded
   --  initialise screen outputs wanted for colour support
   Screen.Init_For_Stdout (Auto);
   Screen.Init_For_Stderr (Auto);
   --  show colour output capabilities in debug mode
   pragma Debug (Put_Line (Standard_Error, "[DEBUG] Checking for colour terminal support..."));
   pragma Debug (Put_Line (Standard_Error, "[DEBUG] Colour support: " & (if Screen.Has_Colors then "YES" else "NO")));
   pragma Debug
     (Put_Line (Standard_Error, "[DEBUG] ANSI support: " & (if Screen.Has_ANSI_Colors then "YES" else "NO")));
   Screen.Clear_To_End_Of_Line;
--  following code excluded

This creates the output as follows:

[DEBUG] Checking for colour terminal support...
[DEBUG] Colour support: YES
[DEBUG] ANSI support: YES.
[DEBUG] build <remaining output deleted here>

The output includes some unexpected extra text: .

NB: The output after the extra unexpected text:  (ie the [DEBUG] build <remaining output deleted here> part) is expected - it is from a later part of the program.

This extra element is being inserted by the call to Screen.Clear_To_End_Of_Line;.

Looking in the gnatcoll-core source at the function gnatcoll_clear_to_end_of_line in terminal.c line 112 the source of this extra output can be found at line 112:

if (write(forStderr ? 2 : 1, "\033[0K", 4) != 4) {

Is this supposed to be there, and is the output intended in that way?

The program is being built and run on Fedora Linux 38 (x86_64), and the full source code that is calling this function can be found here if usefule: password_manager.adb around line 242

Thanks for your help.

Simon

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/terminals.c at gnatcoll_clear_to_end_of_line, especially line 112, and compare it with the call around line 242 of password_manager.adb. Reproduce the output through GNAT Studio's Build and run and through Gnome Terminal using zsh. Done means determining whether the ANSI sequence is intended and, if not, defining the corrected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
zsh
Domain
cli, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.