As noted in the CODE documentation <http://web2py.com/books/default/chapter/29/05/the-views#CODE>, you can pass in a styles dictionary to override the default styles controlling the display of the code. To see the keys of that dictionary that can be used to override various styles, see the source code at https://github.com/web2py/web2py/blob/master/gluon/highlight.py#L192 and https://github.com/web2py/web2py/blob/master/gluon/highlight.py#L284.
In particular, the default styles for the "CODE" key (which get applied to each pre element) are: ''' font-size: 11px; font-family: Bitstream Vera Sans Mono,monospace; background-color: transparent; margin: 0; padding: 5px; border: none; overflow: auto; white-space: pre !important; ''' Notice that white-space is set to pre, which only wraps at newlines and <br> elements. You can override that by supplying a custom set of "CODE" styles: code_styles = ''' font-size: 11px; font-family: Bitstream Vera Sans Mono,monospace; background-color: transparent; margin: 0; padding: 5px; border: none; overflow: auto; white-space: pre-wrap; ''' code = CODE(my_code, styles=dict(CODE=code)) The above sets white-space to pre-wrap, which will allow wrapping (though note that it will not preserve indentation on the wrapped lines, so may not look great). To add scrollbars, you can simply set the overflow CSS property on the container element: div = DIV(CODE(my_code), _style="width:50%; overflow: scroll") Given the above, if the table created by CODE exceeds the width of the containing div, a horizontal scrollbar will be added. Of course, the above can also be achieved via CSS rules in a stylesheet. Anthony On Sunday, September 19, 2021 at 7:32:39 AM UTC-4 lucas wrote: > hello one and all, > > using the CODE() html helper, how can we get either a scrollbar enabled > when the code window doesn't fit in its container, OR, word-wrap enabled to > soft linefeed long lines of code? i see that it outputs a table of the > scripted code but are there setting to facilitate the latter two > possibilities? > > thank you in advance, lucas > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/098611c4-5e19-435c-8e7f-bbdcde43c241n%40googlegroups.com.