reqable / re-editor

Re-Editor is a powerful lightweight text and code editor widget.
https://pub.dev/packages/re_editor
MIT License
527 stars 51 forks source link

Custom Line Numbers to show Assmble Address #48

Open svr2kos2 opened 4 weeks ago

svr2kos2 commented 4 weeks ago

Is your feature request related to a problem? Please describe. No

Describe the solution you'd like I want to use line numbers to show assmble address witch it's not simply 1,2,3,4,5......

Describe alternatives you've considered I'm currently inheriting CodeLineNumberRenderObject and override paint method to do this.

class AsmCodeLineNumberRenderObject extends CodeLineNumberRenderObject {
//.....
@override
  void paint(PaintingContext context, Offset offset) {
//....
    for (final CodeLineRenderParagraph paragraph in value.paragraphs) {
      //convert line number to address
      final addr =  _lineIndex2AsmAddr[firstLineIndex] ?? -1;
      _textPainter.text = TextSpan(
        text: '0x${addr.toRadixString(16).toUpperCase().padLeft(4, '0')}',
        style: paragraph.index == value.focusedIndex ? _focusedTextStyle : _textStyle
      );
      _textPainter.layout();
      _textPainter.paint(canvas, Offset(offset.dx + size.width - _textPainter.width, offset.dy + paragraph.offset.dy));
      firstLineIndex += _controller.codeLines[paragraph.index].lineCount;
    }
//....
  }
}

If we can add a callback as a parameter to CodeLineNumberRenderObject, this feature can be easily achieved. I can create a PR if you accept this idea.

Additional context image

MegatronKing commented 4 weeks ago

Welcome!