[erlang-questions] fixed 80 columns in io:format
Ulf Wiger
ulf.wiger@REDACTED
Wed Jun 2 20:10:56 CEST 2010
Max Lapshin wrote:
> I've found several places in otp:
>
> http://github.com/erlang/otp/blob/dev/lib/stdlib/src/io_lib.erl#L166
> http://github.com/erlang/otp/blob/dev/lib/stdlib/src/io_lib_pretty.erl#L37
>
> Am I right, thinking that these places hardcode width of terminal and
> insert newline, where it is not required for me?
No, those places set common defaults for cases when
nothing else has been specified. The shell asks the
group server for the column width, which in its turn
asks the tty driver (tty_drv).
However, if you want the shell to make use of a wider tty,
the culprit is this:
http://github.com/erlang/otp/blob/dev/lib/stdlib/src/shell.erl#L1424
pp(V, I, RT) ->
io_lib_pretty:print(V, I, columns(), ?LINEMAX, ?CHAR_MAX,
record_print_fun(RT)).
The ?CHAR_MAX macro expands to 60, which sets the actual
limit for the column depth. If this were -1 instead, the
pretty printer would make use of the full width of the window.
Someone wiser than I will have to explain why CHAR_MAX is
hard-coded to 60, and not (if hard-coded at all) -1.
BR,
Ulf W
--
Ulf Wiger
CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd
http://www.erlang-solutions.com
---------------------------------------------------
---------------------------------------------------
WE'VE CHANGED NAMES!
Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.
www.erlang-solutions.com
More information about the erlang-questions
mailing list