我的程序会输出大量信息。为了更好的可读性,一种方法是通过添加不同数量的选项卡将它们组织在不同的级别。例如,可以通过在打印之前始终打印多个标签来实现以下布局,并且可以通过全局参考变量来控制标签的数量。
level_1_begin
... ...
level_2_begin
... ...
level_3_begin
... ...
level_3_end
level_2_end
... ...
level_2_begin
level_2_end
... ...
level_1_end
然而,这种方式存在一个问题:当文本很长并且必须转到另一行时(由于窗口的宽度),它将忽略选项卡并从最左边开始。例如,
level_1_begin
... ...
level_2_begin
a very very very very very very very very very very
very very very very long line
... ...
level_2_end
相反,我希望显示如下:
level_1_begin
... ...
level_2_begin
a very very very very very very very very very very
very very very very long line
... ...
level_2_end
有人知道OCaml是否有任何解决方案可以实现这一目标?