Skip to content

Commit

Permalink
Disable line wrapping in StringFormatted
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisJefferson committed Feb 24, 2022
1 parent 46ed887 commit 5b258a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/string.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1387,12 +1387,15 @@ InstallGlobalFunction(PrintToFormatted, function(stream, s, data...)
end);

InstallGlobalFunction(StringFormatted, function(s, data...)
local str;
local str, stream;
if not IsString(s) then
ErrorNoReturn("Usage: StringFormatted(<string>, <data>...)");
fi;
str := "";
CallFuncList(PrintToFormatted, Concatenation([OutputTextString(str, false), s], data));
stream := OutputTextString(str, false);
SetPrintFormattingStatus(stream, false);

CallFuncList(PrintToFormatted, Concatenation([stream, s], data));
return str;
end);

Expand Down
8 changes: 8 additions & 0 deletions tst/testinstall/format.tst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ gap> StringFormatted("{a!}", rec(a := r1));
gap> StringFormatted("abc{}def",[1,2]) = "abc[ 1, 2 ]def";
true

# Test long output
gap> ListWithIdenticalEntries(1000, 'a') =
> StringFormatted("{}", ListWithIdenticalEntries(1000, 'a'));
true
gap> ListWithIdenticalEntries(1000, 'a') =
> StringFormatted("{}{}", ListWithIdenticalEntries(500, 'a'), ListWithIdenticalEntries(500, 'a'));
true

# Test alternative functions
gap> PrintFormatted();
Error, Usage: PrintFormatted(<string>, <data>...)
Expand Down

0 comments on commit 5b258a0

Please sign in to comment.