mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-16 13:02:49 +00:00
045aff3d9f
The removal of duplicates is done in LastCommandsSection::add and uses the erase-remove idiom for performance. Most of the patch is a cleanup of GuiCommandBuffer: * remove history_ member, that was a copy of the session lastcommands vector. Use instead a wrapper history() around it and a addHistory wrapper for adding new entries. * Make sure that there is only one place where commands are added to history. The code used to maintain a list for interactive editing, and a list for saving the session. They could be different in terms of leading/trailing spaces. * [unrelated] remove command_ member, which is just a copy of LyXAction list of commmands. Use directly lyxaction instead.
94 lines
1.9 KiB
C++
94 lines
1.9 KiB
C++
// -*- C++ -*-
|
|
/**
|
|
* \file GuiCommandBuffer.h
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author Lars
|
|
* \author Asger and Jürgen
|
|
* \author John Levon
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#ifndef GUICOMMANDBUFFER_H
|
|
#define GUICOMMANDBUFFER_H
|
|
|
|
#include "support/docstring.h"
|
|
|
|
#include <QPushButton>
|
|
#include <QWidget>
|
|
|
|
#include <vector>
|
|
|
|
class QListWidgetItem;
|
|
|
|
namespace lyx {
|
|
|
|
class DispatchResult;
|
|
|
|
namespace frontend {
|
|
|
|
class GuiView;
|
|
class GuiCommandEdit;
|
|
|
|
class GuiCommandBuffer : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
GuiCommandBuffer(GuiView * view);
|
|
|
|
public Q_SLOTS:
|
|
/// dispatch a command
|
|
void dispatch();
|
|
/// tab-complete
|
|
void complete();
|
|
/// show history
|
|
void listHistoryUp();
|
|
/// called when an item in a list is selected
|
|
void itemSelected(QListWidgetItem *);
|
|
/// up
|
|
void up();
|
|
/// down
|
|
void down();
|
|
/// leave and hide the command buffer
|
|
void hideParent();
|
|
private:
|
|
/// owning view
|
|
GuiView * view_;
|
|
/// command widget
|
|
GuiCommandEdit * edit_;
|
|
|
|
/// return the previous history entry if any
|
|
std::string const historyUp();
|
|
/// return the next history entry if any
|
|
std::string const historyDown();
|
|
|
|
/// open a listbox and show the contents of the list. When reversed
|
|
/// is true, the contents of the list is filled bottom-up.
|
|
void showList(std::vector<std::string> const & list,
|
|
QPoint const & pos, bool reversed = false) const;
|
|
|
|
/// return the possible completions
|
|
std::vector<std::string> const completions(std::string const & prefix,
|
|
std::string & new_prefix);
|
|
|
|
/// dispatch a command
|
|
DispatchResult const & dispatch(std::string const & str);
|
|
|
|
/// current position in command history
|
|
std::vector<std::string>::const_iterator history_pos_;
|
|
|
|
/// the button up
|
|
QPushButton * upPB;
|
|
|
|
/// the button down
|
|
QPushButton * downPB;
|
|
};
|
|
|
|
} // namespace frontend
|
|
} // namespace lyx
|
|
|
|
#endif // GUICOMMANDBUFFER_H
|