Compare commits

...

12 Commits

Author SHA1 Message Date
Maxime Coste
5c793a6a1e Merge remote-tracking branch 'Screwtapello/hint-git-next-hunk' 2023-10-04 21:04:27 +11:00
Maxime Coste
18902b15af Refactor regex_prompt logic and fix function being called on abort
Fixes #4993
2023-10-04 21:03:10 +11:00
Maxime Coste
7be996e5a4 Merge remote-tracking branch 'raiguard/rc/lua-highlighting' 2023-10-04 20:31:38 +11:00
Tim Allen
9286a7ee49 Make "git next-hunk" hint about how it works. 2023-10-04 10:53:20 +11:00
Tim Allen
87787defd8 The command is called "git prev-hunk", not "git previous-hunk". 2023-10-04 10:52:15 +11:00
Caleb Heuer
5ec40c63b2 Add highlighting of Lua variables, labels, and self keyword 2023-09-30 11:57:30 -06:00
Loric Brevet
a2fd401cfa
Add an InlineInformation face distinct from Information 2023-09-28 15:06:29 +02:00
Maxime Coste
23afed056b Add a daemonize-session command and refactor local client handling
Make it possible to move the current session to a daemon one after
the fact, which is useful to ensure the session state survives client
disconnecting, for example when working from ssh.
2023-09-26 17:50:56 +10:00
Maxime Coste
3bf16c0fb1 Merge remote-tracking branch 'krobelus/foot-custom-keypad-sequences' 2023-09-23 21:31:01 +10:00
Maxime Coste
f49b173497 Merge branch 'master' of http://github.com/epidemicz/kakoune 2023-09-23 21:29:13 +10:00
Tim Zenner
eeb18f6174
Update README.asciidoc 2023-09-21 00:42:13 -05:00
Johannes Altmanninger
84ea52e46e Support CSI u numpad keys
Normally page-down is sent as \033[6~ but some terminals
send a CSI u encoding for the page-down on the numpad. See
https://codeberg.org/dnkl/foot#keypad for example.

Treat them as the underlying key; we could add a modifier if anyone
cares about the distinction.
2023-06-24 22:18:49 +02:00
12 changed files with 89 additions and 67 deletions

View File

@ -31,8 +31,6 @@ regularly beating the best Vim solution.
See the link:doc/design.asciidoc[design document] for more information on
Kakoune's philosophy and design.
:numbered:
Introduction
------------

View File

@ -8,6 +8,9 @@ released versions.
* `+` only duplicates identical selections a single time to avoid surprising
and slow exponential growth in the number of selections.
* `daemonize-session` command makes it possible to convert the current session
to a deamon one (which will not exit on last client disconnecting)
== Kakoune 2023.08.08
* Fix compilation errors on FreeBSD and MacOS using clang

View File

@ -107,6 +107,9 @@ the user interface:
*Information*::
Face for windows and messages displaying other information.
*InlineInformation*::
Face for windows and messages displaying inline information.
*Error*::
Face for errors reported by Kakoune in the status line.

View File

@ -46,14 +46,17 @@ add-highlighter shared/lua/double_string region '"' (?<!\\)(?:\\\\)*" fill str
add-highlighter shared/lua/single_string region "'" (?<!\\)(?:\\\\)*' fill string
add-highlighter shared/lua/comment region '--' $ fill comment
add-highlighter shared/lua/code/variable regex \b\w*\b 0:variable # Everything in Lua is a variable!
add-highlighter shared/lua/code/function_declaration regex \b(?:function\h+)(?:\w+\h*\.\h*)*([a-zA-Z_]\w*)\( 1:function
add-highlighter shared/lua/code/function_call regex \b([a-zA-Z_]\w*)\h*(?=[\(\{]) 1:function
add-highlighter shared/lua/code/keyword regex \b(break|do|else|elseif|end|for|function|goto|if|in|local|repeat|return|then|until|while)\b 0:keyword
add-highlighter shared/lua/code/value regex \b(false|nil|true|[0-9]+(:?\.[0-9])?(:?[eE]-?[0-9]+)?|0x[0-9a-fA-F])\b 0:value
add-highlighter shared/lua/code/value regex \b(false|nil|true|self|[0-9]+(:?\.[0-9])?(:?[eE]-?[0-9]+)?|0x[0-9a-fA-F])\b 0:value
add-highlighter shared/lua/code/symbolic_operator regex (\+|-|\*|/|%|\^|==?|~=|<=?|>=?|\.\.|\.\.\.|#) 0:operator
add-highlighter shared/lua/code/keyword_operator regex \b(and|or|not)\b 0:operator
add-highlighter shared/lua/code/module regex \b(_G|_ENV)\b 0:module
add-highlighter shared/lua/code/attribute regex \B(<[a-zA-Z_]\w*>)\B 0:attribute
add-highlighter shared/lua/code/label regex \s(::\w*::) 1:meta
add-highlighter shared/lua/code/goto_label regex "\bgoto (\w*)\b" 1:meta
# Commands
# ‾‾‾‾‾‾‾‾

View File

@ -60,7 +60,7 @@ define-command -params 1.. \
init
log
next-hunk
previous-hunk
prev-hunk
show
show-branch
show-diff
@ -225,7 +225,7 @@ define-command -params 1.. \
shift
if [ $# -lt 1 ]; then
echo "fail 'no git hunks found'"
echo "fail 'no git hunks found, try \":git show-diff\" first'"
exit
fi

View File

@ -278,7 +278,8 @@ void Client::redraw_ifn()
if (m_ui_pending & InfoShow and m_info.ui_anchor)
m_ui->info_show(m_info.title, m_info.content, *m_info.ui_anchor,
faces["Information"], m_info.style);
faces[(is_inline(m_info.style) || m_info.style == InfoStyle::MenuDoc)
? "InlineInformation" : "Information"], m_info.style);
if (m_ui_pending & InfoHide)
m_ui->info_hide();

View File

@ -688,6 +688,17 @@ const CommandDesc force_kill_cmd = {
kill<true>
};
const CommandDesc daemonize_session_cmd = {
"daemonize-session",
nullptr,
"daemonize-session: set the session server not to quit on last client exit",
{ {} },
CommandFlags::None,
CommandHelper{},
CommandCompleter{},
[](const ParametersParser&, Context&, const ShellContext&) { Server::instance().daemonize(); }
};
template<bool force>
void quit(const ParametersParser& parser, Context& context, const ShellContext&)
{
@ -2756,6 +2767,7 @@ void register_commands()
register_command(write_all_quit_cmd);
register_command(kill_cmd);
register_command(force_kill_cmd);
register_command(daemonize_session_cmd);
register_command(quit_cmd);
register_command(force_quit_cmd);
register_command(write_quit_cmd);

View File

@ -191,6 +191,7 @@ FaceRegistry::FaceRegistry()
{ "MenuBackground", {Face{ Color::Blue, Color::White }} },
{ "MenuInfo", {Face{ Color::Cyan, Color::Default }} },
{ "Information", {Face{ Color::Black, Color::Yellow }} },
{ "InlineInformation", {Face{}, "Information"} },
{ "Error", {Face{ Color::Black, Color::Red }} },
{ "DiagnosticError", {Face{ Color::Red, Color::Default }} },
{ "DiagnosticWarning", {Face{ Color::Yellow, Color::Default }} },

View File

@ -47,6 +47,7 @@ struct {
} constexpr version_notes[] = { {
0,
"» {+b}+{} only duplicates identical selections a single time\n"
"» {+u}daemonize-session{} command\n"
}, {
20230805,
"» Fix FreeBSD/MacOS clang compilation\n"
@ -603,7 +604,6 @@ void register_options()
}
static Client* local_client = nullptr;
static int local_client_exit = 0;
static bool convert_to_client_pending = false;
enum class UIType
@ -671,38 +671,7 @@ pid_t fork_server_to_background()
std::unique_ptr<UserInterface> create_local_ui(UIType ui_type)
{
if (ui_type != UIType::Terminal)
return make_ui(ui_type);
struct LocalUI : TerminalUI
{
LocalUI()
{
set_signal_handler(SIGTSTP, [](int) {
if (ClientManager::instance().count() == 1 and
*ClientManager::instance().begin() == local_client)
TerminalUI::instance().suspend();
else
convert_to_client_pending = true;
});
}
~LocalUI() override
{
local_client = nullptr;
if (convert_to_client_pending or
ClientManager::instance().empty())
return;
if (fork_server_to_background())
{
this->TerminalUI::~TerminalUI();
exit(local_client_exit);
}
}
};
if (not isatty(0))
if (ui_type == UIType::Terminal and not isatty(0))
{
// move stdin to another fd, and restore tty as stdin
int fd = dup(0);
@ -712,7 +681,19 @@ std::unique_ptr<UserInterface> create_local_ui(UIType ui_type)
create_fifo_buffer("*stdin*", fd, Buffer::Flags::None);
}
return std::make_unique<LocalUI>();
auto ui = make_ui(ui_type);
static SignalHandler old_handler = set_signal_handler(SIGTSTP, [](int sig) {
if (ClientManager::instance().count() == 1 and
*ClientManager::instance().begin() == local_client)
old_handler(sig);
else
{
convert_to_client_pending = true;
set_signal_handler(SIGTSTP, old_handler);
}
});
return ui;
}
int run_client(StringView session, StringView name, StringView client_init,
@ -875,13 +856,14 @@ int run_server(StringView session, StringView server_init,
write_to_debug_buffer(format("error while opening command line files: {}", error.what()));
}
int exit_status = 0;
try
{
if (not server.is_daemon())
{
local_client = client_manager.create_client(
create_local_ui(ui_type), getpid(), {}, get_env_vars(), client_init, init_buffer, std::move(init_coord),
[](int status) { local_client_exit = status; });
[&](int status) { exit_status = status; });
if (startup_error and local_client)
local_client->print_status({
@ -920,24 +902,22 @@ int run_server(StringView session, StringView server_init,
global_scope.option_registry().clear_option_trash();
if (local_client and not contains(client_manager, local_client))
local_client = nullptr;
else if (local_client and not local_client->is_ui_ok())
{
ClientManager::instance().remove_client(*local_client, false, -1);
local_client = nullptr;
if (not client_manager.empty() and fork_server_to_background())
return 0;
if ((not client_manager.empty() or server.is_daemon()) and fork_server_to_background())
exit(exit_status); // We do not want to run destructors and hooks here
}
else if (convert_to_client_pending)
{
kak_assert(local_client);
auto& local_context = local_client->context();
const String client_name = local_context.name();
const String buffer_name = local_context.buffer().name();
const String selections = selection_list_to_string(ColumnType::Byte, local_context.selections());
String client_name = local_context.name();
String buffer_name = local_context.buffer().name();
String selections = selection_list_to_string(ColumnType::Byte, local_context.selections());
ClientManager::instance().remove_client(*local_client, true, 0);
client_manager.clear_client_trash();
local_client = nullptr;
convert_to_client_pending = false;
if (fork_server_to_background())
@ -952,7 +932,7 @@ int run_server(StringView session, StringView server_init,
}
catch (const kill_session& kill)
{
local_client_exit = kill.exit_status;
exit_status = kill.exit_status;
}
{
@ -960,7 +940,7 @@ int run_server(StringView session, StringView server_init,
global_scope.hooks().run_hook(Hook::KakEnd, "", empty_context);
}
return local_client_exit;
return exit_status;
}
int run_filter(StringView keystr, ConstArrayView<StringView> files, bool quiet, StringView suffix_backup)

View File

@ -854,20 +854,22 @@ void regex_prompt(Context& context, String prompt, char reg, T func)
context.input_handler().set_prompt_face(context.faces()["Prompt"]);
}
if (not incsearch and event == PromptEvent::Change)
return;
if (event == PromptEvent::Validate)
context.push_jump();
else
RegisterManager::instance()[reg].restore(context, saved_reg);
if (not str.empty() and event == PromptEvent::Change) // Ensure search register based highlighters work incrementally
RegisterManager::instance()[reg].set(context, str.str());
if (not str.empty() or event == PromptEvent::Validate)
func(Regex{str.empty() ? default_regex : str, direction_flags(mode)}, event, context);
switch (event)
{
case PromptEvent::Change:
if (not incsearch or str.empty())
return;
RegisterManager::instance()[reg].set(context, str.str());
func(Regex{str, direction_flags(mode)}, event, context);
return;
case PromptEvent::Abort:
RegisterManager::instance()[reg].restore(context, saved_reg);
return;
case PromptEvent::Validate:
context.push_jump();
func(Regex{str.empty() ? default_regex : str, direction_flags(mode)}, event, context);
return;
}
}
catch (regex_error& err)
{

View File

@ -59,6 +59,7 @@ struct Server : public Singleton<Server>
bool negotiating() const { return not m_accepters.empty(); }
void daemonize() { m_is_daemon = true; }
bool is_daemon() const { return m_is_daemon; }
private:

View File

@ -879,8 +879,26 @@ Optional<Key> TerminalUI::get_next_key()
}
return {};
case 'u':
return masked_key(convert(static_cast<Codepoint>(params[0][0])),
convert(static_cast<Codepoint>(params[0][1])));
{
Codepoint key;
switch (params[0][0])
{
// Treat numpad keys the same as their non-numpad counterparts. Could add a numpad modifier here.
case 57414: key = Key::Return; break;
case 57417: key = Key::Left; break;
case 57418: key = Key::Right; break;
case 57419: key = Key::Up; break;
case 57420: key = Key::Down; break;
case 57421: key = Key::PageUp; break;
case 57422: key = Key::PageDown; break;
case 57423: key = Key::Home; break;
case 57424: key = Key::End; break;
case 57425: key = Key::Insert; break;
case 57426: key = Key::Delete; break;
default: key = convert(static_cast<Codepoint>(params[0][0])); break;
}
return masked_key(key, convert(static_cast<Codepoint>(params[0][1])));
}
case 'Z': return shift(Key::Tab);
case 'I': return {Key::FocusIn};
case 'O': return {Key::FocusOut};