* text_io and grid printing
@ 2018-05-17 14:51 Mehdi Saada
2018-05-17 15:01 ` Mehdi Saada
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Mehdi Saada @ 2018-05-17 14:51 UTC (permalink / raw)
I wanted to use set_col and set_line to print things as in a grid, (to print a matrix) but it seems I was wrong ?
Set_Col (1); Put ("1"); Set_Col (2); Put ("2"); Set_Col (3); Put ("3");
Gives "123"
but Set_Col (2); Put ("2"); Set_Col (1); Put ("1"); Set_Col (3); Put ("3");
gives
2
1 3
Is there something with linux' implementation ? How do you use to print things like a grid in a portable ? Are you forced to use some complicated curse-like library for that ?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: text_io and grid printing
2018-05-17 14:51 text_io and grid printing Mehdi Saada
@ 2018-05-17 15:01 ` Mehdi Saada
2018-05-17 15:20 ` J-P. Rosen
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Mehdi Saada @ 2018-05-17 15:01 UTC (permalink / raw)
To be precise, it can't go back on a line once it went lower through new_line or set_line.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: text_io and grid printing
2018-05-17 14:51 text_io and grid printing Mehdi Saada
2018-05-17 15:01 ` Mehdi Saada
@ 2018-05-17 15:20 ` J-P. Rosen
2018-05-17 15:55 ` Dmitry A. Kazakov
` (2 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: J-P. Rosen @ 2018-05-17 15:20 UTC (permalink / raw)
Le 17/05/2018 à 16:51, Mehdi Saada a écrit :
> I wanted to use set_col and set_line to print things as in a grid, (to print a matrix) but it seems I was wrong ?
> Set_Col (1); Put ("1"); Set_Col (2); Put ("2"); Set_Col (3); Put ("3");
> Gives "123"
> but Set_Col (2); Put ("2"); Set_Col (1); Put ("1"); Set_Col (3); Put ("3");
> gives
> 2
> 1 3
>
> Is there something with linux' implementation ?
No, that's the way it is. Text_IO is for simple text files or consoles,
you cannot move back.
> How do you use to print things like a grid in a portable ? Are you>
> forced to use some complicated curse-like library for that ?For more sophisticated IOs, look at "Ada sur le Web" (in French) under
the heading "Terminaux, graphiques, fenêtrages":
http://www.adalog.fr/fr/adaweb.html#compo
--
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: text_io and grid printing
2018-05-17 14:51 text_io and grid printing Mehdi Saada
2018-05-17 15:01 ` Mehdi Saada
2018-05-17 15:20 ` J-P. Rosen
@ 2018-05-17 15:55 ` Dmitry A. Kazakov
2018-05-17 16:14 ` Mehdi Saada
2018-05-17 16:43 ` Jeffrey R. Carter
4 siblings, 0 replies; 10+ messages in thread
From: Dmitry A. Kazakov @ 2018-05-17 15:55 UTC (permalink / raw)
On 2018-05-17 16:51, Mehdi Saada wrote:
> I wanted to use set_col and set_line to print things as in a grid, (to print a matrix) but it seems I was wrong ?
> Set_Col (1); Put ("1"); Set_Col (2); Put ("2"); Set_Col (3); Put ("3");
> Gives "123"
> but Set_Col (2); Put ("2"); Set_Col (1); Put ("1"); Set_Col (3); Put ("3");
> gives
> 2
> 1 3
>
> Is there something with linux' implementation ? How do you use to print things like a grid in a portable ? Are you forced to use some complicated curse-like library for that ?
No. You need string formatting. Try this:
------------------------------------------------
with Ada.Text_IO; use Ada.Text_IO;
with Strings_Edit; use Strings_Edit;
with Strings_Edit.Integers; use Strings_Edit.Integers;
procedure Test is
Line : String (1..80);
Pointer : Integer;
begin
Pointer := Line'First;
Put (Destination => Line, Pointer => Pointer, Value => 1, Field =>
8, Justify => Right);
Put (Destination => Line, Pointer => Pointer, Value => 2, Field =>
8, Justify => Right);
Put (Destination => Line, Pointer => Pointer, Value => 3, Field =>
8, Justify => Right);
Put_Line (Line (Line'First..Pointer - 1));
Pointer := Line'First;
Put (Destination => Line, Pointer => Pointer, Value => 4, Field =>
8, Justify => Right);
Put (Destination => Line, Pointer => Pointer, Value => 5, Field =>
8, Justify => Right);
Put (Destination => Line, Pointer => Pointer, Value => 6, Field =>
8, Justify => Right);
Put_Line (Line (Line'First..Pointer - 1));
end Test;
---------------------------------------------------
This prints:
1 2 3
4 5 6
Of course you can place fields in any order by setting Pointer to the
beginning of the field.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: text_io and grid printing
2018-05-17 14:51 text_io and grid printing Mehdi Saada
` (2 preceding siblings ...)
2018-05-17 15:55 ` Dmitry A. Kazakov
@ 2018-05-17 16:14 ` Mehdi Saada
2018-05-17 16:24 ` Dmitry A. Kazakov
2018-05-17 16:43 ` Jeffrey R. Carter
4 siblings, 1 reply; 10+ messages in thread
From: Mehdi Saada @ 2018-05-17 16:14 UTC (permalink / raw)
Indeed your package is easy to use, but it can't be better than treating the command line as a grid, so as to output any incoming arbitrary data in its right position in a natural way.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: text_io and grid printing
2018-05-17 16:14 ` Mehdi Saada
@ 2018-05-17 16:24 ` Dmitry A. Kazakov
2018-05-17 17:24 ` Mehdi Saada
0 siblings, 1 reply; 10+ messages in thread
From: Dmitry A. Kazakov @ 2018-05-17 16:24 UTC (permalink / raw)
On 2018-05-17 18:14, Mehdi Saada wrote:
> Indeed your package is easy to use, but it can't be better than treating the command line as a grid, so as to output any incoming arbitrary data in its right position in a natural way.
This is exactly what it does:
--------------------------------
with Ada.Text_IO; use Ada.Text_IO;
with Strings_Edit; use Strings_Edit;
with Strings_Edit.Integers; use Strings_Edit.Integers;
procedure Test is
Line : String (1..80);
Pointer : Integer;
begin
Pointer := 9;
Put (Destination => Line, Pointer => Pointer, Value => 1, Field =>
8, Justify => Right);
Pointer := 17;
Put (Destination => Line, Pointer => Pointer, Value => 2, Field =>
8, Justify => Right);
Pointer := 1;
Put (Destination => Line, Pointer => Pointer, Value => 3, Field =>
8, Justify => Right);
Put_Line (Line (1..24));
end Test;
------------------------------------
This prints:
3 1 2
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: text_io and grid printing
2018-05-17 14:51 text_io and grid printing Mehdi Saada
` (3 preceding siblings ...)
2018-05-17 16:14 ` Mehdi Saada
@ 2018-05-17 16:43 ` Jeffrey R. Carter
2018-05-17 18:57 ` Niklas Holsti
4 siblings, 1 reply; 10+ messages in thread
From: Jeffrey R. Carter @ 2018-05-17 16:43 UTC (permalink / raw)
On 05/17/2018 04:51 PM, Mehdi Saada wrote:
> I wanted to use set_col and set_line to print things as in a grid, (to print a matrix) but it seems I was wrong ?
> Set_Col (1); Put ("1"); Set_Col (2); Put ("2"); Set_Col (3); Put ("3");
> Gives "123"
> but Set_Col (2); Put ("2"); Set_Col (1); Put ("1"); Set_Col (3); Put ("3");
> gives
> 2
> 1 3
It's probably best to forget that Text_IO has those operations.
--
Jeff Carter
"He didn't get that nose from playing ping-pong."
Never Give a Sucker an Even Break
110
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: text_io and grid printing
2018-05-17 16:24 ` Dmitry A. Kazakov
@ 2018-05-17 17:24 ` Mehdi Saada
2018-05-17 18:22 ` Dmitry A. Kazakov
0 siblings, 1 reply; 10+ messages in thread
From: Mehdi Saada @ 2018-05-17 17:24 UTC (permalink / raw)
Sorry, of course it does on a same LINE. I meant it can't go upper in the screen...
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: text_io and grid printing
2018-05-17 17:24 ` Mehdi Saada
@ 2018-05-17 18:22 ` Dmitry A. Kazakov
0 siblings, 0 replies; 10+ messages in thread
From: Dmitry A. Kazakov @ 2018-05-17 18:22 UTC (permalink / raw)
On 2018-05-17 19:24, Mehdi Saada wrote:
> Sorry, of course it does on a same LINE. I meant it can't go upper in the screen...
Easily:
Screen : array (1..24) of String (1..80);
Remember it is either plain text I/O or else not. Plain text ends with
fixed space ASCII, maybe, some subset of Unicode. Anything beyond that
is not not text, but a text buffer, document, surface for rendering,
cell renderer etc. The problem you describe simply is non-existent.
There is no such thing as column, but some coordinate system, or
iterator/cursor, or markup etc.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: text_io and grid printing
2018-05-17 16:43 ` Jeffrey R. Carter
@ 2018-05-17 18:57 ` Niklas Holsti
0 siblings, 0 replies; 10+ messages in thread
From: Niklas Holsti @ 2018-05-17 18:57 UTC (permalink / raw)
On 18-05-17 19:43 , Jeffrey R. Carter wrote:
> On 05/17/2018 04:51 PM, Mehdi Saada wrote:
>> I wanted to use set_col and set_line to print things as in a grid, (to
>> print a matrix) but it seems I was wrong ?
>> Set_Col (1); Put ("1"); Set_Col (2); Put ("2"); Set_Col (3); Put ("3");
>> Gives "123"
>> but Set_Col (2); Put ("2"); Set_Col (1); Put ("1"); Set_Col (3); Put
>> ("3");
>> gives
>> 2
>> 1 3
>
> It's probably best to forget that Text_IO has those operations.
I find Set_Col convenient for simple tabular output, even if it has to
be used in increasing column order. But very weak compared to eg. HTML
tables, of course. I don't remember ever using Set_Line.
HTML output is a good compromise, IMO. I often use the XML EZ_Out
package from www.mckae.com. But it, too, requires the program to
generate table cells in left-to-right, top-down order.
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-05-17 18:57 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-17 14:51 text_io and grid printing Mehdi Saada
2018-05-17 15:01 ` Mehdi Saada
2018-05-17 15:20 ` J-P. Rosen
2018-05-17 15:55 ` Dmitry A. Kazakov
2018-05-17 16:14 ` Mehdi Saada
2018-05-17 16:24 ` Dmitry A. Kazakov
2018-05-17 17:24 ` Mehdi Saada
2018-05-17 18:22 ` Dmitry A. Kazakov
2018-05-17 16:43 ` Jeffrey R. Carter
2018-05-17 18:57 ` Niklas Holsti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox