Git Product home page Git Product logo

rich_code_editor's Introduction

rich_code_editor

A simple package that supports creating code editors in Flutter.

Flutter version supported: Flutter 1.22.5

Getting Started

There are two main components of the rich code editor:

  1. Editor
  2. Syntax Highlighter

The editor is a text area which is identical to Flutter's TextField widget. However, unlike a regular TextField the editor uses an instance of syntax highlighter object to parse and highlight code syntax.

Since the editor itself is independent of the syntax highlighting rules, the same editor can be used for any other programming langugages. Only the syntax highlighter implementation needs to be created separately for each new programming language.

The example demo uses a dummy syntax highlighter implementation DummySyntaxHighlighter.

Get Started by creating your own implementation for SyntaxHighlighterBase class.

The syntax highlight logic part is not much implemented in this package as that will change as per the choice of programming language.

rich_code_editor's People

Contributors

bit-burger avatar psovit avatar redsolver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rich_code_editor's Issues

(Flutter beta) NoSuchMethodError: The getter 'hasFloatingPlaceholder was called on null.

I/flutter (30091): Receiver: null
I/flutter (30091): Tried calling: hasFloatingPlaceholder
I/flutter (30091): 
I/flutter (30091): User-created ancestor of the error-causing widget was:
I/flutter (30091):   CodeTextField
I/flutter (30091): 
I/flutter (30091): When the exception was thrown, this was the stack:
I/flutter (30091): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5)
I/flutter (30091): #1      _InputDecoratorState.initState (package:flutter/src/material/input_decorator.dart:1851:33)
I/flutter (30091): #2      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4060:58)
I/flutter (30091): #3      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3911:5)
I/flutter (30091): #4      Element.inflateWidget (package:flutter/src/widgets/framework.dart:3093:14)
I/flutter (30091): #5      Element.updateChild (package:flutter/src/widgets/framework.dart:2896:12)
...

Flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v1.8.3, on Microsoft Windows [Version 10.0.18362.295], locale en-GB)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
[√] Android Studio (version 3.4)
[√] Android Studio (version 3.5)
[!] IntelliJ IDEA Ultimate Edition (version 2019.1)
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
[√] Connected device (1 available)

! Doctor found issues in 1 category.

The getter 'kMinInteractiveSize' isn't defined for the class 'CodeEditableTextState

Compiler message:
../../../../soft/flutter/.pub-cache/hosted/pub.dartlang.org/rich_code_editor-0.2.8/lib/code_editor/widgets/code_editable_text.dart:1388:11: Error: Getter not found: 'kMinInteractiveSize'.
          kMinInteractiveSize,
          ^^^^^^^^^^^^^^^^^^^
../../../../soft/flutter/.pub-cache/hosted/pub.dartlang.org/rich_code_editor-0.2.8/lib/code_editor/widgets/code_editable_text.dart:1388:11: Error: The getter 'kMinInteractiveSize' isn't defined for the class 'CodeEditableTextState'.
 - 'CodeEditableTextState' is from 'package:rich_code_editor/code_editor/widgets/code_editable_text.dart' ('../../../../soft/flutter/.pub-cache/hosted/pub.dartlang.org/rich_code_editor-0.2.8/lib/code_editor/widgets/code_editable_text.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'kMinInteractiveSize'.
          kMinInteractiveSize,
          ^^^^^^^^^^^^^^^^^^^

RenderEditable.obscuringCharacter

/C:/package/flutter/.pub-cache/hosted/pub.dartlang.org/rich_code_editor-1.0.0/lib/rich_code_controller.dart:6:7: Error: The non-abstract class 'RichCodeEditingController' is missing implementations for these members:

  • TextEditingController.isSelectionWithinTextBounds
    Try to either
  • provide an implementation,
  • inherit an implementation from a superclass or mixin,
  • mark the class as abstract, or
  • provide a 'noSuchMethod' implementation.

class RichCodeEditingController extends ValueNotifier implements TextEditingController {
^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/package/flutter/packages/flutter/lib/src/widgets/editable_text.dart:229:8: Context: 'TextEditingController.isSelectionWithinTextBounds' is defined here.

bool isSelectionWithinTextBounds(TextSelection selection) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/package/flutter/.pub-cache/hosted/pub.dartlang.org/rich_code_editor-1.0.0/lib/rich_editable_code.dart:1617:34: Error: Too few positional arguments: 2 required, 1 given.
? () => controls.handleCopy(this)
^
/C:/package/flutter/.pub-cache/hosted/pub.dartlang.org/rich_code_editor-1.0.0/lib/rich_editable_code.dart:1705:29: Error: Getter not found: 'obscuringCharacter'.
text = RenderEditable.obscuringCharacter * text.length;
^^^^^^^^^^^^^^^^^^
2

FAILURE: Build failed with an exception.

Text manipulation gestures (e.g. double tap, tap & hold) do not seem to work on Android.

Hello

I have noticed that text manipulation gestures do not seem to work on Android.
For example, double tapping a word on the default material TextField highlights that word.
On a CodeTextField, the cursor just moves to the beginning of the word without highlighting it.
Similarly, tapping and holding a word does nothing but move the cursor to the beginning.

Also, this may be Android related only, but on some keyboards there are text gestures such as:
Sliding across the spacebar to move the cursor and dragging the backspace to the left to delete multiple words.
The functionality works (sliding the the spacebar does move the cursor's underlying position, and sliding the backspace does delete multiple words) however there's no visual feedback.

Sliding backspace should highlight words-to-be-deleted before it deletes them, and sliding across the spacebar should move the blinking cursor as its position is being changed.

I was using my own Highlighter, but tested with the provided DummyHighlighter and the behaviour is still missing. Any thoughts?

Thanks for the great work by the way!

rich_code_editor version: 0.2.9
flutter version: 1.7.8+hotfix 3
device: Pixel 2XL running Android 10 (QP1A. 191105)

flutter doctor -v:

PS C:\Development\Flutter\project> flutter doctor -v
[√] Flutter (Channel stable, v1.7.8+hotfix.3, on Microsoft Windows [Version 10.0.18362.476], locale en-GB)
    • Flutter version 1.7.8+hotfix.3 at C:\sdk\flutter
    • Framework revision b712a172f9 (5 months ago), 2019-07-09 13:14:38 -0700
    • Engine revision 54ad777fd2
    • Dart version 2.4.0


[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:\Program Files (x86)\Android\android-sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: c:\programdata\Oracle\Java\javapath\java.exe
    • Java version Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).

[√] VS Code (version 1.40.1)
    • VS Code at C:\Users\Faris\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.6.0

[√] Connected device (1 available)
    • Pixel 2 XL • 711KPPB0677296 • android-arm64 • Android 10 (API 29)

! Doctor found issues in 2 categories.

Edit

So I dug a bit into the code and found that the library has its own implementation of TextSelectionControls, and nothing but Paste is supported, how come? What's the reason behind this?

Editing huge chunk of code makes editor slow

While editing a huge chunk of code, the editor becomes quite slow, probably due to the fact that on every keyPress/change, the syntax highlighting is recalculated for the whole text.

Implementation missing for the class RichCodeEditingController.

Error: The non-abstract class 'RichCodeEditingController' is missing implementations for these members:
 - TextEditingController.isSelectionWithinTextBounds
Try to either
 - provide an implementation,
 - inherit an implementation from a superclass or mixin,
 - mark the class as abstract, or
 - provide a 'noSuchMethod' implementation.

class RichCodeEditingController extends ValueNotifier<TextEditingValue> implements TextEditingController {
      ^^^^^^^^^^^^^^^^^^^^^^^^^
/D:/flutter/packages/flutter/lib/src/widgets/editable_text.dart:225:8: Context: 'TextEditingController.isSelectionWithinTextBounds' is defined `here.`
  bool isSelectionWithinTextBounds(TextSelection selection) {
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^``

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.