# com.hexEditor 库模块帮助文档

## com 成员列表 <a id="com" href="#com">&#x23;</a>

### com.hexEditor() <a id="com.hexEditor" href="#com.hexEditor">&#x23;</a>
[返回对象:hexEditorObject](#hexEditorObject)

### com.hexEditor(winform) <a id="com.hexEditor" href="#com.hexEditor">&#x23;</a>
创建十六进制编辑器  
参数为窗口或控件对象

## hexEditorObject 成员列表 <a id="hexEditorObject" href="#hexEditorObject">&#x23;</a>

### hexEditorObject.accessData(callback) <a id="hexEditorObject.accessData" href="#hexEditorObject.accessData">&#x23;</a>

```aardio
hexEditorObject.accessData( function(dataPtr,size){  
	/*获取当前编辑的数据指针，  
dataPtr 为数据指针, size 为数据长度。  
不可保存 dataPtr 指针并在回调函数外部使用 */  
})
```

### hexEditorObject.copy() <a id="hexEditorObject.copy" href="#hexEditorObject.copy">&#x23;</a>
复制选区

### hexEditorObject.cut() <a id="hexEditorObject.cut" href="#hexEditorObject.cut">&#x23;</a>
剪切选区

### hexEditorObject.deselect() <a id="hexEditorObject.deselect" href="#hexEditorObject.deselect">&#x23;</a>
取消选区

### hexEditorObject.find <a id="hexEditorObject.find" href="#hexEditorObject.find">&#x23;</a>
查找并选中数据

### hexEditorObject.find(模找模式串,开始位置) <a id="hexEditorObject.find" href="#hexEditorObject.find">&#x23;</a>
查找并选中数据。  
参数 @1 支持模式匹配语法，  
开始位置以字节计数

### hexEditorObject.findNext(模找模式串) <a id="hexEditorObject.findNext" href="#hexEditorObject.findNext">&#x23;</a>
查找下一个并选中数据。  
参数 @1 支持模式匹配语法，

### hexEditorObject.getBuffer() <a id="hexEditorObject.getBuffer" href="#hexEditorObject.getBuffer">&#x23;</a>
获取修改后的数据  
返回值为buffer类型字节数组,  
返回值不会自动更新数据,必须调用getBuffer()函数才能得到最新的修改后的数据

### hexEditorObject.getCaretPos() <a id="hexEditorObject.getCaretPos" href="#hexEditorObject.getCaretPos">&#x23;</a>
返回光标位置

### hexEditorObject.getCodePage() <a id="hexEditorObject.getCodePage" href="#hexEditorObject.getCodePage">&#x23;</a>
返回代码页

### hexEditorObject.getDataModified() <a id="hexEditorObject.getDataModified" href="#hexEditorObject.getDataModified">&#x23;</a>
数据是否已被用户修改

### hexEditorObject.getFontHeight() <a id="hexEditorObject.getFontHeight" href="#hexEditorObject.getFontHeight">&#x23;</a>
返回字体大小

### hexEditorObject.getSel() <a id="hexEditorObject.getSel" href="#hexEditorObject.getSel">&#x23;</a>
返回选区开始位置,结束位置  
0 为无选区

### hexEditorObject.getSelBuffer() <a id="hexEditorObject.getSelBuffer" href="#hexEditorObject.getSelBuffer">&#x23;</a>
获取选区数据，  
如果选区非空返回 buffer 对象。  
否则返回 null

### hexEditorObject.getSelHex() <a id="hexEditorObject.getSelHex" href="#hexEditorObject.getSelHex">&#x23;</a>
如果选区非空，  
返回选区数据的 16 进制编码文本。  
可选用参数 @1 指定编码前缀，默认为 \x

### hexEditorObject.load() <a id="hexEditorObject.load" href="#hexEditorObject.load">&#x23;</a>
加载文件，  
参数 @1 指定文件路径，支持资源文件

### hexEditorObject.paste() <a id="hexEditorObject.paste" href="#hexEditorObject.paste">&#x23;</a>
粘贴数据

### hexEditorObject.replace <a id="hexEditorObject.replace" href="#hexEditorObject.replace">&#x23;</a>
替换当前选区数据

### hexEditorObject.replace(数据) <a id="hexEditorObject.replace" href="#hexEditorObject.replace">&#x23;</a>
替换当前选区数据，  
数据可以是字符串、buffer类型数据等

### hexEditorObject.selectAll() <a id="hexEditorObject.selectAll" href="#hexEditorObject.selectAll">&#x23;</a>
全选

### hexEditorObject.setAllowChangeSize() <a id="hexEditorObject.setAllowChangeSize" href="#hexEditorObject.setAllowChangeSize">&#x23;</a>
是否允许改变长度,默认值为false

### hexEditorObject.setAppearance() <a id="hexEditorObject.setAppearance" href="#hexEditorObject.setAppearance">&#x23;</a>
0为扁平相式，1为2D边框

### hexEditorObject.setBackColor() <a id="hexEditorObject.setBackColor" href="#hexEditorObject.setBackColor">&#x23;</a>
设置背景颜色,数值 color

### hexEditorObject.setBuffer <a id="hexEditorObject.setBuffer" href="#hexEditorObject.setBuffer">&#x23;</a>
加载数据

### hexEditorObject.setBuffer(数据,开始地址) <a id="hexEditorObject.setBuffer" href="#hexEditorObject.setBuffer">&#x23;</a>
数据可以是字符串、buffer类型数据等,  
数据总是从开始显示，开始地址参数仅用于左侧栏显示地址的开始值

### hexEditorObject.setCodePage() <a id="hexEditorObject.setCodePage" href="#hexEditorObject.setCodePage">&#x23;</a>
设置代码页,  
默认值为 65001（UTF-8 编码）,0 为系统 ANSI 编码

### hexEditorObject.setColumns() <a id="hexEditorObject.setColumns" href="#hexEditorObject.setColumns">&#x23;</a>
显示的列数，设为0时根据控件宽度自动计算列数

### hexEditorObject.setDigitsInAddress() <a id="hexEditorObject.setDigitsInAddress" href="#hexEditorObject.setDigitsInAddress">&#x23;</a>
设置地址栏显示的数位,默认为 4

### hexEditorObject.setFontHeight() <a id="hexEditorObject.setFontHeight" href="#hexEditorObject.setFontHeight">&#x23;</a>
设置字体大小,默认为 14

### hexEditorObject.setForeColor() <a id="hexEditorObject.setForeColor" href="#hexEditorObject.setForeColor">&#x23;</a>
设置文本颜色,数值 Text color

### hexEditorObject.setSel <a id="hexEditorObject.setSel" href="#hexEditorObject.setSel">&#x23;</a>
设置选区

### hexEditorObject.setSel(开始位置,结束位置) <a id="hexEditorObject.setSel" href="#hexEditorObject.setSel">&#x23;</a>
设置选区,  
参数以字节为单位，1 表示第 1 个字节。  
参数指定的位置超出长度或小于 1 时不执行任何操作

### hexEditorObject.setShowAddress() <a id="hexEditorObject.setShowAddress" href="#hexEditorObject.setShowAddress">&#x23;</a>
设为 true 显示地址栏

### hexEditorObject.setShowAscii() <a id="hexEditorObject.setShowAscii" href="#hexEditorObject.setShowAscii">&#x23;</a>
设为 true 显示 ASCII 字符

### hexEditorObject.size() <a id="hexEditorObject.size" href="#hexEditorObject.size">&#x23;</a>
获取当前编辑的数据长度

## hexEditorObject 事件列表 <a id="hexEditorObjectEvent" href="#hexEditorObjectEvent">&#x23;</a>

### hexEditorObject.onCaretPositionChanged <a id="hexEditorObject.onCaretPositionChanged" href="#hexEditorObject.onCaretPositionChanged">&#x23;</a>

```aardio

import win.debounce;  
hexEditorObject.onCaretPositionChanged = win.debounce(function(caretPos,selStart,selEnd){  
	/*光标或选区变更时触发此事件。  
caretPos 为光标位置，selStart 为选区开始位置，  
selEnd 为选区结束位置*/  
});
```

