Merge pull request #2308 from triska/small_format_improvements
Small format improvements
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Written 2020-2023 by Markus Triska (triska@metalevel.at)
|
Written 2020-2024 by Markus Triska (triska@metalevel.at)
|
||||||
Part of Scryer Prolog.
|
Part of Scryer Prolog.
|
||||||
I place this code in the public domain. Use it in any way you want.
|
I place this code in the public domain. Use it in any way you want.
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
@@ -302,14 +302,14 @@ format_number_chars(N0, Chars) :-
|
|||||||
N is N0, % evaluate compound expression
|
N is N0, % evaluate compound expression
|
||||||
number_chars(N, Chars).
|
number_chars(N, Chars).
|
||||||
|
|
||||||
n_newlines(0) --> !.
|
|
||||||
n_newlines(N0) --> { N0 > 0, N is N0 - 1 }, [newline], n_newlines(N).
|
n_newlines(N0) --> { N0 > 0, N is N0 - 1 }, [newline], n_newlines(N).
|
||||||
|
n_newlines(0) --> [].
|
||||||
|
|
||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
?- phrase(upto_what(Cs, ~), "abc~test", Rest).
|
?- phrase(format:upto_what(Cs, ~), "abc~test", Rest).
|
||||||
Cs = [a,b,c], Rest = [~,t,e,s,t].
|
Cs = "abc", Rest = "~test".
|
||||||
?- phrase(upto_what(Cs, ~), "abc", Rest).
|
?- phrase(format:upto_what(Cs, ~), "abc", Rest).
|
||||||
Cs = [a,b,c], Rest = [].
|
Cs = "abc", Rest = [].
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
separate_digits_fractional(Arg, Sep, Num, Cs) :-
|
separate_digits_fractional(Arg, Sep, Num, Cs) :-
|
||||||
@@ -444,9 +444,9 @@ format(Stream, Fs, Args) :-
|
|||||||
?- phrase(format:cells("~`at~50|", [], 0, [], []), Cs),
|
?- phrase(format:cells("~`at~50|", [], 0, [], []), Cs),
|
||||||
phrase(format:format_cells(Cs), Ls).
|
phrase(format:format_cells(Cs), Ls).
|
||||||
?- phrase(format:cells("~ta~t~tb~tc~21|", [], 0, [], []), Cs).
|
?- phrase(format:cells("~ta~t~tb~tc~21|", [], 0, [], []), Cs).
|
||||||
Cs = [cell(0,21,[glue(' ',_A),chars("a"),glue(' ',_B),glue(' ',_C),chars("b"),glue(' ',_D),chars("c ...")])]
|
Cs = [cell(0,21,[glue(' ',_A),chars("a"),glue(' ',_B),glue(' ',_C),chars("b"),glue(' ',_D),chars("c")])].
|
||||||
?- phrase(format:cells("~ta~t~4|", [], 0, [], []), Cs).
|
?- phrase(format:cells("~ta~t~4|", [], 0, [], []), Cs).
|
||||||
Cs = [cell(0,4,[glue(' ',_A),chars("a"),glue(' ',_B)])]
|
Cs = [cell(0,4,[glue(' ',_A),chars("a"),glue(' ',_B)])].
|
||||||
|
|
||||||
?- phrase(format:format_cell(cell(0,1,[glue(a,_94)])), Ls).
|
?- phrase(format:format_cell(cell(0,1,[glue(a,_94)])), Ls).
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user