# Api Reference

## getValue(\[from, to])

Arguments :&#x20;

| Name | Type   | Default |          |
| ---- | ------ | ------- | -------- |
| from | Number |         | optional |
| to   | Number |         | optional |

Return : `String`

```javascript
const value = iblize.getValue();
const subValue = iblize.getValue(0. 10); // just like a substring 
```

## setValue(text\[, recordHistory])

Arguments :&#x20;

| Name          | Type    | Default |          |
| ------------- | ------- | ------- | -------- |
| value         | String  |         | required |
| recordHistory | Boolean | true    | optional |

this method will replace current value with new value

```javascript
iblize.setValue("console.log('hello');");
```

## getOptions()

Return : `Object`

```javascript
const options = iblize.getOptions();
```

## setOptions(options)

Arguments :&#x20;

| Name    | Type   | Default |          |
| ------- | ------ | ------- | -------- |
| options | Object |         | required |

update editor options [see all options](https://github.com/mcanam/iblize#options)

```javascript
iblize.setOptions({
    lineNumber: false,
    // etc
});
```

## getSelection()

Return : `Object { start, end, dir }`&#x20;

```javascript
const selection = iblze.getSelection();
```

## setSelection(start, end\[, dir])

Arguments :&#x20;

| Name  | Type   | Default |          |
| ----- | ------ | ------- | -------- |
| start | Number |         | required |
| end   | Number |         | required |
| dir   | String | "none"  | optional |

```javascript
iblize.setSelection(10, 20);
```

## getCursor()

Return : `Number`

```javascript
const cursor = iblize.getCursor();
```

## setCursor(pos)

Arguments :&#x20;

| Name | Type   | Default |          |
| ---- | ------ | ------- | -------- |
| pos  | Number |         | required |

## getActiveLine()

Return : `Number`

```javascript
const activeLine = iblize.getActiveLine();
```

## getTotalLine()

Return : `Number`

```javascript
const totalLine = iblize.getTotalLine();
```

## getLineValue(line)

Arguments :&#x20;

| Name | Type   | Default |          |
| ---- | ------ | ------- | -------- |
| line | Number |         | required |

Return : `String`

```javascript
const lineValue = iblize.getLineValue(2);
```

## insertTab()

```javascript
iblize.insertTab()
```

## insertText(from, text\[, options])

Arguments :&#x20;

| Name    | Type   | Default |          |
| ------- | ------ | ------- | -------- |
| from    | Number |         | required |
| to      | Number |         | required |
| options | Object |         | optional |

options properties :&#x20;

| Name          | Type   | Default | Accept Value                            |
| ------------- | ------ | ------- | --------------------------------------- |
| moveCursor    | Number |         |                                         |
| recordHistory | String | "after" | "before" \| "after" \| "both" \| "none" |

```javascript
iblize.insertText(10, "hai");

iblize.insertText(10, "hai", {
    moveCursor: 10 + 3
});
```

## removeText(from, to\[, options])

Arguments :&#x20;

| Name    | Type   | Default |          |
| ------- | ------ | ------- | -------- |
| from    | Number |         | required |
| to      | Number |         | required |
| options | Object |         | optional |

options properties :&#x20;

| Name          | Type   | Default | Accept Value                            |
| ------------- | ------ | ------- | --------------------------------------- |
| moveCursor    | Number |         |                                         |
| recordHistory | String | "after" | "before" \| "after" \| "both" \| "none" |

```javascript
iblize.removeText(10, 13);
```

## undo()

```javascript
iblize.undo();
```

## redo()

```javascript
iblize.redo();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mcanam.gitbook.io/iblize-docs/api-reference.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
