1/*
2 SPDX-FileCopyrightText: 2017 Allan Sandfeld Jensen <kde@carewolf.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KTEXTEDITOR_SCRIPTCURSOR_H
8#define KTEXTEDITOR_SCRIPTCURSOR_H
9
10#include <QJSEngine>
11#include <QJSValue>
12
13#include "ktexteditor/cursor.h"
14
15inline QJSValue cursorToScriptValue(QJSEngine *engine, const KTextEditor::Cursor cursor)
16{
17 const auto result = engine->globalObject().property(QStringLiteral("Cursor")).callAsConstructor(args: QJSValueList() << cursor.line() << cursor.column());
18 Q_ASSERT(!result.isError());
19 return result;
20}
21
22inline KTextEditor::Cursor cursorFromScriptValue(const QJSValue &obj)
23{
24 const auto line = obj.property(QStringLiteral("line"));
25 const auto column = obj.property(QStringLiteral("column"));
26 return KTextEditor::Cursor(line.toInt(), column.toInt());
27}
28
29#endif
30

source code of ktexteditor/src/script/scriptcursor.h