Add a -debug flag to :edit to set the buffer as debug data
As for the *debug* buffer, buffers with the debug flag wont get used for cycling through buffer, or word completion.
This commit is contained in:
parent
da206d9323
commit
a0b42323ed
|
@ -12,7 +12,7 @@ def lint -docstring 'Parse the current buffer with a linter' %{
|
||||||
printf '%s\n' "eval -no-hooks write $dir/buf"
|
printf '%s\n' "eval -no-hooks write $dir/buf"
|
||||||
|
|
||||||
printf '%s\n' "eval -draft %{
|
printf '%s\n' "eval -draft %{
|
||||||
edit! -fifo $dir/fifo *lint-output*
|
edit! -fifo $dir/fifo -debug *lint-output*
|
||||||
set buffer filetype make
|
set buffer filetype make
|
||||||
set buffer make_current_error_line 0
|
set buffer make_current_error_line 0
|
||||||
hook -group fifo buffer BufCloseFifo .* %{
|
hook -group fifo buffer BufCloseFifo .* %{
|
||||||
|
|
|
@ -20,7 +20,7 @@ The syntaxic errors detected during parsing are shown when auto-diagnostics are
|
||||||
%sh{
|
%sh{
|
||||||
dir=${kak_opt_clang_tmp_dir}
|
dir=${kak_opt_clang_tmp_dir}
|
||||||
printf %s\\n "eval -draft %{
|
printf %s\\n "eval -draft %{
|
||||||
edit! -fifo ${dir}/fifo *clang-output*
|
edit! -fifo ${dir}/fifo -debug *clang-output*
|
||||||
set buffer filetype make
|
set buffer filetype make
|
||||||
set buffer make_current_error_line 0
|
set buffer make_current_error_line 0
|
||||||
hook -group fifo buffer BufCloseFifo .* %{
|
hook -group fifo buffer BufCloseFifo .* %{
|
||||||
|
|
|
@ -87,7 +87,7 @@ void reload_file_buffer(Buffer& buffer)
|
||||||
buffer.reload(file_data, file_data.st.st_mtim);
|
buffer.reload(file_data, file_data.st.st_mtim);
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer* create_fifo_buffer(String name, int fd, bool scroll)
|
Buffer* create_fifo_buffer(String name, int fd, Buffer::Flags flags, bool scroll)
|
||||||
{
|
{
|
||||||
static ValueId s_fifo_watcher_id = get_free_value_id();
|
static ValueId s_fifo_watcher_id = get_free_value_id();
|
||||||
|
|
||||||
|
@ -95,12 +95,12 @@ Buffer* create_fifo_buffer(String name, int fd, bool scroll)
|
||||||
Buffer* buffer = buffer_manager.get_buffer_ifp(name);
|
Buffer* buffer = buffer_manager.get_buffer_ifp(name);
|
||||||
if (buffer)
|
if (buffer)
|
||||||
{
|
{
|
||||||
buffer->flags() |= Buffer::Flags::NoUndo;
|
buffer->flags() |= Buffer::Flags::NoUndo | flags;
|
||||||
buffer->reload({}, InvalidTime);
|
buffer->reload({}, InvalidTime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
buffer = buffer_manager.create_buffer(
|
buffer = buffer_manager.create_buffer(
|
||||||
std::move(name), Buffer::Flags::Fifo | Buffer::Flags::NoUndo);
|
std::move(name), flags | Buffer::Flags::Fifo | Buffer::Flags::NoUndo);
|
||||||
|
|
||||||
auto watcher_deleter = [buffer](FDWatcher* watcher) {
|
auto watcher_deleter = [buffer](FDWatcher* watcher) {
|
||||||
kak_assert(buffer->flags() & Buffer::Flags::Fifo);
|
kak_assert(buffer->flags() & Buffer::Flags::Fifo);
|
||||||
|
@ -159,7 +159,7 @@ Buffer* create_fifo_buffer(String name, int fd, bool scroll)
|
||||||
}), std::move(watcher_deleter));
|
}), std::move(watcher_deleter));
|
||||||
|
|
||||||
buffer->values()[fifo_watcher_id] = Value(std::move(watcher));
|
buffer->values()[fifo_watcher_id] = Value(std::move(watcher));
|
||||||
buffer->flags() = Buffer::Flags::Fifo | Buffer::Flags::NoUndo;
|
buffer->flags() = flags | Buffer::Flags::Fifo | Buffer::Flags::NoUndo;
|
||||||
buffer->run_hook_in_own_context("BufOpenFifo", buffer->name());
|
buffer->run_hook_in_own_context("BufOpenFifo", buffer->name());
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
|
@ -75,7 +75,7 @@ ColumnCount get_column(const Buffer& buffer,
|
||||||
ByteCount get_byte_to_column(const Buffer& buffer, ColumnCount tabstop,
|
ByteCount get_byte_to_column(const Buffer& buffer, ColumnCount tabstop,
|
||||||
DisplayCoord coord);
|
DisplayCoord coord);
|
||||||
|
|
||||||
Buffer* create_fifo_buffer(String name, int fd, bool scroll = false);
|
Buffer* create_fifo_buffer(String name, int fd, Buffer::Flags flags, bool scroll = false);
|
||||||
Buffer* open_file_buffer(StringView filename,
|
Buffer* open_file_buffer(StringView filename,
|
||||||
Buffer::Flags flags = Buffer::Flags::None);
|
Buffer::Flags flags = Buffer::Flags::None);
|
||||||
Buffer* open_or_create_file_buffer(StringView filename,
|
Buffer* open_or_create_file_buffer(StringView filename,
|
||||||
|
|
|
@ -58,14 +58,14 @@ struct option_type_name<TimestampedList<RangeAndFace>>
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
Buffer* open_fifo(StringView name, StringView filename, bool scroll)
|
Buffer* open_fifo(StringView name, StringView filename, Buffer::Flags flags, bool scroll)
|
||||||
{
|
{
|
||||||
int fd = open(parse_filename(filename).c_str(), O_RDONLY | O_NONBLOCK);
|
int fd = open(parse_filename(filename).c_str(), O_RDONLY | O_NONBLOCK);
|
||||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
throw runtime_error(format("unable to open '{}'", filename));
|
throw runtime_error(format("unable to open '{}'", filename));
|
||||||
|
|
||||||
return create_fifo_buffer(name.str(), fd, scroll);
|
return create_fifo_buffer(name.str(), fd, flags, scroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Completers> struct PerArgumentCommandCompleter;
|
template<typename... Completers> struct PerArgumentCommandCompleter;
|
||||||
|
@ -228,7 +228,8 @@ void edit(const ParametersParser& parser, Context& context, const ShellContext&)
|
||||||
|
|
||||||
Buffer* buffer = buffer_manager.get_buffer_ifp(name);
|
Buffer* buffer = buffer_manager.get_buffer_ifp(name);
|
||||||
const bool no_hooks = context.hooks_disabled();
|
const bool no_hooks = context.hooks_disabled();
|
||||||
const auto flags = no_hooks ? Buffer::Flags::NoHooks : Buffer::Flags::None;
|
const auto flags = (no_hooks ? Buffer::Flags::NoHooks : Buffer::Flags::None) |
|
||||||
|
(parser.get_switch("debug") ? Buffer::Flags::Debug : Buffer::Flags::None);
|
||||||
|
|
||||||
if (force_reload and buffer and buffer->flags() & Buffer::Flags::File)
|
if (force_reload and buffer and buffer->flags() & Buffer::Flags::File)
|
||||||
reload_file_buffer(*buffer);
|
reload_file_buffer(*buffer);
|
||||||
|
@ -246,7 +247,7 @@ void edit(const ParametersParser& parser, Context& context, const ShellContext&)
|
||||||
buffer = buffer_manager.create_buffer(name, flags);
|
buffer = buffer_manager.create_buffer(name, flags);
|
||||||
}
|
}
|
||||||
else if (auto fifo = parser.get_switch("fifo"))
|
else if (auto fifo = parser.get_switch("fifo"))
|
||||||
buffer = open_fifo(name, *fifo, (bool)parser.get_switch("scroll"));
|
buffer = open_fifo(name, *fifo, flags, (bool)parser.get_switch("scroll"));
|
||||||
else if (not buffer)
|
else if (not buffer)
|
||||||
{
|
{
|
||||||
buffer = parser.get_switch("existing") ? open_file_buffer(name, flags)
|
buffer = parser.get_switch("existing") ? open_file_buffer(name, flags)
|
||||||
|
@ -282,6 +283,7 @@ void edit(const ParametersParser& parser, Context& context, const ShellContext&)
|
||||||
ParameterDesc edit_params{
|
ParameterDesc edit_params{
|
||||||
{ { "existing", { false, "fail if the file does not exists, do not open a new file" } },
|
{ { "existing", { false, "fail if the file does not exists, do not open a new file" } },
|
||||||
{ "scratch", { false, "create a scratch buffer, not linked to a file" } },
|
{ "scratch", { false, "create a scratch buffer, not linked to a file" } },
|
||||||
|
{ "debug", { false, "treate buffer as debug output" } },
|
||||||
{ "fifo", { true, "create a buffer reading its content from a named fifo" } },
|
{ "fifo", { true, "create a buffer reading its content from a named fifo" } },
|
||||||
{ "scroll", { false, "place the initial cursor so that the fifo will scroll to show new data" } } },
|
{ "scroll", { false, "place the initial cursor so that the fifo will scroll to show new data" } } },
|
||||||
ParameterDesc::Flags::None, 0, 3
|
ParameterDesc::Flags::None, 0, 3
|
||||||
|
@ -543,7 +545,7 @@ void cycle_buffer(const ParametersParser& parser, Context& context, const ShellC
|
||||||
newbuf = it->get();
|
newbuf = it->get();
|
||||||
};
|
};
|
||||||
cycle();
|
cycle();
|
||||||
if (newbuf->flags() & Buffer::Flags::Debug)
|
while (newbuf != oldbuf and newbuf->flags() & Buffer::Flags::Debug)
|
||||||
cycle();
|
cycle();
|
||||||
|
|
||||||
if (newbuf != oldbuf)
|
if (newbuf != oldbuf)
|
||||||
|
|
|
@ -449,7 +449,7 @@ std::unique_ptr<UserInterface> create_local_ui(UIType ui_type)
|
||||||
int tty = open("/dev/tty", O_RDONLY);
|
int tty = open("/dev/tty", O_RDONLY);
|
||||||
dup2(tty, 0);
|
dup2(tty, 0);
|
||||||
close(tty);
|
close(tty);
|
||||||
create_fifo_buffer("*stdin*", fd);
|
create_fifo_buffer("*stdin*", fd, Buffer::Flags::None);
|
||||||
}
|
}
|
||||||
|
|
||||||
return make_unique<LocalUI>();
|
return make_unique<LocalUI>();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user