KTextEditor

commandrangeexpressionparser.h
1/*
2 SPDX-FileCopyrightText: 2008-2009 Erlend Hamberg <ehamberg@gmail.com>
3 SPDX-FileCopyrightText: 2011 Svyatoslav Kuzmich <svatoslav1@gmail.com>
4 SPDX-FileCopyrightText: 2012 Vegard Øye
5 SPDX-FileCopyrightText: 2013 Simon St James <kdedevel@etotheipiplusone.com>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#ifndef KATEVI_COMMAND_RANGE_EXPRESSION_PARSER
11#define KATEVI_COMMAND_RANGE_EXPRESSION_PARSER
12
13#include <ktexteditor/range.h>
14
15namespace KateVi
16{
17class InputModeManager;
18
19class CommandRangeExpressionParser
20{
21public:
22 explicit CommandRangeExpressionParser(InputModeManager *vimanager);
23
24 /**
25 * Attempt to parse any leading range expression (e.g. "%", "'<,'>", ".,+6" etc) in @c command and
26 * return it as a Range. If parsing was successful, the range will be valid and the command with
27 * the range stripped will be placed in @c destTransformedCommand. In some special cases,
28 * the @c destTransformedCommand will be further re-written e.g. a command in the form of just a number
29 * will be rewritten as "goto <number>".
30 *
31 * An invalid Range is returned if no leading range expression could be found.
32 */
33 KTextEditor::Range parseRange(const QString &command, QString &destTransformedCommand) const;
34
35 /**
36 * Attempts to find range expression for vi command
37 * @returns range sub string of passed command or empty if not found
38 */
39 static QString parseRangeString(const QString &command);
40
41private:
42 int calculatePosition(const QString &string) const;
43
44 static bool matchLineNumber(const QString &line, QList<int> &values);
45 bool matchLastLine(const QString &line, QList<int> &values) const;
46 bool matchThisLine(const QString &line, QList<int> &values) const;
47 bool matchMark(const QString &line, QList<int> &values) const;
48 bool matchForwardSearch(const QString &line, QList<int> &values) const;
49 bool matchBackwardSearch(const QString &line, QList<int> &values) const;
50
51private:
52 InputModeManager *m_viInputModeManager;
53};
54
55}
56
57#endif
An object representing a section of text, from one Cursor to another.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:57:26 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.