-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
possible issue with Notty.I.strf #19
Comments
Interesting... what happens if you run that in the toplevel? |
|
So there is a warning after all? Exciting! What could it mean? |
are you sarcastic ? does this issue bother you or the way I writted it (did you find me rude, if so I sincerly apologize)? It meens that this kind of character is not accepted by |
This is because So every function that creates them from raw string or character material has to throw that exception. I updated the docs to mention the same thing for If you are trying to simply pad on the left, you can use (* maxby : ('a -> int) -> 'a list -> int *)
let maxby f xs = List.(fold_left max 0 (map f xs))
(* column : align:[`Left|`Middle|`Right] -> image list -> image *)
let column ~align images =
let width = maxby I.width images in
List.map (I.hsnap ~align width) images |> I.vcat Assuming you have (* render_title : string -> image *)
let render_title = I.string A.(fg lightred ++ bg lightblack)
(* render_artist : string -> image *)
let render_artist = I.string A.(fg lightgreen ++ bg lightblack)
let (titles, artists) = List.split songs
let output =
(List.map render_title titles |> column ~align:`Right)
<|> (List.map render_artist artists |> column ~align:`Left) Finally, you can add a column separator in various ways. |
Oh, ok, now I do understand why you reacted that way, I was so focused on again I sincerly apologize for bothering you with this, and thanks you for taking the time to help me. |
Heh, no need to apologize. Especially not sincerely. 😃 Here is a way to see the problem: # print_string "\t]\n"; print_string "[\t]\n";;
]
[ ]
- : unit = () so if you remove the checks you get # let i1, i2 = I.(string A.empty "[", string A.empty "\t]") ;;
val i1 : Notty.image = <abstr>
val i2 : Notty.image = <abstr>
# Notty_unix.(output_image (i2 <-> (i1 <|> i2) |> eol)) ;;
]
[ ]
- : unit = () so you can see that It turns out the width is context-dependent, in the sense that the space Every single control character will cause similar breakdown. Notty's nice API is just incompatible with allowing them in the output. Some of them, like |
I wanted to add tab space in a string image like with
Format.astring
with :but it makes my program stop without any warnings, when I remove the "\t" part, everything is fine.
If I add a backslash to try to escape,
my program does not crash but it displays something like:
"\ta_title : an artist" which is not the same behavior that
Format.astring
as it is said in the documentationRegards.
The text was updated successfully, but these errors were encountered: