akvelon / flutter-code-editor

Flutter Code Editor is a multi-platform code editor supporting syntax highlighting, code blocks folding, autocompletion, read-only code blocks, hiding specific code blocks, themes, and more.
https://akvelon.com
Apache License 2.0
197 stars 47 forks source link

Please support word wrap #221

Open sma opened 1 year ago

sma commented 1 year ago

Please support your CodeField.wrap property which currently seems to do nothing. This is the only feature I really need from an editor so it is rather unfortunate that after I struggles through all other issues I reported before, this should be the reason why I can't use it after all. It would also important for me that the wrap keeps the indentation. I think, the normal Flutter TextField does not.

The challenge with word wrapping is probably keeping the gutter in sync which then needs to have different heights per line and the naive approach to layout each line twice might be too slow, I don't know. As you use a TextField as a core, you probably cannot access the internal layout of its text rendering.

sma commented 1 year ago

I noticed this issue (https://github.com/BertrandBev/code_field/issues/6), which has been open since 2021, which means that text wrapping support has been missing for two years now, and because someone wants to restructure something somewhere in the Flutter framework (https://github.com/flutter/flutter/pull/119430), I don't think we'll get a way to access line metrics and get a solution in the next few months.

alexeyinkin commented 1 year ago

A potential workaround for the Flutter issue is to:

  1. Iterate lines.
  2. For each line find its y the same way we calculate the suggestion box offset.
  3. Draw line numbers at those ys.

It feels slow but should work for someone who really needs this.

This is not a top priority to us but if you make a PR we would be happy to review it.