Class: Ruflet::UI::Controls::RufletComponents::CodeEditorControl
- Defined in:
- lib/ruflet_ui/ruflet/ui/controls/materials/codeeditor_control.rb
Overview
CodeEditor control — parity with Flet’s CodeEditor extension (flet.dev/docs/controls/codeeditor/).
Properties: value, language, code_theme, text_style, padding, selection,
gutter_style, autocomplete, autocomplete_words, issues, read_only,
autofocus, plus the usual layout props.
Events: on_change, on_selection_change, on_focus, on_blur. Methods (invoked over the wire on a mounted control): focus, fold_at,
fold_comment_at_line_zero, fold_imports.
‘language` accepts a highlight.js identifier (e.g. “python”, “ruby”, “javascript”); `code_theme` accepts a highlight.js theme name shared with Markdown (e.g. “atom-one-light”, “atom-one-dark”, “monokai-sublime”).
Constant Summary collapse
- TYPE =
"CodeEditor".freeze
- WIRE =
"CodeEditor".freeze
Constants inherited from Control
Instance Attribute Summary
Attributes inherited from Control
#children, #id, #props, #runtime_page, #type, #wire_id
Instance Method Summary collapse
-
#focus ⇒ Object
Request focus for the editor.
-
#fold_at(line_number) ⇒ Object
Fold the code block that starts at the given line number.
-
#fold_comment_at_line_zero ⇒ Object
Fold the comment block at line 0 (e.g. a license header).
-
#fold_imports ⇒ Object
Fold all import sections.
-
#initialize(id: nil, adaptive: nil, autocomplete: nil, autocomplete_words: nil, autofocus: nil, badge: nil, code_theme: nil, col: nil, data: nil, disabled: nil, expand: nil, expand_loose: nil, gutter_style: nil, height: nil, issues: nil, key: nil, language: nil, opacity: nil, padding: nil, read_only: nil, rtl: nil, selection: nil, text_style: nil, tooltip: nil, value: nil, visible: nil, width: nil, on_blur: nil, on_change: nil, on_focus: nil, on_selection_change: nil) ⇒ CodeEditorControl
constructor
A new instance of CodeEditorControl.
Methods inherited from Control
#[], #[]=, #emit, generate_id, #has_handler?, #method_missing, #on, #respond_to_missing?, #to_patch
Constructor Details
#initialize(id: nil, adaptive: nil, autocomplete: nil, autocomplete_words: nil, autofocus: nil, badge: nil, code_theme: nil, col: nil, data: nil, disabled: nil, expand: nil, expand_loose: nil, gutter_style: nil, height: nil, issues: nil, key: nil, language: nil, opacity: nil, padding: nil, read_only: nil, rtl: nil, selection: nil, text_style: nil, tooltip: nil, value: nil, visible: nil, width: nil, on_blur: nil, on_change: nil, on_focus: nil, on_selection_change: nil) ⇒ CodeEditorControl
Returns a new instance of CodeEditorControl.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ruflet_ui/ruflet/ui/controls/materials/codeeditor_control.rb', line 24 def initialize(id: nil, adaptive: nil, autocomplete: nil, autocomplete_words: nil, autofocus: nil, badge: nil, code_theme: nil, col: nil, data: nil, disabled: nil, expand: nil, expand_loose: nil, gutter_style: nil, height: nil, issues: nil, key: nil, language: nil, opacity: nil, padding: nil, read_only: nil, rtl: nil, selection: nil, text_style: nil, tooltip: nil, value: nil, visible: nil, width: nil, on_blur: nil, on_change: nil, on_focus: nil, on_selection_change: nil) props = {} props[:adaptive] = adaptive unless adaptive.nil? props[:autocomplete] = autocomplete unless autocomplete.nil? props[:autocomplete_words] = autocomplete_words unless autocomplete_words.nil? props[:autofocus] = autofocus unless autofocus.nil? props[:badge] = badge unless badge.nil? props[:code_theme] = code_theme unless code_theme.nil? props[:col] = col unless col.nil? props[:data] = data unless data.nil? props[:disabled] = disabled unless disabled.nil? props[:expand] = unless .nil? props[:expand_loose] = unless .nil? props[:gutter_style] = gutter_style unless gutter_style.nil? props[:height] = height unless height.nil? props[:issues] = issues unless issues.nil? props[:key] = key unless key.nil? props[:language] = language unless language.nil? props[:opacity] = opacity unless opacity.nil? props[:padding] = padding unless padding.nil? props[:read_only] = read_only unless read_only.nil? props[:rtl] = rtl unless rtl.nil? props[:selection] = selection unless selection.nil? props[:text_style] = text_style unless text_style.nil? props[:tooltip] = tooltip unless tooltip.nil? props[:value] = value unless value.nil? props[:visible] = visible unless visible.nil? props[:width] = width unless width.nil? props[:on_blur] = on_blur unless on_blur.nil? props[:on_change] = on_change unless on_change.nil? props[:on_focus] = on_focus unless on_focus.nil? props[:on_selection_change] = on_selection_change unless on_selection_change.nil? super(type: TYPE, id: id, **props) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Ruflet::Control
Instance Method Details
#focus ⇒ Object
Request focus for the editor.
66 |
# File 'lib/ruflet_ui/ruflet/ui/controls/materials/codeeditor_control.rb', line 66 def focus = invoke_editor_method("focus") |
#fold_at(line_number) ⇒ Object
Fold the code block that starts at the given line number.
69 70 71 |
# File 'lib/ruflet_ui/ruflet/ui/controls/materials/codeeditor_control.rb', line 69 def fold_at(line_number) invoke_editor_method("fold_at", { "line_number" => line_number.to_i }) end |
#fold_comment_at_line_zero ⇒ Object
Fold the comment block at line 0 (e.g. a license header).
74 |
# File 'lib/ruflet_ui/ruflet/ui/controls/materials/codeeditor_control.rb', line 74 def fold_comment_at_line_zero = invoke_editor_method("fold_comment_at_line_zero") |
#fold_imports ⇒ Object
Fold all import sections.
77 |
# File 'lib/ruflet_ui/ruflet/ui/controls/materials/codeeditor_control.rb', line 77 def fold_imports = invoke_editor_method("fold_imports") |