Difference between revisions of "CudaText API"

From Free Pascal wiki
Jump to navigationJump to search
Line 89: Line 89:
  
 
  get_sel_rect()
 
  get_sel_rect()
 +
 +
Gets 4-tuple: coords of column selection, (x1, y1, x2, y2). All 0 if no column selection.
  
 
===set_sel_rect===
 
===set_sel_rect===

Revision as of 18:51, 23 September 2015

Intro

This is API for CudaText in Python.

  • Main Py module is cudatext. Main module has constants, funcs, class Editor, objects of class Editor.
  • Additional module: cudatext_cmd has constants for command runner func.

Global funcs

msg_box

Editor class

Caret-related

get_caret

get_caret()

Returns 4-tuple: info about top visible caret: (PosX, PosY, EndX, EndY). PosY is line index (0-base), PosX is column (0-base), EndY/EndX are position of selection end for this caret or both -1 if no selection.

get_carets

get_carets()

Returns list of 4-tuples. Each list item is info about each caret, see get_caret.

set_caret

set_caret(posx, posy, endx=-1, endy=-1)

Sets single caret with given info (4 integers, see get_caret). Multi-carets 're removed.

add_caret

add_caret(posx, posy, endx=-1, endy=-1)

Adds caret with given info (4 integers, see get_caret). If called with posx<0, then all carets deleted.

Text read/write

get_text_all

get_text_all()

Returns str: entire text in editor.

set_text_all

set_text_all(text)

Sets entire text in editor from str.

get_text_line

get_text_line(num)

Gets str: line with given index (w/o CR LF). Gets None if index incorrect.

set_text_line

set_text_line(num, text)

Sets line with given index to given text. Text should be w/o CR LF.

get_text_substr

get_text_substr(x1, y1, x2, y2)

Gets substring: from caret position (x1, y1) to caret position (x2, y2). Second position must be higher.

Selection

get_text_sel

get_text_sel()

Returns str: selected text for 1st caret (empty, if no selection).

get_sel_mode

get_sel_mode()

Gets kind of selection: normal or column selection, values: SEL_NORMAL, SEL_COLUMN.

get_sel_lines

get_sel_lines()

Gets 2-tuple, indexes of 1st and last lines affected by 1st caret selection. Both -1 if no selection.

get_sel_rect

get_sel_rect()

Gets 4-tuple: coords of column selection, (x1, y1, x2, y2). All 0 if no column selection.

set_sel_rect

set_sel_rect(x1, y1, x2, y2)

Properties

Misc