Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
184762d83a | ||
|
|
27f104b3e6 | ||
|
|
35930924a7 | ||
|
|
4a1388a5c7 | ||
|
|
92e994ebf6 | ||
|
|
245db502cc | ||
|
|
ca95bcf1d8 | ||
|
|
dd6a85f480 | ||
|
|
db8f535b61 | ||
|
|
52be0b3aab | ||
|
|
bd889a9e06 | ||
|
|
951529ebc0 | ||
|
|
0fc14e3b2d | ||
|
|
79b05dc365 | ||
|
|
c7fe60c541 | ||
|
|
ec5fac3274 | ||
|
|
90f0339fa9 | ||
|
|
e0e5977008 | ||
|
|
85a6fe95c5 | ||
|
|
55955fa5c1 | ||
|
|
993b227682 | ||
|
|
d8b9bab3ea | ||
|
|
c5297d6b6b | ||
|
|
8dd3f692b8 | ||
|
|
7e3f92f049 | ||
|
|
3efdfd3bca | ||
|
|
b101603a4a | ||
|
|
c693b7eae4 | ||
|
|
4ee6488a09 | ||
|
|
8229d972b9 | ||
|
|
6193885a55 | ||
|
|
6b1748240c |
No files matched your search
@@ -136,6 +136,30 @@ func (app *app) loop() {
|
|||||||
clientChan := app.ui.readExpr()
|
clientChan := app.ui.readExpr()
|
||||||
serverChan := readExpr()
|
serverChan := readExpr()
|
||||||
|
|
||||||
|
if gSelect != "" {
|
||||||
|
go func() {
|
||||||
|
app.ui.exprChan <- &callExpr{"select", []string{gSelect}, 1}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, path := range gConfigPaths {
|
||||||
|
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
||||||
|
app.readFile(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if gCommand != "" {
|
||||||
|
p := newParser(strings.NewReader(gCommand))
|
||||||
|
|
||||||
|
for p.parse() {
|
||||||
|
p.expr.eval(app, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.err != nil {
|
||||||
|
app.ui.printf("%s", p.err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-app.quitChan:
|
case <-app.quitChan:
|
||||||
@@ -328,12 +352,12 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
|
|
||||||
switch prefix {
|
switch prefix {
|
||||||
case "%":
|
case "%":
|
||||||
go func() {
|
|
||||||
app.cmd = cmd
|
app.cmd = cmd
|
||||||
app.cmdOutBuf = nil
|
app.cmdOutBuf = nil
|
||||||
app.ui.msg = ""
|
app.ui.msg = ""
|
||||||
app.ui.cmdPrefix = ">"
|
app.ui.cmdPrefix = ">"
|
||||||
|
|
||||||
|
go func() {
|
||||||
reader := bufio.NewReader(out)
|
reader := bufio.NewReader(out)
|
||||||
for {
|
for {
|
||||||
b, err := reader.ReadByte()
|
b, err := reader.ReadByte()
|
||||||
|
|||||||
@@ -29,16 +29,10 @@ func run() {
|
|||||||
}
|
}
|
||||||
defer termbox.Close()
|
defer termbox.Close()
|
||||||
|
|
||||||
termbox.SetOutputMode(termbox.Output256)
|
setColorMode()
|
||||||
|
|
||||||
app := newApp()
|
app := newApp()
|
||||||
|
|
||||||
for _, path := range gConfigPaths {
|
|
||||||
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
|
||||||
app.readFile(path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := app.nav.readMarks(); err != nil {
|
if err := app.nav.readMarks(); err != nil {
|
||||||
app.ui.printf("reading marks file: %s", err)
|
app.ui.printf("reading marks file: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,25 +51,25 @@ func parseColors() colorMap {
|
|||||||
return parseColorsBSD(env)
|
return parseColorsBSD(env)
|
||||||
}
|
}
|
||||||
|
|
||||||
// default values from dircolors
|
// default values from dircolors with removed background colors
|
||||||
defaultColors := []string{
|
defaultColors := []string{
|
||||||
// "rs=0",
|
// "rs=0",
|
||||||
"di=01;34",
|
"di=01;34",
|
||||||
"ln=01;36",
|
"ln=01;36",
|
||||||
// "mh=00",
|
// "mh=00",
|
||||||
"pi=40;33",
|
"pi=33", // "pi=40;33",
|
||||||
"so=01;35",
|
"so=01;35",
|
||||||
"do=01;35",
|
"do=01;35",
|
||||||
"bd=40;33;01",
|
"bd=33;01", // "bd=40;33;01",
|
||||||
"cd=40;33;01",
|
"cd=33;01", // "cd=40;33;01",
|
||||||
"or=40;31;01",
|
"or=31;01", // "or=40;31;01",
|
||||||
// "mi=00",
|
// "mi=00",
|
||||||
"su=37;41",
|
"su=01;32", // "su=37;41",
|
||||||
"sg=30;43",
|
"sg=01;32", // "sg=30;43",
|
||||||
"ca=30;41",
|
// "ca=30;41",
|
||||||
"tw=30;42",
|
"tw=01;34", // "tw=30;42",
|
||||||
"ow=34;42",
|
"ow=01;34", // "ow=34;42",
|
||||||
"st=37;44",
|
"st=01;34", // "st=37;44",
|
||||||
"ex=01;32",
|
"ex=01;32",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+28
@@ -31,6 +31,7 @@ var (
|
|||||||
"copy",
|
"copy",
|
||||||
"cut",
|
"cut",
|
||||||
"paste",
|
"paste",
|
||||||
|
"delete",
|
||||||
"clear",
|
"clear",
|
||||||
"draw",
|
"draw",
|
||||||
"redraw",
|
"redraw",
|
||||||
@@ -63,6 +64,9 @@ var (
|
|||||||
"anchorfind",
|
"anchorfind",
|
||||||
"noanchorfind",
|
"noanchorfind",
|
||||||
"anchorfind!",
|
"anchorfind!",
|
||||||
|
"color256",
|
||||||
|
"nocolor256",
|
||||||
|
"color256!",
|
||||||
"dircounts",
|
"dircounts",
|
||||||
"nodircounts",
|
"nodircounts",
|
||||||
"dircounts!",
|
"dircounts!",
|
||||||
@@ -81,6 +85,12 @@ var (
|
|||||||
"ignorecase",
|
"ignorecase",
|
||||||
"noignorecase",
|
"noignorecase",
|
||||||
"ignorecase!",
|
"ignorecase!",
|
||||||
|
"ignoredia",
|
||||||
|
"noignoredia",
|
||||||
|
"ignoredia!",
|
||||||
|
"incsearch",
|
||||||
|
"noincsearch",
|
||||||
|
"incsearch!",
|
||||||
"preview",
|
"preview",
|
||||||
"nopreview",
|
"nopreview",
|
||||||
"preview!",
|
"preview!",
|
||||||
@@ -90,9 +100,18 @@ var (
|
|||||||
"smartcase",
|
"smartcase",
|
||||||
"nosmartcase",
|
"nosmartcase",
|
||||||
"smartcase!",
|
"smartcase!",
|
||||||
|
"smartdia",
|
||||||
|
"nosmartdia",
|
||||||
|
"smartdia!",
|
||||||
"wrapscan",
|
"wrapscan",
|
||||||
"nowrapscan",
|
"nowrapscan",
|
||||||
"wrapscan!",
|
"wrapscan!",
|
||||||
|
"number",
|
||||||
|
"nonumber",
|
||||||
|
"number!",
|
||||||
|
"relativenumber",
|
||||||
|
"norelativenumber",
|
||||||
|
"relativenumber!",
|
||||||
"findlen",
|
"findlen",
|
||||||
"period",
|
"period",
|
||||||
"scrolloff",
|
"scrolloff",
|
||||||
@@ -265,6 +284,15 @@ func completeCmd(acc []rune) (matches []string, longestAcc []rune) {
|
|||||||
words = append(words, c)
|
words = append(words, c)
|
||||||
}
|
}
|
||||||
sort.Strings(words)
|
sort.Strings(words)
|
||||||
|
j := 0
|
||||||
|
for i := 1; i < len(words); i++ {
|
||||||
|
if words[j] == words[i] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
j++
|
||||||
|
words[i], words[j] = words[j], words[i]
|
||||||
|
}
|
||||||
|
words = words[:j+1]
|
||||||
matches, longest = matchWord(s, words)
|
matches, longest = matchWord(s, words)
|
||||||
longestAcc = []rune(longest)
|
longestAcc = []rune(longest)
|
||||||
case 2:
|
case 2:
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var normMap map[rune]rune
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
normMap = make(map[rune]rune)
|
||||||
|
|
||||||
|
// (not only) european
|
||||||
|
appendTransliterate(
|
||||||
|
"ěřůøĉĝĥĵŝŭèùÿėįųāēīūļķņģőűëïąćęłńśźżõșțčďĺľňŕšťýžéíñóúüåäöçîşûğăâđêôơưáàãảạ",
|
||||||
|
"eruocghjsueuyeiuaeiulkngoueiacelnszzostcdllnrstyzeinouuaaocisugaadeoouaaaaa",
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
|
||||||
|
// Vietnamese
|
||||||
|
appendTransliterate(
|
||||||
|
"áạàảãăắặằẳẵâấậầẩẫéẹèẻẽêếệềểễiíịìỉĩoóọòỏõôốộồổỗơớợờởỡúụùủũưứựừửữyýỵỳỷỹđ",
|
||||||
|
"aaaaaaaaaaaaaaaaaeeeeeeeeeeeiiiiiioooooooooooooooooouuuuuuuuuuuyyyyyyd",
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func appendTransliterate(base, norm string, uppercase bool) {
|
||||||
|
normRunes := []rune(norm)
|
||||||
|
baseRunes := []rune(base)
|
||||||
|
|
||||||
|
lenNorm := len(normRunes)
|
||||||
|
lenBase := len(baseRunes)
|
||||||
|
if lenNorm != lenBase {
|
||||||
|
panic("Base and normalized strings have differend lenght: base=" + strconv.Itoa(lenBase) + ", norm=" + strconv.Itoa(lenNorm)) // programmer error in constant lenght
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, baseRune := range baseRunes {
|
||||||
|
normMap[baseRune] = normRunes[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
if uppercase {
|
||||||
|
upperBase := strings.ToUpper(base)
|
||||||
|
upperNorm := strings.ToUpper(norm)
|
||||||
|
normRune := []rune(upperNorm)
|
||||||
|
for i, baseRune := range []rune(upperBase) {
|
||||||
|
normMap[baseRune] = normRune[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove diacritics and make lowercase.
|
||||||
|
func removeDiacritics(baseString string) string {
|
||||||
|
var normalizedRunes []rune
|
||||||
|
for _, baseRune := range []rune(baseString) {
|
||||||
|
if normRune, ok := normMap[baseRune]; ok {
|
||||||
|
normalizedRunes = append(normalizedRunes, normRune)
|
||||||
|
} else {
|
||||||
|
normalizedRunes = append(normalizedRunes, baseRune)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string(normalizedRunes)
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// typical czech test sentence ;-)
|
||||||
|
const baseTestString = "Příliš žluťoučký kůň příšerně úpěl ďábelské ódy"
|
||||||
|
|
||||||
|
func TestRemoveDiacritics(t *testing.T) {
|
||||||
|
testStr := baseTestString
|
||||||
|
expStr := "Prilis zlutoucky kun priserne upel dabelske ody"
|
||||||
|
checkRemoveDiacritics(testStr, expStr, t)
|
||||||
|
|
||||||
|
// other accents (non comlete, but all I founded)
|
||||||
|
testStr = "áéíóúýčďěňřšťžůåøĉĝĥĵŝŭšžõäöüàâçéèêëîïôùûüÿžščćđáéíóúąęėįųūčšžāēīūčšžļķņģáéíóúöüőűäöüëïąćęłńóśźżáàãâçéêíóõôăâîșțáäčďéíĺľňóôŕšťúýžáéíñóúüåäöâçîşûğăâđêôơưáàãảạ"
|
||||||
|
expStr = "aeiouycdenrstzuaocghjsuszoaouaaceeeeiiouuuyzsccdaeiouaeeiuucszaeiucszlkngaeiouououaoueiacelnoszzaaaaceeioooaaistaacdeillnoorstuyzaeinouuaaoacisugaadeoouaaaaa"
|
||||||
|
checkRemoveDiacritics(testStr, expStr, t)
|
||||||
|
|
||||||
|
testStr = "ÁÉÍÓÚÝČĎĚŇŘŠŤŽŮÅØĈĜĤĴŜŬŠŽÕÄÖÜÀÂÇÉÈÊËÎÏÔÙÛÜŸŽŠČĆĐÁÉÍÓÚĄĘĖĮŲŪČŠŽĀĒĪŪČŠŽĻĶŅĢÁÉÍÓÚÖÜŐŰÄÖÜËÏĄĆĘŁŃÓŚŹŻÁÀÃÂÇÉÊÍÓÕÔĂÂÎȘȚÁÄČĎÉÍĹĽŇÓÔŔŠŤÚÝŽÁÉÍÑÓÚÜÅÄÖÂÇÎŞÛĞĂÂĐÊÔƠƯÁÀÃẢẠ"
|
||||||
|
expStr = "AEIOUYCDENRSTZUAOCGHJSUSZOAOUAACEEEEIIOUUUYZSCCDAEIOUAEEIUUCSZAEIUCSZLKNGAEIOUOUOUAOUEIACELNOSZZAAAACEEIOOOAAISTAACDEILLNOORSTUYZAEINOUUAAOACISUGAADEOOUAAAAA"
|
||||||
|
checkRemoveDiacritics(testStr, expStr, t)
|
||||||
|
|
||||||
|
testStr = "áạàảãăắặằẳẵâấậầẩẫéẹèẻẽêếệềểễiíịìỉĩoóọòỏõôốộồổỗơớợờởỡúụùủũưứựừửữyýỵỳỷỹđ"
|
||||||
|
expStr = "aaaaaaaaaaaaaaaaaeeeeeeeeeeeiiiiiioooooooooooooooooouuuuuuuuuuuyyyyyyd"
|
||||||
|
checkRemoveDiacritics(testStr, expStr, t)
|
||||||
|
|
||||||
|
testStr = "ÁẠÀẢÃĂẮẶẰẲẴÂẤẬẦẨẪÉẸÈẺẼÊẾỆỀỂỄÍỊÌỈĨÓỌÒỎÕÔỐỘỒỔỖƠỚỢỜỞỠÚỤÙỦŨƯỨỰỪỬỮÝỴỲỶỸĐ"
|
||||||
|
expStr = "AAAAAAAAAAAAAAAAAEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYYD"
|
||||||
|
checkRemoveDiacritics(testStr, expStr, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkRemoveDiacritics(testStr string, expStr string, t *testing.T) {
|
||||||
|
resultStr := removeDiacritics(testStr)
|
||||||
|
if resultStr != expStr {
|
||||||
|
t.Errorf("at input '%v' expected '%v' but got '%v'", testStr, expStr, resultStr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSearchSettings(t *testing.T) {
|
||||||
|
runSearch(t, true, false, true, true, "Veřejný", "vere", true)
|
||||||
|
|
||||||
|
runSearch(t, true, false, true, false, baseTestString, "Zlutoucky", true)
|
||||||
|
runSearch(t, true, false, true, false, baseTestString, "zlutoucky", true)
|
||||||
|
runSearch(t, true, true, true, false, baseTestString, "Zlutoucky", false)
|
||||||
|
runSearch(t, true, true, true, true, baseTestString, "zlutoucky", true)
|
||||||
|
|
||||||
|
runSearch(t, false, false, true, false, baseTestString, "žlutoucky", true)
|
||||||
|
runSearch(t, false, false, true, false, baseTestString, "Žlutoucky", false)
|
||||||
|
|
||||||
|
runSearch(t, false, false, true, true, baseTestString, "žluťoučký", true)
|
||||||
|
runSearch(t, false, false, true, false, baseTestString, "žluťoučký", true)
|
||||||
|
runSearch(t, false, false, false, false, baseTestString, "žluťoučký", true)
|
||||||
|
runSearch(t, false, false, false, false, baseTestString, "zlutoucky", false)
|
||||||
|
runSearch(t, false, false, true, true, baseTestString, "zlutoucky", true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func runSearch(t *testing.T, ignorecase, smartcase, ignorediacritics, smartdiacritics bool, base, pattern string, expected bool) {
|
||||||
|
gOpts.ignorecase = ignorecase
|
||||||
|
gOpts.smartcase = smartcase
|
||||||
|
gOpts.ignoredia = ignorediacritics
|
||||||
|
gOpts.smartdia = smartdiacritics
|
||||||
|
matched, _ := searchMatch(base, pattern)
|
||||||
|
if matched != expected {
|
||||||
|
t.Errorf("False search for" +
|
||||||
|
" ignorecase = " + strconv.FormatBool(gOpts.ignorecase) + ", " +
|
||||||
|
" smartcase = " + strconv.FormatBool(gOpts.smartcase) + ", " +
|
||||||
|
" ignoredia = " + strconv.FormatBool(gOpts.ignoredia) + ", " +
|
||||||
|
" smartdia = " + strconv.FormatBool(gOpts.smartdia) + ", ")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -61,7 +61,8 @@ The following commands are provided by lf without default keybindings:
|
|||||||
cd changes working directory to its argument
|
cd changes working directory to its argument
|
||||||
select changes current file selection to its argument
|
select changes current file selection to its argument
|
||||||
source reads the configuration file in its argument
|
source reads the configuration file in its argument
|
||||||
push simulate key pushes given in its argument
|
push simulates key pushes given in its argument
|
||||||
|
delete deletes the current file or selected file(s)
|
||||||
|
|
||||||
The following command line commands are provided by lf with default
|
The following command line commands are provided by lf with default
|
||||||
keybindings:
|
keybindings:
|
||||||
@@ -94,16 +95,22 @@ keybindings:
|
|||||||
The following options can be used to customize the behavior of lf:
|
The following options can be used to customize the behavior of lf:
|
||||||
|
|
||||||
anchorfind boolean (default on)
|
anchorfind boolean (default on)
|
||||||
|
color256 boolean (default off)
|
||||||
dircounts boolean (default off)
|
dircounts boolean (default off)
|
||||||
dirfirst boolean (default on)
|
dirfirst boolean (default on)
|
||||||
drawbox boolean (default off)
|
drawbox boolean (default off)
|
||||||
globsearch boolean (default off)
|
globsearch boolean (default off)
|
||||||
hidden boolean (default off)
|
hidden boolean (default off)
|
||||||
ignorecase boolean (default on)
|
ignorecase boolean (default on)
|
||||||
|
ignoredia boolean (default off)
|
||||||
|
incsearch boolean (default off)
|
||||||
preview boolean (default on)
|
preview boolean (default on)
|
||||||
reverse boolean (default off)
|
reverse boolean (default off)
|
||||||
smartcase boolean (default on)
|
smartcase boolean (default on)
|
||||||
|
smartdia boolean (default off)
|
||||||
wrapscan boolean (default on)
|
wrapscan boolean (default on)
|
||||||
|
number boolean (default off)
|
||||||
|
relativenumber boolean (default off)
|
||||||
findlen integer (default 1) (zero to prompt until single match)
|
findlen integer (default 1) (zero to prompt until single match)
|
||||||
period integer (default 0) (zero to disable periodic loading)
|
period integer (default 0) (zero to disable periodic loading)
|
||||||
scrolloff integer (default 0)
|
scrolloff integer (default 0)
|
||||||
@@ -538,17 +545,50 @@ commands if they support it (i.e. GNU implementation), change the command type
|
|||||||
to asynchronous, or use 'rsync' command with progress bar option for copying
|
to asynchronous, or use 'rsync' command with progress bar option for copying
|
||||||
and feed the progress to the client periodically with remote 'echo' calls.
|
and feed the progress to the client periodically with remote 'echo' calls.
|
||||||
|
|
||||||
By default, lf does not provide an actual file deletion command to protect new
|
By default, lf does not assign 'delete' command to a key to protect new users.
|
||||||
users. You can define such a command and optionally assign a key if you like.
|
You can customize file deletion by defining a 'delete' command. You can also
|
||||||
An example command to move selected files to a trash folder and remove files
|
assign a key to this command if you like. An example command to move selected
|
||||||
completely are provided in the example configuration file.
|
files to a trash folder and remove files completely after a prompt are provided
|
||||||
|
in the example configuration file.
|
||||||
|
|
||||||
|
Searching Files
|
||||||
|
|
||||||
|
There are two mechanisms implemented in lf to search a file in the current
|
||||||
|
directory. Searching is the traditional method to move the selection to a file
|
||||||
|
matching a given pattern. Finding is an alternative way to search for a pattern
|
||||||
|
possibly using fewer keystrokes.
|
||||||
|
|
||||||
|
Searching mechanism is implemented with commands 'search' (default '/'),
|
||||||
|
'search-back' (default '?'), 'search-next' (default 'n'), and 'search-prev'
|
||||||
|
(default 'N'). You can enable 'globsearch' option to match with a glob pattern.
|
||||||
|
Globbing supports '*' to match any sequence, '?' to match any character, and
|
||||||
|
'[...]' or '[^...] to match character sets or ranges. You can enable
|
||||||
|
'incsearch' option to jump to the current match at each keystroke while typing.
|
||||||
|
In this mode, you can either use 'cmd-enter' to accept the search or use
|
||||||
|
'cmd-escape' to cancel the search.
|
||||||
|
|
||||||
|
Finding mechanism is implemented with commands 'find' (default 'f'),
|
||||||
|
'find-back' (default 'F'), 'find-next' (default ';'), 'find-prev' (default
|
||||||
|
','). You can disable 'anchorfind' option to match a pattern at an arbitrary
|
||||||
|
position in the filename instead of the beginning. You can set the number of
|
||||||
|
keys to match using 'findlen' option. If you set this value to zero, then the
|
||||||
|
the keys are read until there is only a single match. Default values of these
|
||||||
|
two options are set to jump to the first file with the given initial.
|
||||||
|
|
||||||
|
Some options effect both searching and finding. You can disable 'wrapscan'
|
||||||
|
option to prevent searches to wrap around at the end of the file list. You can
|
||||||
|
disable 'ignorecase' option to match cases in the pattern and the filename.
|
||||||
|
This option is already automatically overridden if the pattern contains upper
|
||||||
|
case characters. You can disable 'smartcase' option to disable this behavior.
|
||||||
|
Two similar options 'ignoredia' and 'smartdia' are provided to control matching
|
||||||
|
diacritics in latin letters.
|
||||||
|
|
||||||
Opening Files
|
Opening Files
|
||||||
|
|
||||||
You can define a an 'open' command (default 'l') to configure file opening.
|
You can define a an 'open' command (default 'l' and '<right>') to configure
|
||||||
This command is only called when the current file is not a directory, otherwise
|
file opening. This command is only called when the current file is not a
|
||||||
the directory is entered instead. You can define it just as you would define
|
directory, otherwise the directory is entered instead. You can define it just
|
||||||
any other command:
|
as you would define any other command:
|
||||||
|
|
||||||
cmd open $vi $fx
|
cmd open $vi $fx
|
||||||
|
|
||||||
@@ -634,6 +674,13 @@ If both of these environment variables are not set, then lf fallbacks to its
|
|||||||
default colorscheme. Default lf colors are taken from GNU dircolors defaults.
|
default colorscheme. Default lf colors are taken from GNU dircolors defaults.
|
||||||
These defaults use 8 basic colors and bold attribute.
|
These defaults use 8 basic colors and bold attribute.
|
||||||
|
|
||||||
|
You should also note that lf uses 8 color mode by default which uses sgr 3-bit
|
||||||
|
color escapes (e.g. '\033[34m'). If you want to use 256 colors, you need to
|
||||||
|
enable 'color256' option which then makes lf use sgr 8-bit color escapes (e.g.
|
||||||
|
'\033[38;5;4m'). This option is intended to eliminate differences between
|
||||||
|
default colors used by ls and lf since terminals may render 3-bit and 8-bit
|
||||||
|
escapes differently even for the same color.
|
||||||
|
|
||||||
Keeping this mechanism in mind, you can configure lf colors in two different
|
Keeping this mechanism in mind, you can configure lf colors in two different
|
||||||
ways. First, you can configure 8 basic colors used by your terminal and lf
|
ways. First, you can configure 8 basic colors used by your terminal and lf
|
||||||
should pick up those colors automatically. Depending on your terminal, you
|
should pick up those colors automatically. Depending on your terminal, you
|
||||||
@@ -646,5 +693,10 @@ fine grained customization. This is useful to change colors used for different
|
|||||||
file types and extensions. '$LS_COLORS' is more powerful than '$LSCOLORS' and
|
file types and extensions. '$LS_COLORS' is more powerful than '$LSCOLORS' and
|
||||||
it can be used even when GNU programs are not installed on the system. You can
|
it can be used even when GNU programs are not installed on the system. You can
|
||||||
combine this second method with the first method for best results.
|
combine this second method with the first method for best results.
|
||||||
|
|
||||||
|
Lastly, you may also want to configure the colors of the prompt line to match
|
||||||
|
the rest of the colors. Colors of the prompt line can be configured using the
|
||||||
|
'promptfmt' option which can include hardcoded colors as ansi escapes. See the
|
||||||
|
default value of this option to have an idea about how to color this line.
|
||||||
*/
|
*/
|
||||||
package main
|
package main
|
||||||
+63
-9
@@ -64,7 +64,8 @@ The following commands are provided by lf without default keybindings:
|
|||||||
cd changes working directory to its argument
|
cd changes working directory to its argument
|
||||||
select changes current file selection to its argument
|
select changes current file selection to its argument
|
||||||
source reads the configuration file in its argument
|
source reads the configuration file in its argument
|
||||||
push simulate key pushes given in its argument
|
push simulates key pushes given in its argument
|
||||||
|
delete deletes the current file or selected file(s)
|
||||||
|
|
||||||
The following command line commands are provided by lf with default
|
The following command line commands are provided by lf with default
|
||||||
keybindings:
|
keybindings:
|
||||||
@@ -97,16 +98,22 @@ keybindings:
|
|||||||
The following options can be used to customize the behavior of lf:
|
The following options can be used to customize the behavior of lf:
|
||||||
|
|
||||||
anchorfind boolean (default on)
|
anchorfind boolean (default on)
|
||||||
|
color256 boolean (default off)
|
||||||
dircounts boolean (default off)
|
dircounts boolean (default off)
|
||||||
dirfirst boolean (default on)
|
dirfirst boolean (default on)
|
||||||
drawbox boolean (default off)
|
drawbox boolean (default off)
|
||||||
globsearch boolean (default off)
|
globsearch boolean (default off)
|
||||||
hidden boolean (default off)
|
hidden boolean (default off)
|
||||||
ignorecase boolean (default on)
|
ignorecase boolean (default on)
|
||||||
|
ignoredia boolean (default off)
|
||||||
|
incsearch boolean (default off)
|
||||||
preview boolean (default on)
|
preview boolean (default on)
|
||||||
reverse boolean (default off)
|
reverse boolean (default off)
|
||||||
smartcase boolean (default on)
|
smartcase boolean (default on)
|
||||||
|
smartdia boolean (default off)
|
||||||
wrapscan boolean (default on)
|
wrapscan boolean (default on)
|
||||||
|
number boolean (default off)
|
||||||
|
relativenumber boolean (default off)
|
||||||
findlen integer (default 1) (zero to prompt until single match)
|
findlen integer (default 1) (zero to prompt until single match)
|
||||||
period integer (default 0) (zero to disable periodic loading)
|
period integer (default 0) (zero to disable periodic loading)
|
||||||
scrolloff integer (default 0)
|
scrolloff integer (default 0)
|
||||||
@@ -561,18 +568,52 @@ command type to asynchronous, or use 'rsync' command with progress bar
|
|||||||
option for copying and feed the progress to the client periodically with
|
option for copying and feed the progress to the client periodically with
|
||||||
remote 'echo' calls.
|
remote 'echo' calls.
|
||||||
|
|
||||||
By default, lf does not provide an actual file deletion command to protect
|
By default, lf does not assign 'delete' command to a key to protect new
|
||||||
new users. You can define such a command and optionally assign a key if you
|
users. You can customize file deletion by defining a 'delete' command. You
|
||||||
like. An example command to move selected files to a trash folder and remove
|
can also assign a key to this command if you like. An example command to
|
||||||
files completely are provided in the example configuration file.
|
move selected files to a trash folder and remove files completely after a
|
||||||
|
prompt are provided in the example configuration file.
|
||||||
|
|
||||||
|
|
||||||
|
Searching Files
|
||||||
|
|
||||||
|
There are two mechanisms implemented in lf to search a file in the current
|
||||||
|
directory. Searching is the traditional method to move the selection to a
|
||||||
|
file matching a given pattern. Finding is an alternative way to search for a
|
||||||
|
pattern possibly using fewer keystrokes.
|
||||||
|
|
||||||
|
Searching mechanism is implemented with commands 'search' (default '/'),
|
||||||
|
'search-back' (default '?'), 'search-next' (default 'n'), and 'search-prev'
|
||||||
|
(default 'N'). You can enable 'globsearch' option to match with a glob
|
||||||
|
pattern. Globbing supports '*' to match any sequence, '?' to match any
|
||||||
|
character, and '[...]' or '[^...] to match character sets or ranges. You can
|
||||||
|
enable 'incsearch' option to jump to the current match at each keystroke
|
||||||
|
while typing. In this mode, you can either use 'cmd-enter' to accept the
|
||||||
|
search or use 'cmd-escape' to cancel the search.
|
||||||
|
|
||||||
|
Finding mechanism is implemented with commands 'find' (default 'f'),
|
||||||
|
'find-back' (default 'F'), 'find-next' (default ';'), 'find-prev' (default
|
||||||
|
','). You can disable 'anchorfind' option to match a pattern at an arbitrary
|
||||||
|
position in the filename instead of the beginning. You can set the number of
|
||||||
|
keys to match using 'findlen' option. If you set this value to zero, then
|
||||||
|
the the keys are read until there is only a single match. Default values of
|
||||||
|
these two options are set to jump to the first file with the given initial.
|
||||||
|
|
||||||
|
Some options effect both searching and finding. You can disable 'wrapscan'
|
||||||
|
option to prevent searches to wrap around at the end of the file list. You
|
||||||
|
can disable 'ignorecase' option to match cases in the pattern and the
|
||||||
|
filename. This option is already automatically overridden if the pattern
|
||||||
|
contains upper case characters. You can disable 'smartcase' option to
|
||||||
|
disable this behavior. Two similar options 'ignoredia' and 'smartdia' are
|
||||||
|
provided to control matching diacritics in latin letters.
|
||||||
|
|
||||||
|
|
||||||
Opening Files
|
Opening Files
|
||||||
|
|
||||||
You can define a an 'open' command (default 'l') to configure file opening.
|
You can define a an 'open' command (default 'l' and '<right>') to configure
|
||||||
This command is only called when the current file is not a directory,
|
file opening. This command is only called when the current file is not a
|
||||||
otherwise the directory is entered instead. You can define it just as you
|
directory, otherwise the directory is entered instead. You can define it
|
||||||
would define any other command:
|
just as you would define any other command:
|
||||||
|
|
||||||
cmd open $vi $fx
|
cmd open $vi $fx
|
||||||
|
|
||||||
@@ -664,6 +705,13 @@ If both of these environment variables are not set, then lf fallbacks to its
|
|||||||
default colorscheme. Default lf colors are taken from GNU dircolors
|
default colorscheme. Default lf colors are taken from GNU dircolors
|
||||||
defaults. These defaults use 8 basic colors and bold attribute.
|
defaults. These defaults use 8 basic colors and bold attribute.
|
||||||
|
|
||||||
|
You should also note that lf uses 8 color mode by default which uses sgr
|
||||||
|
3-bit color escapes (e.g. '\033[34m'). If you want to use 256 colors, you
|
||||||
|
need to enable 'color256' option which then makes lf use sgr 8-bit color
|
||||||
|
escapes (e.g. '\033[38;5;4m'). This option is intended to eliminate
|
||||||
|
differences between default colors used by ls and lf since terminals may
|
||||||
|
render 3-bit and 8-bit escapes differently even for the same color.
|
||||||
|
|
||||||
Keeping this mechanism in mind, you can configure lf colors in two different
|
Keeping this mechanism in mind, you can configure lf colors in two different
|
||||||
ways. First, you can configure 8 basic colors used by your terminal and lf
|
ways. First, you can configure 8 basic colors used by your terminal and lf
|
||||||
should pick up those colors automatically. Depending on your terminal, you
|
should pick up those colors automatically. Depending on your terminal, you
|
||||||
@@ -677,4 +725,10 @@ different file types and extensions. '$LS_COLORS' is more powerful than
|
|||||||
'$LSCOLORS' and it can be used even when GNU programs are not installed on
|
'$LSCOLORS' and it can be used even when GNU programs are not installed on
|
||||||
the system. You can combine this second method with the first method for
|
the system. You can combine this second method with the first method for
|
||||||
best results.
|
best results.
|
||||||
|
|
||||||
|
Lastly, you may also want to configure the colors of the prompt line to
|
||||||
|
match the rest of the colors. Colors of the prompt line can be configured
|
||||||
|
using the 'promptfmt' option which can include hardcoded colors as ansi
|
||||||
|
escapes. See the default value of this option to have an idea about how to
|
||||||
|
color this line.
|
||||||
`
|
`
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
# Autocompletion for Fish shell
|
||||||
|
# Put this file somewhere in $fish_complete_path
|
||||||
|
# for example in ~/.config/fish/completions/
|
||||||
|
|
||||||
|
complete -c lf -o cpuprofile -r -d 'path to the file to write the CPU profile'
|
||||||
|
complete -c lf -o doc -d 'show documentation'
|
||||||
|
complete -c lf -o last-dir-path -r -d 'path to the file to write the last dir on exit (to use for cd)'
|
||||||
|
complete -c lf -o memprofile -r -d 'path to the file to write the memory profile'
|
||||||
|
complete -c lf -o remote -x -d 'send remote command to server'
|
||||||
|
complete -c lf -o selection-path -r -d 'path to the file to write selected files on open (to use as open file dialog)'
|
||||||
|
complete -c lf -o server -d 'start server (automatic)'
|
||||||
|
complete -c lf -o version -d 'show version'
|
||||||
|
complete -c lf -s h -d "short help"
|
||||||
@@ -20,6 +20,21 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
gOpts.anchorfind = false
|
gOpts.anchorfind = false
|
||||||
case "anchorfind!":
|
case "anchorfind!":
|
||||||
gOpts.anchorfind = !gOpts.anchorfind
|
gOpts.anchorfind = !gOpts.anchorfind
|
||||||
|
case "color256":
|
||||||
|
gOpts.color256 = true
|
||||||
|
setColorMode()
|
||||||
|
app.ui.pause()
|
||||||
|
app.ui.resume()
|
||||||
|
case "nocolor256":
|
||||||
|
gOpts.color256 = false
|
||||||
|
setColorMode()
|
||||||
|
app.ui.pause()
|
||||||
|
app.ui.resume()
|
||||||
|
case "color256!":
|
||||||
|
gOpts.color256 = !gOpts.color256
|
||||||
|
setColorMode()
|
||||||
|
app.ui.pause()
|
||||||
|
app.ui.resume()
|
||||||
case "dircounts":
|
case "dircounts":
|
||||||
gOpts.dircounts = true
|
gOpts.dircounts = true
|
||||||
case "nodircounts":
|
case "nodircounts":
|
||||||
@@ -80,6 +95,18 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
gOpts.ignorecase = false
|
gOpts.ignorecase = false
|
||||||
case "ignorecase!":
|
case "ignorecase!":
|
||||||
gOpts.ignorecase = !gOpts.ignorecase
|
gOpts.ignorecase = !gOpts.ignorecase
|
||||||
|
case "ignoredia":
|
||||||
|
gOpts.ignoredia = true
|
||||||
|
case "noignoredia":
|
||||||
|
gOpts.ignoredia = false
|
||||||
|
case "ignoredia!":
|
||||||
|
gOpts.ignoredia = !gOpts.ignoredia
|
||||||
|
case "incsearch":
|
||||||
|
gOpts.incsearch = true
|
||||||
|
case "noincsearch":
|
||||||
|
gOpts.incsearch = false
|
||||||
|
case "incsearch!":
|
||||||
|
gOpts.incsearch = !gOpts.incsearch
|
||||||
case "preview":
|
case "preview":
|
||||||
gOpts.preview = true
|
gOpts.preview = true
|
||||||
case "nopreview":
|
case "nopreview":
|
||||||
@@ -104,12 +131,30 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
gOpts.smartcase = false
|
gOpts.smartcase = false
|
||||||
case "smartcase!":
|
case "smartcase!":
|
||||||
gOpts.smartcase = !gOpts.smartcase
|
gOpts.smartcase = !gOpts.smartcase
|
||||||
|
case "smartdia":
|
||||||
|
gOpts.smartdia = true
|
||||||
|
case "nosmartdia":
|
||||||
|
gOpts.smartdia = false
|
||||||
|
case "smartdia!":
|
||||||
|
gOpts.smartdia = !gOpts.smartdia
|
||||||
case "wrapscan":
|
case "wrapscan":
|
||||||
gOpts.wrapscan = true
|
gOpts.wrapscan = true
|
||||||
case "nowrapscan":
|
case "nowrapscan":
|
||||||
gOpts.wrapscan = false
|
gOpts.wrapscan = false
|
||||||
case "wrapscan!":
|
case "wrapscan!":
|
||||||
gOpts.wrapscan = !gOpts.wrapscan
|
gOpts.wrapscan = !gOpts.wrapscan
|
||||||
|
case "number":
|
||||||
|
gOpts.number = true
|
||||||
|
case "nonumber":
|
||||||
|
gOpts.number = false
|
||||||
|
case "number!":
|
||||||
|
gOpts.number = !gOpts.number
|
||||||
|
case "relativenumber":
|
||||||
|
gOpts.relativenumber = true
|
||||||
|
case "norelativenumber":
|
||||||
|
gOpts.relativenumber = false
|
||||||
|
case "relativenumber!":
|
||||||
|
gOpts.relativenumber = !gOpts.relativenumber
|
||||||
case "findlen":
|
case "findlen":
|
||||||
n, err := strconv.Atoi(e.val)
|
n, err := strconv.Atoi(e.val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -270,9 +315,59 @@ func splitKeys(s string) (keys []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func update(app *app) {
|
||||||
|
switch {
|
||||||
|
case gOpts.incsearch && app.ui.cmdPrefix == "/":
|
||||||
|
app.nav.search = string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
|
||||||
|
|
||||||
|
last := app.nav.currDir()
|
||||||
|
last.ind = app.nav.searchInd
|
||||||
|
last.pos = app.nav.searchPos
|
||||||
|
|
||||||
|
if app.nav.searchBack {
|
||||||
|
if err := app.nav.searchPrev(); err != nil {
|
||||||
|
app.ui.printf("search-back: %s: %s", err, app.nav.search)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := app.nav.searchNext(); err != nil {
|
||||||
|
app.ui.printf("search: %s: %s", err, app.nav.search)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
app.ui.loadFile(app.nav)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
case gOpts.incsearch && app.ui.cmdPrefix == "?":
|
||||||
|
app.nav.search = string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
|
||||||
|
|
||||||
|
last := app.nav.currDir()
|
||||||
|
last.ind = app.nav.searchInd
|
||||||
|
last.pos = app.nav.searchPos
|
||||||
|
|
||||||
|
if app.nav.searchBack {
|
||||||
|
if err := app.nav.searchNext(); err != nil {
|
||||||
|
app.ui.printf("search-back: %s: %s", err, app.nav.search)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := app.nav.searchPrev(); err != nil {
|
||||||
|
app.ui.printf("search: %s: %s", err, app.nav.search)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
app.ui.loadFile(app.nav)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func insert(app *app, arg string) {
|
func insert(app *app, arg string) {
|
||||||
switch app.ui.cmdPrefix {
|
switch {
|
||||||
case "find: ":
|
case gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?"):
|
||||||
|
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...)
|
||||||
|
update(app)
|
||||||
|
case app.ui.cmdPrefix == "find: ":
|
||||||
app.nav.find = string(app.ui.cmdAccLeft) + arg + string(app.ui.cmdAccRight)
|
app.nav.find = string(app.ui.cmdAccLeft) + arg + string(app.ui.cmdAccRight)
|
||||||
|
|
||||||
if gOpts.findlen == 0 {
|
if gOpts.findlen == 0 {
|
||||||
@@ -304,7 +399,7 @@ func insert(app *app, arg string) {
|
|||||||
app.ui.cmdAccLeft = nil
|
app.ui.cmdAccLeft = nil
|
||||||
app.ui.cmdAccRight = nil
|
app.ui.cmdAccRight = nil
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
case "find-back: ":
|
case app.ui.cmdPrefix == "find-back: ":
|
||||||
app.nav.find = string(app.ui.cmdAccLeft) + arg + string(app.ui.cmdAccRight)
|
app.nav.find = string(app.ui.cmdAccLeft) + arg + string(app.ui.cmdAccRight)
|
||||||
|
|
||||||
if gOpts.findlen == 0 {
|
if gOpts.findlen == 0 {
|
||||||
@@ -336,7 +431,23 @@ func insert(app *app, arg string) {
|
|||||||
app.ui.cmdAccLeft = nil
|
app.ui.cmdAccLeft = nil
|
||||||
app.ui.cmdAccRight = nil
|
app.ui.cmdAccRight = nil
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
case "mark-save: ":
|
case app.ui.cmdPrefix == "delete?[y/N]: ":
|
||||||
|
app.ui.menuBuf = nil
|
||||||
|
app.ui.cmdAccLeft = nil
|
||||||
|
app.ui.cmdAccRight = nil
|
||||||
|
app.ui.cmdPrefix = ""
|
||||||
|
|
||||||
|
if arg == "y" {
|
||||||
|
if err := app.nav.del(); err != nil {
|
||||||
|
app.ui.printf("delete: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
app.nav.unselect()
|
||||||
|
if err := sendRemote("send load"); err != nil {
|
||||||
|
app.ui.printf("delete: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case app.ui.cmdPrefix == "mark-save: ":
|
||||||
app.ui.menuBuf = nil
|
app.ui.menuBuf = nil
|
||||||
app.ui.cmdAccLeft = nil
|
app.ui.cmdAccLeft = nil
|
||||||
app.ui.cmdAccRight = nil
|
app.ui.cmdAccRight = nil
|
||||||
@@ -348,7 +459,7 @@ func insert(app *app, arg string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.nav.marks[arg] = wd
|
app.nav.marks[arg] = wd
|
||||||
case "mark-load: ":
|
case app.ui.cmdPrefix == "mark-load: ":
|
||||||
app.ui.menuBuf = nil
|
app.ui.menuBuf = nil
|
||||||
app.ui.cmdAccLeft = nil
|
app.ui.cmdAccLeft = nil
|
||||||
app.ui.cmdAccRight = nil
|
app.ui.cmdAccRight = nil
|
||||||
@@ -441,11 +552,8 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
defer out.Close()
|
defer out.Close()
|
||||||
|
|
||||||
var path string
|
var path string
|
||||||
if len(app.nav.selections) != 0 {
|
if list, err := app.nav.currFileOrSelections(); err == nil {
|
||||||
selections := app.nav.currSelections()
|
path = strings.Join(list, "\n")
|
||||||
path = strings.Join(selections, "\n")
|
|
||||||
} else if curr, err := app.nav.currFile(); err == nil {
|
|
||||||
path = curr.path
|
|
||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -514,6 +622,20 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
if err := sendRemote("send sync"); err != nil {
|
if err := sendRemote("send sync"); err != nil {
|
||||||
app.ui.printf("paste: %s", err)
|
app.ui.printf("paste: %s", err)
|
||||||
}
|
}
|
||||||
|
case "delete":
|
||||||
|
if cmd, ok := gOpts.cmds["delete"]; ok {
|
||||||
|
cmd.eval(app, e.args)
|
||||||
|
app.nav.unselect()
|
||||||
|
if err := sendRemote("send load"); err != nil {
|
||||||
|
app.ui.printf("delete: %s", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if _, err := app.nav.currFileOrSelections(); err != nil {
|
||||||
|
app.ui.printf("delete: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
app.ui.cmdPrefix = "delete?[y/N]: "
|
||||||
|
}
|
||||||
case "clear":
|
case "clear":
|
||||||
if err := saveFiles(nil, false); err != nil {
|
if err := saveFiles(nil, false); err != nil {
|
||||||
app.ui.printf("clear: %s", err)
|
app.ui.printf("clear: %s", err)
|
||||||
@@ -571,9 +693,15 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "search":
|
case "search":
|
||||||
app.ui.cmdPrefix = "/"
|
app.ui.cmdPrefix = "/"
|
||||||
|
last := app.nav.currDir()
|
||||||
|
app.nav.searchInd = last.ind
|
||||||
|
app.nav.searchPos = last.pos
|
||||||
app.nav.searchBack = false
|
app.nav.searchBack = false
|
||||||
case "search-back":
|
case "search-back":
|
||||||
app.ui.cmdPrefix = "?"
|
app.ui.cmdPrefix = "?"
|
||||||
|
last := app.nav.currDir()
|
||||||
|
app.nav.searchInd = last.ind
|
||||||
|
app.nav.searchPos = last.pos
|
||||||
app.nav.searchBack = true
|
app.nav.searchBack = true
|
||||||
case "search-next":
|
case "search-next":
|
||||||
for i := 0; i < e.count; i++ {
|
for i := 0; i < e.count; i++ {
|
||||||
@@ -699,6 +827,14 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
if app.ui.cmdPrefix == ">" {
|
if app.ui.cmdPrefix == ">" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?") {
|
||||||
|
last := app.nav.currDir()
|
||||||
|
last.ind = app.nav.searchInd
|
||||||
|
last.pos = app.nav.searchPos
|
||||||
|
|
||||||
|
app.ui.loadFile(app.nav)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
app.ui.menuBuf = nil
|
app.ui.menuBuf = nil
|
||||||
app.ui.cmdAccLeft = nil
|
app.ui.cmdAccLeft = nil
|
||||||
app.ui.cmdAccRight = nil
|
app.ui.cmdAccRight = nil
|
||||||
@@ -727,6 +863,8 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
switch app.ui.cmdPrefix {
|
switch app.ui.cmdPrefix {
|
||||||
case ":":
|
case ":":
|
||||||
log.Printf("command: %s", s)
|
log.Printf("command: %s", s)
|
||||||
|
app.ui.cmdPrefix = ""
|
||||||
|
app.cmdHistory = append(app.cmdHistory, cmdItem{":", s})
|
||||||
p := newParser(strings.NewReader(s))
|
p := newParser(strings.NewReader(s))
|
||||||
for p.parse() {
|
for p.parse() {
|
||||||
p.expr.eval(app, nil)
|
p.expr.eval(app, nil)
|
||||||
@@ -734,32 +872,36 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
if p.err != nil {
|
if p.err != nil {
|
||||||
app.ui.printf("%s", p.err)
|
app.ui.printf("%s", p.err)
|
||||||
}
|
}
|
||||||
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
|
||||||
app.ui.cmdPrefix = ""
|
|
||||||
case "$":
|
case "$":
|
||||||
log.Printf("shell: %s", s)
|
log.Printf("shell: %s", s)
|
||||||
app.runShell(s, nil, app.ui.cmdPrefix)
|
|
||||||
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
|
app.cmdHistory = append(app.cmdHistory, cmdItem{"$", s})
|
||||||
|
app.runShell(s, nil, "$")
|
||||||
case "%":
|
case "%":
|
||||||
log.Printf("shell-pipe: %s", s)
|
log.Printf("shell-pipe: %s", s)
|
||||||
app.runShell(s, nil, app.ui.cmdPrefix)
|
app.cmdHistory = append(app.cmdHistory, cmdItem{"%", s})
|
||||||
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
app.runShell(s, nil, "%")
|
||||||
case ">":
|
case ">":
|
||||||
io.WriteString(app.cmdIn, s+"\n")
|
io.WriteString(app.cmdIn, s+"\n")
|
||||||
app.cmdOutBuf = nil
|
app.cmdOutBuf = nil
|
||||||
case "!":
|
case "!":
|
||||||
log.Printf("shell-wait: %s", s)
|
log.Printf("shell-wait: %s", s)
|
||||||
app.runShell(s, nil, app.ui.cmdPrefix)
|
|
||||||
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
|
app.cmdHistory = append(app.cmdHistory, cmdItem{"!", s})
|
||||||
|
app.runShell(s, nil, "!")
|
||||||
case "&":
|
case "&":
|
||||||
log.Printf("shell-async: %s", s)
|
log.Printf("shell-async: %s", s)
|
||||||
app.runShell(s, nil, app.ui.cmdPrefix)
|
|
||||||
app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
|
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
|
app.cmdHistory = append(app.cmdHistory, cmdItem{"&", s})
|
||||||
|
app.runShell(s, nil, "&")
|
||||||
case "/":
|
case "/":
|
||||||
|
if gOpts.incsearch {
|
||||||
|
last := app.nav.currDir()
|
||||||
|
last.ind = app.nav.searchInd
|
||||||
|
last.pos = app.nav.searchPos
|
||||||
|
}
|
||||||
log.Printf("search: %s", s)
|
log.Printf("search: %s", s)
|
||||||
|
app.ui.cmdPrefix = ""
|
||||||
app.nav.search = s
|
app.nav.search = s
|
||||||
if err := app.nav.searchNext(); err != nil {
|
if err := app.nav.searchNext(); err != nil {
|
||||||
app.ui.printf("search: %s: %s", err, app.nav.search)
|
app.ui.printf("search: %s: %s", err, app.nav.search)
|
||||||
@@ -767,9 +909,14 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFile(app.nav)
|
app.ui.loadFile(app.nav)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
app.ui.cmdPrefix = ""
|
|
||||||
case "?":
|
case "?":
|
||||||
|
if gOpts.incsearch {
|
||||||
|
last := app.nav.currDir()
|
||||||
|
last.ind = app.nav.searchInd
|
||||||
|
last.pos = app.nav.searchPos
|
||||||
|
}
|
||||||
log.Printf("search-back: %s", s)
|
log.Printf("search-back: %s", s)
|
||||||
|
app.ui.cmdPrefix = ""
|
||||||
app.nav.search = s
|
app.nav.search = s
|
||||||
if err := app.nav.searchPrev(); err != nil {
|
if err := app.nav.searchPrev(); err != nil {
|
||||||
app.ui.printf("search-back: %s: %s", err, app.nav.search)
|
app.ui.printf("search-back: %s: %s", err, app.nav.search)
|
||||||
@@ -777,7 +924,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFile(app.nav)
|
app.ui.loadFile(app.nav)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
app.ui.cmdPrefix = ""
|
|
||||||
default:
|
default:
|
||||||
log.Printf("entering unknown execution prefix: %q", app.ui.cmdPrefix)
|
log.Printf("entering unknown execution prefix: %q", app.ui.cmdPrefix)
|
||||||
}
|
}
|
||||||
@@ -821,11 +967,13 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.ui.cmdAccRight = app.ui.cmdAccRight[1:]
|
app.ui.cmdAccRight = app.ui.cmdAccRight[1:]
|
||||||
|
update(app)
|
||||||
case "cmd-delete-back":
|
case "cmd-delete-back":
|
||||||
if len(app.ui.cmdAccLeft) == 0 {
|
if len(app.ui.cmdAccLeft) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.ui.cmdAccLeft = app.ui.cmdAccLeft[:len(app.ui.cmdAccLeft)-1]
|
app.ui.cmdAccLeft = app.ui.cmdAccLeft[:len(app.ui.cmdAccLeft)-1]
|
||||||
|
update(app)
|
||||||
case "cmd-left":
|
case "cmd-left":
|
||||||
if len(app.ui.cmdAccLeft) == 0 {
|
if len(app.ui.cmdAccLeft) == 0 {
|
||||||
return
|
return
|
||||||
@@ -850,23 +998,28 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
app.ui.cmdYankBuf = app.ui.cmdAccLeft
|
app.ui.cmdYankBuf = app.ui.cmdAccLeft
|
||||||
app.ui.cmdAccLeft = nil
|
app.ui.cmdAccLeft = nil
|
||||||
|
update(app)
|
||||||
case "cmd-delete-end":
|
case "cmd-delete-end":
|
||||||
if len(app.ui.cmdAccRight) == 0 {
|
if len(app.ui.cmdAccRight) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.ui.cmdYankBuf = app.ui.cmdAccRight
|
app.ui.cmdYankBuf = app.ui.cmdAccRight
|
||||||
app.ui.cmdAccRight = nil
|
app.ui.cmdAccRight = nil
|
||||||
|
update(app)
|
||||||
case "cmd-delete-unix-word":
|
case "cmd-delete-unix-word":
|
||||||
ind := strings.LastIndex(strings.TrimRight(string(app.ui.cmdAccLeft), " "), " ") + 1
|
ind := strings.LastIndex(strings.TrimRight(string(app.ui.cmdAccLeft), " "), " ") + 1
|
||||||
app.ui.cmdYankBuf = app.ui.cmdAccLeft[ind:]
|
app.ui.cmdYankBuf = app.ui.cmdAccLeft[ind:]
|
||||||
app.ui.cmdAccLeft = app.ui.cmdAccLeft[:ind]
|
app.ui.cmdAccLeft = app.ui.cmdAccLeft[:ind]
|
||||||
|
update(app)
|
||||||
case "cmd-yank":
|
case "cmd-yank":
|
||||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, app.ui.cmdYankBuf...)
|
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, app.ui.cmdYankBuf...)
|
||||||
|
update(app)
|
||||||
case "cmd-transpose":
|
case "cmd-transpose":
|
||||||
if len(app.ui.cmdAccLeft) < 2 {
|
if len(app.ui.cmdAccLeft) < 2 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-1], app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-2] = app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-2], app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-1]
|
app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-1], app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-2] = app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-2], app.ui.cmdAccLeft[len(app.ui.cmdAccLeft)-1]
|
||||||
|
update(app)
|
||||||
case "cmd-interrupt":
|
case "cmd-interrupt":
|
||||||
if app.cmd != nil {
|
if app.cmd != nil {
|
||||||
app.cmd.Process.Kill()
|
app.cmd.Process.Kill()
|
||||||
@@ -917,6 +1070,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
ind = loc[0] + 1
|
ind = loc[0] + 1
|
||||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, app.ui.cmdAccRight[:ind]...)
|
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, app.ui.cmdAccRight[:ind]...)
|
||||||
app.ui.cmdAccRight = app.ui.cmdAccRight[ind:]
|
app.ui.cmdAccRight = app.ui.cmdAccRight[ind:]
|
||||||
|
update(app)
|
||||||
case "cmd-delete-word":
|
case "cmd-delete-word":
|
||||||
if len(app.ui.cmdAccRight) == 0 {
|
if len(app.ui.cmdAccRight) == 0 {
|
||||||
return
|
return
|
||||||
@@ -927,6 +1081,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
ind := loc[0] + 1
|
ind := loc[0] + 1
|
||||||
app.ui.cmdAccRight = app.ui.cmdAccRight[ind:]
|
app.ui.cmdAccRight = app.ui.cmdAccRight[ind:]
|
||||||
|
update(app)
|
||||||
case "cmd-uppercase-word":
|
case "cmd-uppercase-word":
|
||||||
if len(app.ui.cmdAccRight) == 0 {
|
if len(app.ui.cmdAccRight) == 0 {
|
||||||
return
|
return
|
||||||
@@ -938,6 +1093,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
ind := loc[0] + 1
|
ind := loc[0] + 1
|
||||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(strings.ToUpper(string(app.ui.cmdAccRight[:ind])))...)
|
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(strings.ToUpper(string(app.ui.cmdAccRight[:ind])))...)
|
||||||
app.ui.cmdAccRight = app.ui.cmdAccRight[ind:]
|
app.ui.cmdAccRight = app.ui.cmdAccRight[ind:]
|
||||||
|
update(app)
|
||||||
case "cmd-lowercase-word":
|
case "cmd-lowercase-word":
|
||||||
if len(app.ui.cmdAccRight) == 0 {
|
if len(app.ui.cmdAccRight) == 0 {
|
||||||
return
|
return
|
||||||
@@ -949,6 +1105,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
ind := loc[0] + 1
|
ind := loc[0] + 1
|
||||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(strings.ToLower(string(app.ui.cmdAccRight[:ind])))...)
|
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(strings.ToLower(string(app.ui.cmdAccRight[:ind])))...)
|
||||||
app.ui.cmdAccRight = app.ui.cmdAccRight[ind:]
|
app.ui.cmdAccRight = app.ui.cmdAccRight[ind:]
|
||||||
|
update(app)
|
||||||
case "cmd-transpose-word":
|
case "cmd-transpose-word":
|
||||||
if len(app.ui.cmdAccLeft) == 0 {
|
if len(app.ui.cmdAccLeft) == 0 {
|
||||||
return
|
return
|
||||||
@@ -982,6 +1139,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
acc = append(acc, app.ui.cmdAccLeft[end2:]...)
|
acc = append(acc, app.ui.cmdAccLeft[end2:]...)
|
||||||
|
|
||||||
app.ui.cmdAccLeft = acc
|
app.ui.cmdAccLeft = acc
|
||||||
|
update(app)
|
||||||
default:
|
default:
|
||||||
cmd, ok := gOpts.cmds[e.name]
|
cmd, ok := gOpts.cmds[e.name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ The following commands are provided by lf without default keybindings:
|
|||||||
cd changes working directory to its argument
|
cd changes working directory to its argument
|
||||||
select changes current file selection to its argument
|
select changes current file selection to its argument
|
||||||
source reads the configuration file in its argument
|
source reads the configuration file in its argument
|
||||||
push simulate key pushes given in its argument
|
push simulates key pushes given in its argument
|
||||||
|
delete deletes the current file or selected file(s)
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
The following command line commands are provided by lf with default keybindings:
|
The following command line commands are provided by lf with default keybindings:
|
||||||
@@ -109,16 +110,22 @@ The following options can be used to customize the behavior of lf:
|
|||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
anchorfind boolean (default on)
|
anchorfind boolean (default on)
|
||||||
|
color256 boolean (default off)
|
||||||
dircounts boolean (default off)
|
dircounts boolean (default off)
|
||||||
dirfirst boolean (default on)
|
dirfirst boolean (default on)
|
||||||
drawbox boolean (default off)
|
drawbox boolean (default off)
|
||||||
globsearch boolean (default off)
|
globsearch boolean (default off)
|
||||||
hidden boolean (default off)
|
hidden boolean (default off)
|
||||||
ignorecase boolean (default on)
|
ignorecase boolean (default on)
|
||||||
|
ignoredia boolean (default off)
|
||||||
|
incsearch boolean (default off)
|
||||||
preview boolean (default on)
|
preview boolean (default on)
|
||||||
reverse boolean (default off)
|
reverse boolean (default off)
|
||||||
smartcase boolean (default on)
|
smartcase boolean (default on)
|
||||||
|
smartdia boolean (default off)
|
||||||
wrapscan boolean (default on)
|
wrapscan boolean (default on)
|
||||||
|
number boolean (default off)
|
||||||
|
relativenumber boolean (default off)
|
||||||
findlen integer (default 1) (zero to prompt until single match)
|
findlen integer (default 1) (zero to prompt until single match)
|
||||||
period integer (default 0) (zero to disable periodic loading)
|
period integer (default 0) (zero to disable periodic loading)
|
||||||
scrolloff integer (default 0)
|
scrolloff integer (default 0)
|
||||||
@@ -542,9 +549,17 @@ You can customize these operations by defining a 'paste' command. This is a spec
|
|||||||
.PP
|
.PP
|
||||||
Some useful things are to use the backup option ('--backup') with 'cp' and 'mv' commands if they support it (i.e. GNU implementation), change the command type to asynchronous, or use 'rsync' command with progress bar option for copying and feed the progress to the client periodically with remote 'echo' calls.
|
Some useful things are to use the backup option ('--backup') with 'cp' and 'mv' commands if they support it (i.e. GNU implementation), change the command type to asynchronous, or use 'rsync' command with progress bar option for copying and feed the progress to the client periodically with remote 'echo' calls.
|
||||||
.PP
|
.PP
|
||||||
By default, lf does not provide an actual file deletion command to protect new users. You can define such a command and optionally assign a key if you like. An example command to move selected files to a trash folder and remove files completely are provided in the example configuration file.
|
By default, lf does not assign 'delete' command to a key to protect new users. You can customize file deletion by defining a 'delete' command. You can also assign a key to this command if you like. An example command to move selected files to a trash folder and remove files completely after a prompt are provided in the example configuration file.
|
||||||
|
.SH SEARCHING FILES
|
||||||
|
There are two mechanisms implemented in lf to search a file in the current directory. Searching is the traditional method to move the selection to a file matching a given pattern. Finding is an alternative way to search for a pattern possibly using fewer keystrokes.
|
||||||
|
.PP
|
||||||
|
Searching mechanism is implemented with commands 'search' (default '/'), 'search-back' (default '?'), 'search-next' (default 'n'), and 'search-prev' (default 'N'). You can enable 'globsearch' option to match with a glob pattern. Globbing supports '*' to match any sequence, '?' to match any character, and '[...]' or '[^...] to match character sets or ranges. You can enable 'incsearch' option to jump to the current match at each keystroke while typing. In this mode, you can either use 'cmd-enter' to accept the search or use 'cmd-escape' to cancel the search.
|
||||||
|
.PP
|
||||||
|
Finding mechanism is implemented with commands 'find' (default 'f'), 'find-back' (default 'F'), 'find-next' (default ';'), 'find-prev' (default ','). You can disable 'anchorfind' option to match a pattern at an arbitrary position in the filename instead of the beginning. You can set the number of keys to match using 'findlen' option. If you set this value to zero, then the the keys are read until there is only a single match. Default values of these two options are set to jump to the first file with the given initial.
|
||||||
|
.PP
|
||||||
|
Some options effect both searching and finding. You can disable 'wrapscan' option to prevent searches to wrap around at the end of the file list. You can disable 'ignorecase' option to match cases in the pattern and the filename. This option is already automatically overridden if the pattern contains upper case characters. You can disable 'smartcase' option to disable this behavior. Two similar options 'ignoredia' and 'smartdia' are provided to control matching diacritics in latin letters.
|
||||||
.SH OPENING FILES
|
.SH OPENING FILES
|
||||||
You can define a an 'open' command (default 'l') to configure file opening. This command is only called when the current file is not a directory, otherwise the directory is entered instead. You can define it just as you would define any other command:
|
You can define a an 'open' command (default 'l' and '<right>') to configure file opening. This command is only called when the current file is not a directory, otherwise the directory is entered instead. You can define it just as you would define any other command:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
cmd open $vi $fx
|
cmd open $vi $fx
|
||||||
@@ -609,6 +624,10 @@ If '$LS_COLORS' variable is not set, '$LSCOLORS' variable is checked instead. Th
|
|||||||
.PP
|
.PP
|
||||||
If both of these environment variables are not set, then lf fallbacks to its default colorscheme. Default lf colors are taken from GNU dircolors defaults. These defaults use 8 basic colors and bold attribute.
|
If both of these environment variables are not set, then lf fallbacks to its default colorscheme. Default lf colors are taken from GNU dircolors defaults. These defaults use 8 basic colors and bold attribute.
|
||||||
.PP
|
.PP
|
||||||
|
You should also note that lf uses 8 color mode by default which uses sgr 3-bit color escapes (e.g. '\e033[34m'). If you want to use 256 colors, you need to enable 'color256' option which then makes lf use sgr 8-bit color escapes (e.g. '\e033[38;5;4m'). This option is intended to eliminate differences between default colors used by ls and lf since terminals may render 3-bit and 8-bit escapes differently even for the same color.
|
||||||
|
.PP
|
||||||
Keeping this mechanism in mind, you can configure lf colors in two different ways. First, you can configure 8 basic colors used by your terminal and lf should pick up those colors automatically. Depending on your terminal, you should be able to select your colors from a 24-bit palette. This is the recommended approach as colors used by other programs will also match each other.
|
Keeping this mechanism in mind, you can configure lf colors in two different ways. First, you can configure 8 basic colors used by your terminal and lf should pick up those colors automatically. Depending on your terminal, you should be able to select your colors from a 24-bit palette. This is the recommended approach as colors used by other programs will also match each other.
|
||||||
.PP
|
.PP
|
||||||
Second, you can set the values of environmental variables mentioned above for fine grained customization. This is useful to change colors used for different file types and extensions. '$LS_COLORS' is more powerful than '$LSCOLORS' and it can be used even when GNU programs are not installed on the system. You can combine this second method with the first method for best results.
|
Second, you can set the values of environmental variables mentioned above for fine grained customization. This is useful to change colors used for different file types and extensions. '$LS_COLORS' is more powerful than '$LSCOLORS' and it can be used even when GNU programs are not installed on the system. You can combine this second method with the first method for best results.
|
||||||
|
.PP
|
||||||
|
Lastly, you may also want to configure the colors of the prompt line to match the rest of the colors. Colors of the prompt line can be configured using the 'promptfmt' option which can include hardcoded colors as ansi escapes. See the default value of this option to have an idea about how to color this line.
|
||||||
@@ -25,6 +25,8 @@ var (
|
|||||||
gSocketPath string
|
gSocketPath string
|
||||||
gLogPath string
|
gLogPath string
|
||||||
gServerLogPath string
|
gServerLogPath string
|
||||||
|
gSelect string
|
||||||
|
gCommand string
|
||||||
gVersion string
|
gVersion string
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -103,6 +105,11 @@ func main() {
|
|||||||
"",
|
"",
|
||||||
"path to the file to write selected files on open (to use as open file dialog)")
|
"path to the file to write selected files on open (to use as open file dialog)")
|
||||||
|
|
||||||
|
flag.StringVar(&gCommand,
|
||||||
|
"command",
|
||||||
|
"",
|
||||||
|
"command to execute on client initialization")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
gSocketProt = gDefaultSocketProt
|
gSocketProt = gDefaultSocketProt
|
||||||
@@ -149,13 +156,9 @@ func main() {
|
|||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
dir := flag.Arg(0)
|
gSelect = flag.Arg(0)
|
||||||
if err := os.Chdir(dir); err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "%s\n", err)
|
|
||||||
os.Exit(2)
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
fmt.Fprintf(os.Stderr, "only single directory is allowed\n")
|
fmt.Fprintf(os.Stderr, "only single file or directory is allowed\n")
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -202,6 +202,8 @@ type nav struct {
|
|||||||
findBack bool
|
findBack bool
|
||||||
search string
|
search string
|
||||||
searchBack bool
|
searchBack bool
|
||||||
|
searchInd int
|
||||||
|
searchPos int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) loadDir(path string) *dir {
|
func (nav *nav) loadDir(path string) *dir {
|
||||||
@@ -549,30 +551,19 @@ func (nav *nav) unselect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) save(cp bool) error {
|
func (nav *nav) save(cp bool) error {
|
||||||
if len(nav.selections) == 0 {
|
list, err := nav.currFileOrSelections()
|
||||||
curr, err := nav.currFile()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("no file selected")
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := saveFiles([]string{curr.path}, cp); err != nil {
|
if err := saveFiles(list, cp); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
nav.saves = make(map[string]bool)
|
nav.saves = make(map[string]bool)
|
||||||
nav.saves[curr.path] = cp
|
for _, f := range list {
|
||||||
} else {
|
|
||||||
selections := nav.currSelections()
|
|
||||||
|
|
||||||
if err := saveFiles(selections, cp); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
nav.saves = make(map[string]bool)
|
|
||||||
for f := range nav.selections {
|
|
||||||
nav.saves[f] = cp
|
nav.saves[f] = cp
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -602,6 +593,22 @@ func (nav *nav) paste() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nav *nav) del() error {
|
||||||
|
list, err := nav.currFileOrSelections()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, path := range list {
|
||||||
|
if err := os.RemoveAll(path); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (nav *nav) sync() error {
|
func (nav *nav) sync() error {
|
||||||
list, cp, err := loadFiles()
|
list, cp, err := loadFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -665,6 +672,13 @@ func findMatch(name, pattern string) bool {
|
|||||||
name = strings.ToLower(name)
|
name = strings.ToLower(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if gOpts.ignoredia {
|
||||||
|
lpattern := removeDiacritics(pattern)
|
||||||
|
if !gOpts.smartdia || lpattern == pattern {
|
||||||
|
pattern = lpattern
|
||||||
|
name = removeDiacritics(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
if gOpts.anchorfind {
|
if gOpts.anchorfind {
|
||||||
return strings.HasPrefix(name, pattern)
|
return strings.HasPrefix(name, pattern)
|
||||||
}
|
}
|
||||||
@@ -740,6 +754,13 @@ func searchMatch(name, pattern string) (matched bool, err error) {
|
|||||||
name = strings.ToLower(name)
|
name = strings.ToLower(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if gOpts.ignoredia {
|
||||||
|
lpattern := removeDiacritics(pattern)
|
||||||
|
if !gOpts.smartdia || lpattern == pattern {
|
||||||
|
pattern = lpattern
|
||||||
|
name = removeDiacritics(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
if gOpts.globsearch {
|
if gOpts.globsearch {
|
||||||
return filepath.Match(pattern, name)
|
return filepath.Match(pattern, name)
|
||||||
}
|
}
|
||||||
@@ -800,19 +821,6 @@ func (nav *nav) searchPrev() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) currDir() *dir {
|
|
||||||
return nav.dirs[len(nav.dirs)-1]
|
|
||||||
}
|
|
||||||
|
|
||||||
func (nav *nav) currFile() (*file, error) {
|
|
||||||
last := nav.dirs[len(nav.dirs)-1]
|
|
||||||
|
|
||||||
if len(last.files) == 0 {
|
|
||||||
return nil, fmt.Errorf("empty directory")
|
|
||||||
}
|
|
||||||
return last.files[last.ind], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (nav *nav) readMarks() error {
|
func (nav *nav) readMarks() error {
|
||||||
f, err := os.Open(gMarksPath)
|
f, err := os.Open(gMarksPath)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
@@ -873,6 +881,19 @@ func (nav *nav) writeMarks() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nav *nav) currDir() *dir {
|
||||||
|
return nav.dirs[len(nav.dirs)-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nav *nav) currFile() (*file, error) {
|
||||||
|
last := nav.dirs[len(nav.dirs)-1]
|
||||||
|
|
||||||
|
if len(last.files) == 0 {
|
||||||
|
return nil, fmt.Errorf("empty directory")
|
||||||
|
}
|
||||||
|
return last.files[last.ind], nil
|
||||||
|
}
|
||||||
|
|
||||||
type indexedSelections struct {
|
type indexedSelections struct {
|
||||||
paths []string
|
paths []string
|
||||||
indices []int
|
indices []int
|
||||||
@@ -897,3 +918,16 @@ func (nav *nav) currSelections() []string {
|
|||||||
sort.Sort(indexedSelections{paths: paths, indices: indices})
|
sort.Sort(indexedSelections{paths: paths, indices: indices})
|
||||||
return paths
|
return paths
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nav *nav) currFileOrSelections() (list []string, err error) {
|
||||||
|
if len(nav.selections) == 0 {
|
||||||
|
curr, err := nav.currFile()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.New("no file selected")
|
||||||
|
}
|
||||||
|
|
||||||
|
return []string{curr.path}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return nav.currSelections(), nil
|
||||||
|
}
|
||||||
@@ -26,13 +26,19 @@ type sortType struct {
|
|||||||
|
|
||||||
var gOpts struct {
|
var gOpts struct {
|
||||||
anchorfind bool
|
anchorfind bool
|
||||||
|
color256 bool
|
||||||
dircounts bool
|
dircounts bool
|
||||||
drawbox bool
|
drawbox bool
|
||||||
globsearch bool
|
globsearch bool
|
||||||
ignorecase bool
|
ignorecase bool
|
||||||
|
incsearch bool
|
||||||
preview bool
|
preview bool
|
||||||
smartcase bool
|
smartcase bool
|
||||||
|
ignoredia bool
|
||||||
|
smartdia bool
|
||||||
wrapscan bool
|
wrapscan bool
|
||||||
|
number bool
|
||||||
|
relativenumber bool
|
||||||
findlen int
|
findlen int
|
||||||
period int
|
period int
|
||||||
scrolloff int
|
scrolloff int
|
||||||
@@ -54,12 +60,16 @@ var gOpts struct {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
gOpts.anchorfind = true
|
gOpts.anchorfind = true
|
||||||
|
gOpts.color256 = false
|
||||||
gOpts.dircounts = false
|
gOpts.dircounts = false
|
||||||
gOpts.drawbox = false
|
gOpts.drawbox = false
|
||||||
gOpts.globsearch = false
|
gOpts.globsearch = false
|
||||||
gOpts.ignorecase = true
|
gOpts.ignorecase = true
|
||||||
|
gOpts.incsearch = false
|
||||||
gOpts.preview = true
|
gOpts.preview = true
|
||||||
gOpts.smartcase = true
|
gOpts.smartcase = true
|
||||||
|
gOpts.ignoredia = false
|
||||||
|
gOpts.smartdia = false
|
||||||
gOpts.wrapscan = true
|
gOpts.wrapscan = true
|
||||||
gOpts.findlen = 1
|
gOpts.findlen = 1
|
||||||
gOpts.period = 0
|
gOpts.period = 0
|
||||||
|
|||||||
@@ -267,18 +267,45 @@ func (win *win) printDir(dir *dir, selections map[string]int, saves map[string]b
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lnwidth int = 0
|
||||||
|
var lnformat string = ""
|
||||||
|
|
||||||
|
if gOpts.number || gOpts.relativenumber {
|
||||||
|
lnwidth = 1
|
||||||
|
for j := 10; j < len(dir.files); j *= 10 {
|
||||||
|
lnwidth++
|
||||||
|
}
|
||||||
|
lnformat = fmt.Sprintf("%%%d.d ", lnwidth)
|
||||||
|
}
|
||||||
|
|
||||||
for i, f := range dir.files[beg:end] {
|
for i, f := range dir.files[beg:end] {
|
||||||
fg, bg = colors.get(f)
|
fg, bg = colors.get(f)
|
||||||
|
|
||||||
|
if lnwidth > 0 {
|
||||||
|
var ln string
|
||||||
|
|
||||||
|
if gOpts.number && (!gOpts.relativenumber || i == dir.pos) {
|
||||||
|
ln = fmt.Sprintf(lnformat, i+1+beg)
|
||||||
|
} else if gOpts.relativenumber {
|
||||||
|
if i < dir.pos {
|
||||||
|
ln = fmt.Sprintf(lnformat, dir.pos-i)
|
||||||
|
} else {
|
||||||
|
ln = fmt.Sprintf(lnformat, i-dir.pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
win.print(0, i, termbox.ColorYellow, bg, ln)
|
||||||
|
}
|
||||||
|
|
||||||
path := filepath.Join(dir.path, f.Name())
|
path := filepath.Join(dir.path, f.Name())
|
||||||
|
|
||||||
if _, ok := selections[path]; ok {
|
if _, ok := selections[path]; ok {
|
||||||
win.print(0, i, fg, termbox.ColorMagenta, " ")
|
win.print(lnwidth, i, fg, termbox.ColorMagenta, " ")
|
||||||
} else if cp, ok := saves[path]; ok {
|
} else if cp, ok := saves[path]; ok {
|
||||||
if cp {
|
if cp {
|
||||||
win.print(0, i, fg, termbox.ColorYellow, " ")
|
win.print(lnwidth, i, fg, termbox.ColorYellow, " ")
|
||||||
} else {
|
} else {
|
||||||
win.print(0, i, fg, termbox.ColorRed, " ")
|
win.print(lnwidth, i, fg, termbox.ColorRed, " ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,7 +348,7 @@ func (win *win) printDir(dir *dir, selections map[string]int, saves map[string]b
|
|||||||
|
|
||||||
s = append(s, ' ')
|
s = append(s, ' ')
|
||||||
|
|
||||||
win.print(1, i, fg, bg, string(s))
|
win.print(lnwidth+1, i, fg, bg, string(s))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -892,6 +919,14 @@ func (ui *ui) readExpr() <-chan expr {
|
|||||||
return ch
|
return ch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setColorMode() {
|
||||||
|
if gOpts.color256 {
|
||||||
|
termbox.SetOutputMode(termbox.Output256)
|
||||||
|
} else {
|
||||||
|
termbox.SetOutputMode(termbox.OutputNormal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (ui *ui) pause() {
|
func (ui *ui) pause() {
|
||||||
termbox.Close()
|
termbox.Close()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user