cygnus 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/cygnus +28 -13
- data/lib/cygnus.rb +44 -17
- data/lib/cygnus/version.rb +1 -1
- metadata +3 -3
data/bin/cygnus
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# Author: rkumar http://github.com/rkumar/mancurses/
|
9
9
|
# Date: 2011-11-09 - 16:59
|
10
10
|
# License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
11
|
-
# Last update: 2013-03-19
|
11
|
+
# Last update: 2013-03-19 20:04
|
12
12
|
#
|
13
13
|
# == CHANGES
|
14
14
|
# == BUGS
|
@@ -334,6 +334,7 @@ def full_indexed_list dir=Dir.pwd, config={}, &block
|
|
334
334
|
|
335
335
|
#config[:suppress_border] = true
|
336
336
|
$files = get_file_list(dir)
|
337
|
+
enhance_file_list
|
337
338
|
lb = Cygnus::TextPad.new @form, config, &block
|
338
339
|
form_bindings @form
|
339
340
|
$grows = lb.rows
|
@@ -448,14 +449,25 @@ def c_process_key c
|
|
448
449
|
ch = "end"
|
449
450
|
end
|
450
451
|
|
451
|
-
|
452
|
-
|
453
|
-
if
|
454
|
-
|
455
|
-
|
452
|
+
x = h[ch]
|
453
|
+
x = h[ch.to_sym] unless x
|
454
|
+
x = x.split if x
|
455
|
+
if x
|
456
|
+
binding = x.shift
|
457
|
+
args = x
|
458
|
+
if binding && respond_to?(binding, true)
|
459
|
+
send(binding, *args)
|
456
460
|
return true
|
457
461
|
end
|
462
|
+
else
|
463
|
+
#perror "No binding for #{ch}"
|
458
464
|
end
|
465
|
+
#if binding
|
466
|
+
#if respond_to?(binding, true)
|
467
|
+
#send(binding)
|
468
|
+
#return true
|
469
|
+
#end
|
470
|
+
#end
|
459
471
|
return false
|
460
472
|
end
|
461
473
|
def pad_display_file filename, renderer, config={}, &block
|
@@ -473,7 +485,8 @@ def pad_display_file filename, renderer, config={}, &block
|
|
473
485
|
# maintain a stack of filename so we can backspace through them
|
474
486
|
fn = filename
|
475
487
|
fn = "#{Dir.pwd}/#{filename}" unless filename[0] == "/"
|
476
|
-
|
488
|
+
#@file_stack << fn unless @file_stack.include? fn
|
489
|
+
$visited_files << fn unless $visited_files.include? fn
|
477
490
|
|
478
491
|
listconfig = config[:listconfig] || {}
|
479
492
|
#listconfig[:list] = list
|
@@ -536,10 +549,10 @@ def pad_display_file filename, renderer, config={}, &block
|
|
536
549
|
when 127
|
537
550
|
# hitting backspace cycles through list of files viewed
|
538
551
|
# FIXME first time we have to hit BS 2 times since we get same file we are viewing
|
539
|
-
_f =
|
552
|
+
_f = $visited_files.pop
|
540
553
|
if _f
|
541
554
|
# push it to first
|
542
|
-
|
555
|
+
$visited_files.insert 0, _f
|
543
556
|
#lb.filename(_f)
|
544
557
|
lb.text(get_file_contents(_f))
|
545
558
|
form.repaint
|
@@ -676,7 +689,6 @@ end
|
|
676
689
|
return ix
|
677
690
|
end
|
678
691
|
@dir_stack = []
|
679
|
-
@file_stack = []
|
680
692
|
def change_dir dir, filename=nil
|
681
693
|
@dir_stack << Dir.pwd unless @dir_stack.include? Dir.pwd
|
682
694
|
$sta = $cursor = 0
|
@@ -701,6 +713,8 @@ end
|
|
701
713
|
def display_dir filename=nil
|
702
714
|
$sta = $cursor = 0
|
703
715
|
list = get_file_list
|
716
|
+
$files = list
|
717
|
+
enhance_file_list
|
704
718
|
if filename
|
705
719
|
ix = list.index filename
|
706
720
|
if ix
|
@@ -712,7 +726,7 @@ end
|
|
712
726
|
end
|
713
727
|
end
|
714
728
|
#alist = index_this_list list
|
715
|
-
alist = columnate_with_indexing
|
729
|
+
alist = columnate_with_indexing $files, $grows
|
716
730
|
lb = @form.by_name["fitp"]
|
717
731
|
lb.formatted_text(alist, :tmux)
|
718
732
|
lb.title = Dir.pwd
|
@@ -721,8 +735,7 @@ end
|
|
721
735
|
@header.text_center Dir.pwd
|
722
736
|
@header.text_right "#{$sta}, #{$cursor}"
|
723
737
|
@form.repaint
|
724
|
-
$files
|
725
|
-
return list
|
738
|
+
$files
|
726
739
|
end
|
727
740
|
def get_file_list dir="."
|
728
741
|
list = Dir.entries dir
|
@@ -783,6 +796,7 @@ end
|
|
783
796
|
end
|
784
797
|
end
|
785
798
|
def show
|
799
|
+
# used still ? XXX
|
786
800
|
list = get_file_list
|
787
801
|
ix = padpopuplist list, :title => "Files", :bgcolor => :blue, :color => :white
|
788
802
|
return unless ix
|
@@ -835,6 +849,7 @@ end
|
|
835
849
|
"M-+" => "columns_incdec 1",
|
836
850
|
"S" => "command_file list y ls -lh",
|
837
851
|
"L" => "command_file Page n less",
|
852
|
+
"V" => "command_file edit n vim",
|
838
853
|
"C-d" => "cursor_scroll_dn",
|
839
854
|
"C-b" => "cursor_scroll_up",
|
840
855
|
"up" => "cursor_up",
|
data/lib/cygnus.rb
CHANGED
@@ -846,7 +846,7 @@ def subcommand
|
|
846
846
|
$quitting = true
|
847
847
|
$writing = true if $modified
|
848
848
|
elsif command == "p"
|
849
|
-
|
849
|
+
c_system "echo $PWD | pbcopy"
|
850
850
|
get_single "Stored PWD in clipboard (using pbcopy)"
|
851
851
|
end
|
852
852
|
end
|
@@ -993,8 +993,8 @@ def command_file prompt, *command
|
|
993
993
|
file = File.expand_path(file)
|
994
994
|
if File.exists? file
|
995
995
|
file = Shellwords.escape(file)
|
996
|
-
pbold "#{command} #{file} (
|
997
|
-
|
996
|
+
pbold "#{command} #{file} (press a key)"
|
997
|
+
c_system "#{command} #{file}"
|
998
998
|
pause if pauseyn == "y"
|
999
999
|
c_refresh
|
1000
1000
|
else
|
@@ -1386,7 +1386,7 @@ def newfile
|
|
1386
1386
|
str = get_line "Enter file name: "
|
1387
1387
|
#str = Readline::readline('>', true)
|
1388
1388
|
return if str.nil? || str == ""
|
1389
|
-
|
1389
|
+
c_system "$EDITOR #{str}"
|
1390
1390
|
$visited_files.insert(0, str) if File.exists?(str)
|
1391
1391
|
c_refresh
|
1392
1392
|
end
|
@@ -1433,13 +1433,18 @@ def enhance_file_list
|
|
1433
1433
|
# if only one entry and its a dir
|
1434
1434
|
# get its children and maybe the recent mod files a few
|
1435
1435
|
|
1436
|
+
# zsh gives errors which stick on stdscr and don't get off!
|
1437
|
+
# Rather than using N I'll try to convert to ruby, but then we lose
|
1438
|
+
# similarity to cetus and its tough to redo all the sorting stuff.
|
1436
1439
|
if $files.size == 1
|
1437
1440
|
# its a dir, let give the next level at least
|
1438
1441
|
if $files.first[-1] == "/"
|
1439
1442
|
d = $files.first
|
1440
|
-
f = `zsh -c 'print -rl -- #{d}*(omM)'`.split("\n")
|
1443
|
+
#f = `zsh -c 'print -rl -- #{d}*(omM)'`.split("\n")
|
1444
|
+
f = get_file_list d
|
1441
1445
|
if f && f.size > 0
|
1442
1446
|
$files.concat f
|
1447
|
+
$files.concat get_important_files(d)
|
1443
1448
|
return
|
1444
1449
|
end
|
1445
1450
|
else
|
@@ -1454,15 +1459,16 @@ def enhance_file_list
|
|
1454
1459
|
if $files.index("Gemfile") || $files.grep(/\.gemspec/).size > 0
|
1455
1460
|
# usually the lib dir has only one file and one dir
|
1456
1461
|
flg = false
|
1462
|
+
$files.concat get_important_files(Dir.pwd)
|
1457
1463
|
if $files.index("lib/")
|
1458
|
-
f = `zsh -c 'print -rl -- lib/*(om[1,5]
|
1464
|
+
f = `zsh -c 'print -rl -- lib/*(om[1,5]MN)'`.split("\n")
|
1459
1465
|
if f && f.size() > 0
|
1460
1466
|
insert_into_list("lib/", f)
|
1461
1467
|
flg = true
|
1462
1468
|
end
|
1463
1469
|
dd = File.basename(Dir.pwd)
|
1464
1470
|
if f.index("lib/#{dd}/")
|
1465
|
-
f = `zsh -c 'print -rl -- lib/#{dd}/*(om[1,5]
|
1471
|
+
f = `zsh -c 'print -rl -- lib/#{dd}/*(om[1,5]MN)'`.split("\n")
|
1466
1472
|
if f && f.size() > 0
|
1467
1473
|
insert_into_list("lib/#{dd}/", f)
|
1468
1474
|
flg = true
|
@@ -1470,7 +1476,7 @@ def enhance_file_list
|
|
1470
1476
|
end
|
1471
1477
|
end
|
1472
1478
|
if $files.index("bin/")
|
1473
|
-
f = `zsh -c 'print -rl -- bin/*(om[1,5]
|
1479
|
+
f = `zsh -c 'print -rl -- bin/*(om[1,5]MN)'`.split("\n")
|
1474
1480
|
insert_into_list("bin/", f) if f && f.size() > 0
|
1475
1481
|
flg = true
|
1476
1482
|
end
|
@@ -1482,23 +1488,23 @@ def enhance_file_list
|
|
1482
1488
|
return if $files.size > 15
|
1483
1489
|
|
1484
1490
|
## first check accessed else modified will change accessed
|
1485
|
-
moda = `zsh -c 'print -rn -- *(/oa[1]
|
1491
|
+
moda = `zsh -c 'print -rn -- *(/oa[1]MN)'`
|
1486
1492
|
if moda && moda != ""
|
1487
|
-
modf = `zsh -c 'print -rn -- #{moda}*(oa[1]
|
1493
|
+
modf = `zsh -c 'print -rn -- #{moda}*(oa[1]MN)'`
|
1488
1494
|
if modf && modf != ""
|
1489
1495
|
insert_into_list moda, modf
|
1490
1496
|
end
|
1491
|
-
modm = `zsh -c 'print -rn -- #{moda}*(om[1]
|
1497
|
+
modm = `zsh -c 'print -rn -- #{moda}*(om[1]MN)'`
|
1492
1498
|
if modm && modm != "" && modm != modf
|
1493
1499
|
insert_into_list moda, modm
|
1494
1500
|
end
|
1495
1501
|
end
|
1496
1502
|
## get last modified dir
|
1497
|
-
modm = `zsh -c 'print -rn -- *(/om[1]
|
1503
|
+
modm = `zsh -c 'print -rn -- *(/om[1]MN)'`
|
1498
1504
|
if modm != moda
|
1499
|
-
modmf = `zsh -c 'print -rn -- #{modm}*(oa[1]
|
1505
|
+
modmf = `zsh -c 'print -rn -- #{modm}*(oa[1]MN)'`
|
1500
1506
|
insert_into_list modm, modmf
|
1501
|
-
modmf1 = `zsh -c 'print -rn -- #{modm}*(om[1]
|
1507
|
+
modmf1 = `zsh -c 'print -rn -- #{modm}*(om[1]MN)'`
|
1502
1508
|
insert_into_list(modm, modmf1) if modmf1 != modmf
|
1503
1509
|
else
|
1504
1510
|
# if both are same then our options get reduced so we need to get something more
|
@@ -1507,9 +1513,30 @@ def enhance_file_list
|
|
1507
1513
|
end
|
1508
1514
|
end
|
1509
1515
|
def insert_into_list dir, file
|
1510
|
-
|
1511
|
-
|
1512
|
-
$files.
|
1516
|
+
## earlier we were inserting these files at helpful points (before the dirs), but they are touch to find.
|
1517
|
+
# I think it;s better to put at end
|
1518
|
+
#ix = $files.index(dir)
|
1519
|
+
#raise "something wrong can find #{dir}." unless ix
|
1520
|
+
#$files.insert ix, *file
|
1521
|
+
$files.concat file
|
1522
|
+
end
|
1523
|
+
def get_important_files dir
|
1524
|
+
# checks various lists like visited_files and bookmarks
|
1525
|
+
# to see if files from this dir or below are in it.
|
1526
|
+
# More to be used in a dir with few files.
|
1527
|
+
list = []
|
1528
|
+
l = dir.size + 1
|
1529
|
+
$visited_files.each do |e|
|
1530
|
+
if e.index(dir) == 0
|
1531
|
+
list << e[l..-1]
|
1532
|
+
end
|
1533
|
+
end
|
1534
|
+
# bookmarks have : which needs to be removed
|
1535
|
+
#list1 = $bookmarks.values.select do |e|
|
1536
|
+
#e.index(dir) == 0
|
1537
|
+
#end
|
1538
|
+
#list.concat list1
|
1539
|
+
return list
|
1513
1540
|
end
|
1514
1541
|
#
|
1515
1542
|
# prints a prompt at bottom of screen, takes a character and returns textual representation
|
data/lib/cygnus/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cygnus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -76,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
segments:
|
78
78
|
- 0
|
79
|
-
hash:
|
79
|
+
hash: 849870953013136634
|
80
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
segments:
|
87
87
|
- 0
|
88
|
-
hash:
|
88
|
+
hash: 849870953013136634
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project:
|
91
91
|
rubygems_version: 1.8.25
|