[英]Ace Editor Get Current Cursor Row and Column
我正在使用Ace编辑器。 在Javascript(不是jQuery)中,如何返回当前光标的行和列位置?
editor.getCursorPosition()
返回具有行和列属性的对象
这是将为您提供对象的功能。
getCursor() //The name of this function it may have been changed - this is a current one as of September 2016
它返回一个由两个成员组成的Position对象:
row
column
使用方法是:
var iRowPosition;
var iColumnPosition;
var oPositionObject;
oPositionObject = InstanceOfYourEditor.selection.getCursor(); // to get the Position Object
iRowPosition = InstanceOfYourEditor.selection.getCursor().row; // to get the Row Position
iColumnPosition = InstanceOfYourEditor.selection.getCursor().column; // to get the Column Position
假设您想将此对象作为参数传递给其他函数,例如:
InstanceOfYourEditor.selection.insert() //accepts Position Object and a text to insert
那么您可以按原样传递对象
InstanceOfYourEditor.selection.insert(oPositionObject, "Just Want To Provide A More Detailed Answer So My Fellows Can Better Visualize It All");
这个答案更多的是“为您钓鱼”-但我鼓励您通过参考包含有关对象的所有信息的Ace Editor API来学习一般的捕鱼方法,尤其是Ace Editor对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.