obsidian-notes/代码/获取光标位置.md
CSSC-WORK\murmur 3e6078442b init version
2024-04-15 11:19:57 +08:00

16 lines
513 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 获取光标位置
updated: 2022-01-17 02:32:27Z
created: 2022-01-17 02:16:00Z
---
`ctrl.getsel()`函数可获取光标在编辑框中的位置:
> edit.getsel() = 获取选区起始位置,结束位置\n
> 选区包含起始与结束位置的字符首字符位置为1\n
> 开始位置在指定的字符前面,结束位置表示指定的字符后面\n
> 只有一个返回值时表示无选区,并表示输入光标在指定字符后面\n
> 返回0表示输入光标在最前面,并且无选区