Compare commits

..

No commits in common. "e7da32160c778f943e2b50abb5a1360d1917dd44" and "9056ef41946dca407015ec45505e99d3542e82d1" have entirely different histories.

4 changed files with 9 additions and 35 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2017 - 2021, Přemysl Eric Janouch <p@janouch.name>
Copyright (c) 2017 - 2020, Přemysl Eric Janouch <p@janouch.name>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

View File

@ -1,8 +1,8 @@
.POSIX:
SHELL = /bin/sh
CXXFLAGS = -g -std=c++14 -Wall -Wextra -pedantic
CPPFLAGS = `sed -ne '/^project (\([^ )]*\) VERSION \([^ )]*\).*/ \
s//-DPROJECT_NAME="\1" -DPROJECT_VERSION="\2"/p' CMakeLists.txt`
CPPFLAGS = `sed -ne 's/^project (\([^ )]*\).*/-DPROJECT_NAME="\1"/p' \
-e 's/^set (version \([^ )]*\).*/-DPROJECT_VERSION="\1"/p' CMakeLists.txt`
sdn: sdn.cpp CMakeLists.txt
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $< -o sdn \

14
sdn.1
View File

@ -98,20 +98,6 @@ normal h parent
normal l choose
normal M-f4 quit
.Ed
.Pp
Midnight Commander binds the same traversal actions to sequences normally
unknown to ncurses, due to them being missing from terminfo.
You'll need to define them manually to match your terminal.
For rxvt, that would be:
.Bd -literal -offset indent
define C-ppage ^[[5^
define C-npage ^[[6^
normal C-ppage parent
normal C-npage choose
.Ed
.Pp
Escape characters must be inserted verbatim, e.g., by pressing C-v ESC in vi,
or C-q ESC in Emacs.
.Ss Pa look
Terminal attributes are accepted in a format similar to that of
.Xr git-config 1 ,

24
sdn.cpp
View File

@ -1,7 +1,7 @@
//
// sdn: simple directory navigator
//
// Copyright (c) 2017 - 2021, Přemysl Eric Janouch <p@janouch.name>
// Copyright (c) 2017 - 2020, Přemysl Eric Janouch <p@janouch.name>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted.
@ -544,7 +544,6 @@ static struct {
map<string, wint_t, stringcaseless> name_to_key;
map<wint_t, string> key_to_name;
map<string, wint_t> custom_keys;
string action_names[ACTION_COUNT]; ///< Stylized action names
// Refreshed by reload():
@ -1567,9 +1566,7 @@ fun parse_key (const string &key_name) -> wint_t {
c |= ALT;
p += 2;
}
if (g.name_to_key.count (p)) {
return c | g.name_to_key.at (p);
} else if (!strncmp (p, "C-", 2)) {
if (!strncmp (p, "C-", 2)) {
p += 2;
if (*p < '?' || *p > 'z') {
cerr << "bindings: invalid combination: " << key_name << endl;
@ -1577,6 +1574,8 @@ fun parse_key (const string &key_name) -> wint_t {
}
c |= CTRL (toupper (*p));
p += 1;
} else if (g.name_to_key.count (p)) {
return c | g.name_to_key.at (p);
} else {
wchar_t w; mbstate_t mb {};
auto len = strlen (p) + 1, res = mbrtowc (&w, p, len, &mb);
@ -1605,9 +1604,7 @@ fun learn_named_key (const string &name, wint_t key) {
fun load_bindings () {
learn_named_key ("space", ' ');
learn_named_key ("escape", 0x1b);
int kc = 0;
for (kc = KEY_MIN; kc <= KEY_MAX; kc++) {
for (int kc = KEY_MIN; kc < KEY_MAX; kc++) {
const char *name = keyname (kc);
if (!name)
continue;
@ -1641,18 +1638,11 @@ fun load_bindings () {
if (tokens.empty ())
continue;
if (tokens.size () < 3) {
cerr << "bindings: expected: define name key-sequence"
" | context binding action";
cerr << "bindings: expected: context binding action";
continue;
}
auto context = tokens[0], key_name = tokens[1], action = tokens[2];
if (context == "define") {
// We haven't run initscr() yet, so define_key() would fail here
learn_named_key (key_name, SYM | (g.custom_keys[action] = ++kc));
continue;
}
auto m = g_binding_contexts.find (context);
if (m == g_binding_contexts.end ()) {
cerr << "bindings: invalid context: " << context << endl;
@ -1764,8 +1754,6 @@ int main (int argc, char *argv[]) {
cerr << "cannot initialize screen" << endl;
return 1;
}
for (const auto &definition_kc : g.custom_keys)
define_key (definition_kc.first.c_str (), definition_kc.second);
load_colors ();
load_cmdline (argc, argv);