File indexing completed on 2024-05-19 04:55:50
0001 /** 0002 * \file readlinecompleter.h 0003 * Abstract base class for readline completer. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 22 Sep 2013 0008 * 0009 * Copyright (C) 2013-2018 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #pragma once 0028 0029 #include <QList> 0030 0031 /** 0032 * Abstract base class for readline completer. 0033 */ 0034 class ReadlineCompleter { 0035 public: 0036 /** 0037 * Destructor. 0038 */ 0039 virtual ~ReadlineCompleter(); 0040 0041 /** 0042 * Get list of available commands. 0043 * @return command list. 0044 */ 0045 virtual QList<QByteArray> getCommandList() const = 0; 0046 0047 /** 0048 * Get list of available parameter values. 0049 * @return list of possible parameter values. 0050 */ 0051 virtual QList<QByteArray> getParameterList() const = 0; 0052 0053 /** 0054 * Update the list of possible parameter values. 0055 * @param buffer buffer containing command name and partial parameters 0056 * @return true if list updated, false if file name completion shall be used. 0057 */ 0058 virtual bool updateParameterList(const char* buffer) = 0; 0059 0060 /** 0061 * Install this completer to be used with readline. 0062 */ 0063 void install(); 0064 0065 private: 0066 static char** completion(const char* text, int start, int end); 0067 static char* commandGenerator(const char* text, int state); 0068 static char* parameterGenerator(const char* text, int state); 0069 static char* completionGenerator( 0070 const QList<QByteArray>& completions, const char* text, int state); 0071 0072 static ReadlineCompleter* s_completer; 0073 };