TextEdit

Inherits: Control < CanvasItem < Node < Object

Control de edición de texto multilínea.

Descripción

TextEdit is meant for editing large, multiline text. It also has facilities for editing code, such as syntax highlighting support and multiple levels of undo/redo.

Note: When holding down Alt, the vertical scroll wheel will scroll 5 times as fast as it would normally do. This also works in the Godot script editor.

Propiedades

bool

bookmark_gutter

false

bool

breakpoint_gutter

false

bool

caret_blink

false

float

caret_blink_speed

0.65

bool

caret_block_mode

false

bool

caret_moving_by_right_click

true

bool

context_menu_enabled

true

bool

draw_spaces

false

bool

draw_tabs

false

FocusMode

focus_mode

2 (overrides Control)

bool

fold_gutter

false

bool

hiding_enabled

false

bool

highlight_all_occurrences

false

bool

highlight_current_line

false

bool

minimap_draw

false

int

minimap_width

80

CursorShape

mouse_default_cursor_shape

1 (overrides Control)

bool

override_selected_font_color

false

bool

readonly

false

int

scroll_horizontal

0

float

scroll_vertical

0.0

bool

selecting_enabled

true

bool

shortcut_keys_enabled

true

bool

show_line_numbers

false

bool

smooth_scrolling

false

bool

syntax_highlighting

false

String

text

""

float

v_scroll_speed

80.0

bool

virtual_keyboard_enabled

true

bool

wrap_enabled

false

Métodos

void

add_color_region ( String begin_key, String end_key, Color color, bool line_only=false )

void

add_keyword_color ( String keyword, Color color )

bool

can_fold ( int line ) const

void

center_viewport_to_cursor ( )

void

clear_colors ( )

void

clear_undo_history ( )

void

copy ( )

int

cursor_get_column ( ) const

int

cursor_get_line ( ) const

void

cursor_set_column ( int column, bool adjust_viewport=true )

void

cursor_set_line ( int line, bool adjust_viewport=true, bool can_be_hidden=true, int wrap_index=0 )

void

cut ( )

void

deselect ( )

void

fold_all_lines ( )

void

fold_line ( int line )

Array

get_breakpoints ( ) const

Color

get_keyword_color ( String keyword ) const

String

get_line ( int line ) const

Vector2

get_line_column_at_pos ( Vector2 position ) const

int

get_line_count ( ) const

int

get_line_height ( ) const

int

get_line_width ( int line, int wrap_index=-1 ) const

int

get_line_wrap_count ( int line ) const

PoolStringArray

get_line_wrapped_text ( int line ) const

PopupMenu

get_menu ( ) const

Vector2

get_pos_at_line_column ( int line, int column ) const

Rect2

get_rect_at_line_column ( int line, int column ) const

int

get_selection_from_column ( ) const

int

get_selection_from_line ( ) const

String

get_selection_text ( ) const

int

get_selection_to_column ( ) const

int

get_selection_to_line ( ) const

int

get_total_gutter_width ( ) const

String

get_word_under_cursor ( ) const

bool

has_keyword_color ( String keyword ) const

bool

has_redo ( ) const

bool

has_undo ( ) const

void

insert_text_at_cursor ( String text )

bool

is_folded ( int line ) const

bool

is_line_hidden ( int line ) const

bool

is_line_set_as_bookmark ( int line ) const

bool

is_line_set_as_breakpoint ( int line ) const

bool

is_line_set_as_safe ( int line ) const

bool

is_line_wrapped ( int line ) const

bool

is_selection_active ( ) const

void

menu_option ( int option )

void

paste ( )

void

redo ( )

void

remove_breakpoints ( )

PoolIntArray

search ( String key, int flags, int from_line, int from_column ) const

void

select ( int from_line, int from_column, int to_line, int to_column )

void

select_all ( )

void

set_line ( int line, String new_text )

void

set_line_as_bookmark ( int line, bool bookmark )

void

set_line_as_breakpoint ( int line, bool breakpoint )

void

set_line_as_hidden ( int line, bool enable )

void

set_line_as_safe ( int line, bool safe )

void

toggle_fold_line ( int line )

void

undo ( )

void

unfold_line ( int line )

void

unhide_all_lines ( )

Propiedades del Theme

Color

background_color

Color( 0, 0, 0, 0 )

Color

bookmark_color

Color( 0.08, 0.49, 0.98, 1 )

Color

brace_mismatch_color

Color( 1, 0.2, 0.2, 1 )

Color

breakpoint_color

Color( 0.8, 0.8, 0.4, 0.2 )

Color

caret_background_color

Color( 0, 0, 0, 1 )

Color

caret_color

Color( 0.88, 0.88, 0.88, 1 )

Color

code_folding_color

Color( 0.8, 0.8, 0.8, 0.8 )

Color

completion_background_color

Color( 0.17, 0.16, 0.2, 1 )

Color

completion_existing_color

Color( 0.87, 0.87, 0.87, 0.13 )

Color

completion_font_color

Color( 0.67, 0.67, 0.67, 1 )

Color

completion_scroll_color

Color( 1, 1, 1, 1 )

Color

completion_selected_color

Color( 0.26, 0.26, 0.27, 1 )

Color

current_line_color

Color( 0.25, 0.25, 0.26, 0.8 )

Color

executing_line_color

Color( 0.2, 0.8, 0.2, 0.4 )

Color

font_color

Color( 0.88, 0.88, 0.88, 1 )

Color

font_color_readonly

Color( 0.88, 0.88, 0.88, 0.5 )

Color

font_color_selected

Color( 0, 0, 0, 1 )

Color

function_color

Color( 0.4, 0.64, 0.81, 1 )

Color

line_number_color

Color( 0.67, 0.67, 0.67, 0.4 )

Color

mark_color

Color( 1, 0.4, 0.4, 0.4 )

Color

member_variable_color

Color( 0.9, 0.31, 0.35, 1 )

Color

number_color

Color( 0.92, 0.58, 0.2, 1 )

Color

safe_line_number_color

Color( 0.67, 0.78, 0.67, 0.6 )

Color

selection_color

Color( 0.49, 0.49, 0.49, 1 )

Color

symbol_color

Color( 0.94, 0.94, 0.94, 1 )

Color

word_highlighted_color

Color( 0.8, 0.9, 0.9, 0.15 )

int

completion_lines

7

int

completion_max_width

50

int

completion_scroll_width

3

int

line_spacing

4

Font

font

Texture

fold

Texture

folded

Texture

space

Texture

tab

StyleBox

completion

StyleBox

focus

StyleBox

normal

StyleBox

read_only

Señales

  • breakpoint_toggled ( int row )

Emitido cuando se coloca un breakpoint a través de la canaleta del breakpoint.


  • cursor_changed ( )

Emitido cuando el cursor cambia.


Emitido cuando se hace clic en el icono de información.


  • request_completion ( )



  • text_changed ( )

Emitido cuando el texto cambia.

Enumeraciones

enum SearchFlags:

  • SEARCH_MATCH_CASE = 1 --- Coincide con el caso cuando se busca.

  • SEARCH_WHOLE_WORDS = 2 --- Coincide con palabras enteras cuando se busca.

  • SEARCH_BACKWARDS = 4 --- Busca desde el final hasta el principio.


enum SearchResult:

  • SEARCH_RESULT_COLUMN = 0 --- Used to access the result column from search.

  • SEARCH_RESULT_LINE = 1 --- Used to access the result line from search.


enum MenuItems:

  • MENU_CUT = 0 --- Corta (copia y borra) el texto seleccionado.

  • MENU_COPY = 1 --- Copia el texto seleccionado.

  • MENU_PASTE = 2 --- Pega el texto del portapapeles sobre el texto seleccionado (o en la posición del cursor).

  • MENU_CLEAR = 3 --- Borra todo el texto TextEdit.

  • MENU_SELECT_ALL = 4 --- Selecciona todo el texto TextEdit.

  • MENU_UNDO = 5 --- Deshace la acción anterior.

  • MENU_REDO = 6 --- Rehace la acción anterior.

  • MENU_MAX = 7 --- Representa el tamaño del enum MenuItems.

Descripciones de Propiedades

  • bool bookmark_gutter

Default

false

Setter

set_bookmark_gutter_enabled(value)

Getter

is_bookmark_gutter_enabled()

If true, the bookmark gutter is visible.


  • bool breakpoint_gutter

Default

false

Setter

set_breakpoint_gutter_enabled(value)

Getter

is_breakpoint_gutter_enabled()

Si true, el breakpoint es visible.


Default

false

Setter

cursor_set_blink_enabled(value)

Getter

cursor_get_blink_enabled()

Si true, el caret (cursor visual) parpadea.


Default

0.65

Setter

cursor_set_blink_speed(value)

Getter

cursor_get_blink_speed()

Duración (en segundos) del ciclo de parpadeo de un caret.


  • bool caret_block_mode

Default

false

Setter

cursor_set_block_mode(value)

Getter

cursor_is_block_mode()

Si true, el caret se muestra como un rectángulo.

Si false, el caret se muestra como una barra.


  • bool caret_moving_by_right_click

Default

true

Setter

set_right_click_moves_caret(value)

Getter

is_right_click_moving_caret()

Si true, un clic con el botón derecho mueve el cursor en la posición del ratón antes de mostrar el menú contextual.

Si false, el menú contextual no tiene en cuenta la posición del ratón.


  • bool context_menu_enabled

Default

true

Setter

set_context_menu_enabled(value)

Getter

is_context_menu_enabled()

Si true, un clic con el botón derecho del ratón muestra el menú contextual.


Default

false

Setter

set_draw_spaces(value)

Getter

is_drawing_spaces()

Si true, el carácter "espacio" tendrá una representación visible.


Default

false

Setter

set_draw_tabs(value)

Getter

is_drawing_tabs()

Si true, el carácter "tab" tendrá una representación visible.


Default

false

Setter

set_draw_fold_gutter(value)

Getter

is_drawing_fold_gutter()

Si true, el canalón de pliegue es visible. Esto permite doblar grupos de líneas indentadas.


  • bool hiding_enabled

Default

false

Setter

set_hiding_enabled(value)

Getter

is_hiding_enabled()

Si true, todas las líneas que se han establecido como ocultas por set_line_as_hidden, no serán visibles.


  • bool highlight_all_occurrences

Default

false

Setter

set_highlight_all_occurrences(value)

Getter

is_highlight_all_occurrences_enabled()

Si true, se resaltarán todas las ocurrencias del texto seleccionado.


  • bool highlight_current_line

Default

false

Setter

set_highlight_current_line(value)

Getter

is_highlight_current_line_enabled()

Si true, se resalta la línea que contiene el cursor.


Default

false

Setter

draw_minimap(value)

Getter

is_drawing_minimap()

Si true, se muestra un minimapa, que proporciona un esquema de su código fuente.


  • int minimap_width

Default

80

Setter

set_minimap_width(value)

Getter

get_minimap_width()

El ancho, en píxeles, del minimapa.


  • bool override_selected_font_color

Default

false

Setter

set_override_selected_font_color(value)

Getter

is_overriding_selected_font_color()

Si true, se utilizará el font_color_selected personalizado para el texto seleccionado.


Default

false

Setter

set_readonly(value)

Getter

is_readonly()

Si true, se activa el modo de sólo lectura. El texto existente no puede ser modificado y no se puede añadir texto nuevo.


  • int scroll_horizontal

Default

0

Setter

set_h_scroll(value)

Getter

get_h_scroll()

If there is a horizontal scrollbar, this determines the current horizontal scroll value in pixels.


Default

0.0

Setter

set_v_scroll(value)

Getter

get_v_scroll()

If there is a vertical scrollbar, this determines the current vertical scroll value in line numbers, starting at 0 for the top line.


  • bool selecting_enabled

Default

true

Setter

set_selecting_enabled(value)

Getter

is_selecting_enabled()

Si true, se puede seleccionar el texto.

Si false, el texto no puede ser seleccionado por el usuario o por los métodos select o select_all.


  • bool shortcut_keys_enabled

Default

true

Setter

set_shortcut_keys_enabled(value)

Getter

is_shortcut_keys_enabled()

Si true, las teclas de atajo para los elementos del menú contextual están habilitadas, incluso si el menú contextual está desactivado.


  • bool show_line_numbers

Default

false

Setter

set_show_line_numbers(value)

Getter

is_show_line_numbers_enabled()

Si true, los números de línea se muestran a la izquierda del texto.


  • bool smooth_scrolling

Default

false

Setter

set_smooth_scroll_enable(value)

Getter

is_smooth_scroll_enabled()

Si true, establece el step de las scrollbars en 0.25 lo que resulta en un desplazamiento más suave.


  • bool syntax_highlighting

Default

false

Setter

set_syntax_coloring(value)

Getter

is_syntax_coloring_enabled()

If true, any custom color properties that have been set for this TextEdit will be visible.


Default

""

Setter

set_text(value)

Getter

get_text()

Valor de string de TextEdit.


Default

80.0

Setter

set_v_scroll_speed(value)

Getter

get_v_scroll_speed()

Sensibilidad de scroll vertical.


  • bool virtual_keyboard_enabled

Default

true

Setter

set_virtual_keyboard_enabled(value)

Getter

is_virtual_keyboard_enabled()

Si true, el teclado virtual nativo se muestra cuando se enfoca en plataformas que lo soportan.


Default

false

Setter

set_wrap_enabled(value)

Getter

is_wrap_enabled()

Si true, permite la envoltura del texto cuando va más allá del borde de lo que es visible.

Descripciones de Métodos

Adds color region (given the delimiters) and its colors.


  • void add_keyword_color ( String keyword, Color color )

Adds a keyword and its Color.


Regresa si la línea dada es plegable, es decir, tiene líneas indentadas justo debajo de ella.


  • void center_viewport_to_cursor ( )

Centra la vista en la línea en la que se encuentra el cursor de edición. Esto también restablece el valor de scroll_horizontal a 0.


  • void clear_colors ( )

Clears all custom syntax coloring information previously added with add_color_region or add_keyword_color.


  • void clear_undo_history ( )

Limpia el historial de deshacer.


  • void copy ( )

Copiar es la selección de texto actual.


  • int cursor_get_column ( ) const

Devuelve la columna en la que se encuentra el cursor de edición.


  • int cursor_get_line ( ) const

Devuelve la línea en la que está el cursor de edición.


  • void cursor_set_column ( int column, bool adjust_viewport=true )

Mueve el cursor en el índice de la columnespecificada.

Si adjust_viewport se establece en true, el viewport se centrará en la posición del cursor después de que se produzca el movimiento.


  • void cursor_set_line ( int line, bool adjust_viewport=true, bool can_be_hidden=true, int wrap_index=0 )

Mueve el cursor en el índice especificado de line.

Si adjust_viewport se establece en true, el viewport se centrará en la posición del cursor después de que se produzca el movimiento.

Si can_be_hidden se establece en true, la línea line especificada puede ser ocultada usando set_line_as_hidden.


  • void cut ( )

Corta la selección actual.


  • void deselect ( )

Deselecciona la selección actual.


  • void fold_all_lines ( )

Pliega todas las líneas que se pueden plegar (ver can_fold).


  • void fold_line ( int line )

Dobla la línea dada, si es posible (ver can_fold).


  • Array get_breakpoints ( ) const

Devuelve un array que contiene el número de línea de cada breakpoint.


Returns the Color of the specified keyword.


Devuelve el texto de una línea específica.


Returns the line and column at the given position. In the returned vector, x is the column, y is the line.


  • int get_line_count ( ) const

Devuelve la cantidad de líneas totales en el texto.


  • int get_line_height ( ) const

Returns the height of a largest line.


  • int get_line_width ( int line, int wrap_index=-1 ) const

Returns the width in pixels of the wrap_index on line.


  • int get_line_wrap_count ( int line ) const

Returns the number of times the given line is wrapped.


Returns an array of Strings representing each wrapped index.


Returns the PopupMenu of this TextEdit. By default, this menu is displayed when right-clicking on the TextEdit.

Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their CanvasItem.visible property.


Returns the local position for the given line and column. If x or y of the returned vector equal -1, the position is outside of the viewable area of the control.

Note: The Y position corresponds to the bottom side of the line. Use get_rect_at_line_column to get the top side position.


  • Rect2 get_rect_at_line_column ( int line, int column ) const

Returns the local position and size for the grapheme at the given line and column. If x or y position of the returned rect equal -1, the position is outside of the viewable area of the control.

Note: The Y position of the returned rect corresponds to the top side of the line, unlike get_pos_at_line_column which returns the bottom side.


  • int get_selection_from_column ( ) const

Devuelve la columna de inicio de la selección.


  • int get_selection_from_line ( ) const

Devuelve la línea de inicio de la selección.


  • String get_selection_text ( ) const

Devuelve el texto dentro de la selección.


  • int get_selection_to_column ( ) const

Devuelve la columna de final de selección.


  • int get_selection_to_line ( ) const

Devuelve la línea final de selección.


  • int get_total_gutter_width ( ) const

Returns the total width of all gutters and internal padding.


  • String get_word_under_cursor ( ) const

Returns a String text with the word under the caret (text cursor) location.


Returns whether the specified keyword has a color set to it or not.


  • bool has_redo ( ) const

Devuelve true si una acción de "redo" está disponible.


  • bool has_undo ( ) const

Devuelve true si se dispone de una acción de "deshacer".


  • void insert_text_at_cursor ( String text )

Inserta el texto especificado en la posición del cursor.


  • bool is_folded ( int line ) const

Devuelve si la línea del índice especificado está doblado o no.


  • bool is_line_hidden ( int line ) const

Devuelve si la línea en el índice especificado está oculta o no.


  • bool is_line_set_as_bookmark ( int line ) const

Returns true when the specified line is bookmarked.


  • bool is_line_set_as_breakpoint ( int line ) const

Returns true when the specified line has a breakpoint.


  • bool is_line_set_as_safe ( int line ) const

Returns true when the specified line is marked as safe.


  • bool is_line_wrapped ( int line ) const

Returns if the given line is wrapped.


  • bool is_selection_active ( ) const

Devuelve true si la selección está activa.


  • void menu_option ( int option )

Desencadena una acción de menú con el botón derecho del ratón por el índice especificado. Véase MenuItems para una lista de los índices disponibles.


  • void paste ( )

Pega la selección actual.


  • void redo ( )

Realiza la operación de rehacer.


  • void remove_breakpoints ( )

Elimina todos los breakpoints. Esto no disparará la señal breakpoint_toggled.


Perform a search inside the text. Search flags can be specified in the SearchFlags enum.

Returns an empty PoolIntArray if no result was found. Otherwise, the result line and column can be accessed at indices specified in the SearchResult enum, e.g:

var result = search(key, flags, line, column)
if result.size() > 0:
    # Result found.
    var res_line = result[TextEdit.SEARCH_RESULT_LINE]
    var res_column = result[TextEdit.SEARCH_RESULT_COLUMN]

  • void select ( int from_line, int from_column, int to_line, int to_column )

Realiza la selección, de línea/columna a línea/columna.

Si selecting_enabled es false, no se producirá ninguna selección.


  • void select_all ( )

Selecciona todo el texto.

Si selecting_enabled es false, no se producirá ninguna selección.


  • void set_line ( int line, String new_text )

Establece el texto para una línea específica.


  • void set_line_as_bookmark ( int line, bool bookmark )

Bookmarks the line if bookmark is true. Deletes the bookmark if bookmark is false.

Bookmarks are shown in the breakpoint_gutter.


  • void set_line_as_breakpoint ( int line, bool breakpoint )

Adds or removes the breakpoint in line. Breakpoints are shown in the breakpoint_gutter.


  • void set_line_as_hidden ( int line, bool enable )

Si true, oculta la línea del índice especificado.


  • void set_line_as_safe ( int line, bool safe )

If true, marks the line as safe.

This will show the line number with the color provided in the safe_line_number_color theme property.


  • void toggle_fold_line ( int line )

Cambia el plegado del bloque de código en la línea dada.


  • void undo ( )

Realiza la operación de deshacer.


  • void unfold_line ( int line )

Despliega la línea dada, si se dobla.


  • void unhide_all_lines ( )

Deshacer todas las líneas que fueron previamente establecidas como ocultas por set_line_as_hidden.

Theme Property Descriptions

Default

Color( 0, 0, 0, 0 )

Establece el fondo Color de este TextEdit. syntax_highlighting tiene que estar activada.


Default

Color( 0.08, 0.49, 0.98, 1 )

Establece el Color del marcador. syntax_highlighting tiene que estar activado.


  • Color brace_mismatch_color

Default

Color( 1, 0.2, 0.2, 1 )


Default

Color( 0.8, 0.8, 0.4, 0.2 )

Establece el Color de los breakpoints. El breakpoint_gutter tiene que estar activado.


  • Color caret_background_color

Default

Color( 0, 0, 0, 1 )


Default

Color( 0.88, 0.88, 0.88, 1 )


  • Color code_folding_color

Default

Color( 0.8, 0.8, 0.8, 0.8 )


  • Color completion_background_color

Default

Color( 0.17, 0.16, 0.2, 1 )


  • Color completion_existing_color

Default

Color( 0.87, 0.87, 0.87, 0.13 )


  • Color completion_font_color

Default

Color( 0.67, 0.67, 0.67, 1 )


  • Color completion_scroll_color

Default

Color( 1, 1, 1, 1 )


  • Color completion_selected_color

Default

Color( 0.26, 0.26, 0.27, 1 )


  • Color current_line_color

Default

Color( 0.25, 0.25, 0.26, 0.8 )

Establece el Color de los breakpoints. El breakpoint_gutter tiene que estar activado.


  • Color executing_line_color

Default

Color( 0.2, 0.8, 0.2, 0.4 )


Default

Color( 0.88, 0.88, 0.88, 1 )

Establece la fuente Color.


  • Color font_color_readonly

Default

Color( 0.88, 0.88, 0.88, 0.5 )


  • Color font_color_selected

Default

Color( 0, 0, 0, 1 )

Establece el Color del texto seleccionado. override_selected_font_color tiene que estar activado.


Default

Color( 0.4, 0.64, 0.81, 1 )


  • Color line_number_color

Default

Color( 0.67, 0.67, 0.67, 0.4 )

Establece el Color de los números de línea. show_line_numbers tiene que estar activado.


Default

Color( 1, 0.4, 0.4, 0.4 )

Establece el Color del texto marcado.


  • Color member_variable_color

Default

Color( 0.9, 0.31, 0.35, 1 )


Default

Color( 0.92, 0.58, 0.2, 1 )


  • Color safe_line_number_color

Default

Color( 0.67, 0.78, 0.67, 0.6 )


Default

Color( 0.49, 0.49, 0.49, 1 )

Establece el resaltado Color de las selecciones de texto.


Default

Color( 0.94, 0.94, 0.94, 1 )


  • Color word_highlighted_color

Default

Color( 0.8, 0.9, 0.9, 0.15 )

Establece el resaltado Color de múltiples ocurrencias. highlight_all_occurrences tiene que ser activado.


  • int completion_lines

Default

7


  • int completion_max_width

Default

50


  • int completion_scroll_width

Default

3


  • int line_spacing

Default

4

Establece el espacio entre las líneas.


Establece la Font predeterminada.





Sets a custom Texture for tab text characters.




Establece el StyleBox de este TextEdit.


Establece el StyleBox de este TextEdit cuando readonly está activado.