2020-01-23 08:18:19 +00:00
|
|
|
#pragma once
|
|
|
|
|
2024-06-25 14:23:37 +00:00
|
|
|
#include <Client/LineReader.h>
|
|
|
|
#include <base/strong_typedef.h>
|
2020-01-23 08:18:19 +00:00
|
|
|
#include <replxx.hxx>
|
|
|
|
|
2022-12-10 10:16:31 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-01-23 08:18:19 +00:00
|
|
|
class ReplxxLineReader : public LineReader
|
|
|
|
{
|
|
|
|
public:
|
2024-06-25 14:23:37 +00:00
|
|
|
ReplxxLineReader
|
|
|
|
(
|
2022-01-18 18:03:51 +00:00
|
|
|
Suggest & suggest,
|
2020-06-04 22:45:04 +00:00
|
|
|
const String & history_file_path,
|
|
|
|
bool multiline,
|
|
|
|
Patterns extenders_,
|
|
|
|
Patterns delimiters_,
|
2023-08-04 07:20:01 +00:00
|
|
|
const char word_break_characters_[],
|
2024-06-25 14:23:37 +00:00
|
|
|
replxx::Replxx::highlighter_callback_t highlighter_,
|
|
|
|
std::istream & input_stream_ = std::cin,
|
|
|
|
std::ostream & output_stream_ = std::cout,
|
|
|
|
int in_fd_ = STDIN_FILENO,
|
|
|
|
int out_fd_ = STDOUT_FILENO,
|
|
|
|
int err_fd_ = STDERR_FILENO
|
|
|
|
);
|
|
|
|
|
2020-01-23 08:18:19 +00:00
|
|
|
~ReplxxLineReader() override;
|
|
|
|
|
2020-02-25 08:30:11 +00:00
|
|
|
void enableBracketedPaste() override;
|
2023-04-06 23:04:51 +00:00
|
|
|
void disableBracketedPaste() override;
|
2020-02-25 08:30:11 +00:00
|
|
|
|
2022-01-29 11:44:27 +00:00
|
|
|
/// If highlight is on, we will set a flag to denote whether the last token is a delimiter.
|
|
|
|
/// This is useful to determine the behavior of <ENTER> key when multiline is enabled.
|
|
|
|
static void setLastIsDelimiter(bool flag);
|
2020-01-23 08:18:19 +00:00
|
|
|
private:
|
|
|
|
InputStatus readOneLine(const String & prompt) override;
|
|
|
|
void addToHistory(const String & line) override;
|
2021-11-16 18:07:33 +00:00
|
|
|
int executeEditor(const std::string & path);
|
2020-12-01 10:34:34 +00:00
|
|
|
void openEditor();
|
2020-01-23 08:18:19 +00:00
|
|
|
|
|
|
|
replxx::Replxx rx;
|
2020-06-04 22:45:04 +00:00
|
|
|
replxx::Replxx::highlighter_callback_t highlighter;
|
2020-06-04 21:31:51 +00:00
|
|
|
|
2023-08-04 07:20:01 +00:00
|
|
|
const char * word_break_characters;
|
|
|
|
|
2020-06-04 21:31:51 +00:00
|
|
|
// used to call flock() to synchronize multiple clients using same history file
|
|
|
|
int history_file_fd = -1;
|
2020-12-01 10:34:34 +00:00
|
|
|
bool bracketed_paste_enabled = false;
|
2021-11-16 18:07:33 +00:00
|
|
|
|
|
|
|
std::string editor;
|
2023-11-25 21:00:56 +00:00
|
|
|
bool overwrite_mode = false;
|
2020-01-23 08:18:19 +00:00
|
|
|
};
|
2022-12-10 10:16:31 +00:00
|
|
|
|
|
|
|
}
|