summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-12 00:23:18 +0100
committerhut <hut@lavabit.com>2009-12-12 00:23:18 +0100
commit22449efdeaec4ae089a6461ab93700536b5ea1bd (patch)
treee50ea0bcd38f93bd3fa59f60086980f84e33282f /ranger
parent649a69cb87af38f4bf1848085d49d1193f6e01ab (diff)
downloadranger-22449efdeaec4ae089a6461ab93700536b5ea1bd.tar.gz
clean ups/fixes
Diffstat (limited to 'ranger')
-rw-r--r--ranger/defaults/apps.py4
-rw-r--r--ranger/defaults/keys.py28
-rw-r--r--ranger/ext/log.py2
-rw-r--r--ranger/fm.py2
-rw-r--r--ranger/gui/widgets/console.py42
-rw-r--r--ranger/gui/widgets/filelist.py1
6 files changed, 47 insertions, 32 deletions
diff --git a/ranger/defaults/apps.py b/ranger/defaults/apps.py
index b2dc36c6..37422a6e 100644
--- a/ranger/defaults/apps.py
+++ b/ranger/defaults/apps.py
@@ -53,12 +53,16 @@ class CustomApplications(Applications):
 	def app_feh(self, **kw):
 		if kw['files']:
 			if kw['mode'] == 1:
+				kw['flags'] += 'd'
 				return run('feh', '--bg-scale', kw['files'][0], **kw)
 			if kw['mode'] == 2:
+				kw['flags'] += 'd'
 				return run('feh', '--bg-tile', kw['files'][0], **kw)
 			if kw['mode'] == 3:
+				kw['flags'] += 'd'
 				return run('feh', '--bg-center', kw['files'][0], **kw)
 			if kw['mode'] == 4:
+				kw['flags'] += 'd'
 				return run('gimp', *kw['files'], **kw)
 		return run('feh', *kw['files'], **kw)
 
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 5edae929..7d6f7bd6 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -15,9 +15,9 @@ def initialize_commands(command_list):
 	# * an integer which represents an ascii code
 	# * a tuple of integers
 
-	def curry(fnc, *args, **keywords):
+	# currying
+	def c(fnc, *args, **keywords):
 		return lambda fm: fnc(fm, *args, **keywords)
-	c=curry
 
 	def move(**keywords):
 		return lambda fm: fm.move_pointer(**keywords)
@@ -75,13 +75,13 @@ def initialize_commands(command_list):
 	bind(do.interrupt,    ctrl('C'))
 	bind(do.resize,       curses.KEY_RESIZE)
 	bind(do.handle_mouse, curses.KEY_MOUSE)
-	bind(curry(do.open_console, ':'), ':')
-	bind(curry(do.open_console, '/'), '/')
-	bind(curry(do.open_console, '!'), '!')
-	bind(curry(do.open_console, '@'), 'r')
+	bind(c(do.open_console, ':'), ':')
+	bind(c(do.open_console, '/'), '/')
+	bind(c(do.open_console, '!'), '!')
+	bind(c(do.open_console, '@'), 'r')
 
 	def test(fm):
-		from ranger.helper import log
+		from ranger import log
 		log(fm.bookmarks.dct)
 	bind(test, 'x')
 
@@ -96,15 +96,14 @@ def initialize_console_commands(command_list):
 		command_list.bind(fnc, *keys)
 
 	def type_key(key):
-		return lambda con, fm: con.type_key(key)
+		return lambda con: con.type_key(key)
 
-	def curry(fnc, *args, **keywords):
-		return lambda con, fm: fnc(con, *args, **keywords)
+	# currying
+	def c(fnc, *args, **keywords):
+		return lambda con: fnc(con, *args, **keywords)
 
-	def curry_fm(fnc, *args, **keywords):
-		return lambda con, fm: fnc(fm, *args, **keywords)
-	c_fm = curry_fm
-	c = curry
+	def c_fm(fnc, *args, **keywords):
+		return lambda con: fnc(con.fm, *args, **keywords)
 
 	# movement
 	bind(c(Console.move, relative = -1), curses.KEY_LEFT, ctrl('b'))
@@ -113,6 +112,7 @@ def initialize_console_commands(command_list):
 	bind(c(Console.move, absolute = -1), curses.KEY_END, ctrl('e'))
 	bind(c(Console.delete, 0), curses.KEY_DC, ctrl('d'))
 	bind(c(Console.delete, -1), curses.KEY_BACKSPACE, 127, ctrl('h'))
+	bind(c(Console.delete_word), ctrl('W'))
 	bind(c(Console.delete_rest, -1), ctrl('U'))
 	bind(c(Console.delete_rest,  1), ctrl('K'))
 
diff --git a/ranger/ext/log.py b/ranger/ext/log.py
index 9f56dd71..c2521e09 100644
--- a/ranger/ext/log.py
+++ b/ranger/ext/log.py
@@ -7,7 +7,7 @@ Has the same arguments as print() in python3"""
 	sep   =   'sep' in keywords and keywords['sep']   or ' '
 	_file =  'file' in keywords and keywords['file']  or open(LOGFILE, 'a')
 	end   =   'end' in keywords and keywords['end']   or '\n'
-	_file.write(sep.join((start, ) + objects) + end)
+	_file.write(sep.join(map(str, (start, ) + objects)) + end)
 	
 #for python3-only versions, this could be replaced with:
 #
diff --git a/ranger/fm.py b/ranger/fm.py
index dd74342f..5abb2a8e 100644
--- a/ranger/fm.py
+++ b/ranger/fm.py
@@ -47,4 +47,4 @@ class FM(Actions):
 					self.env.garbage_collect()
 
 			except KeyboardInterrupt:
-				self.ui.handle_key(CTRL_C, self)
+				self.ui.handle_key(CTRL_C)
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index c7f3b29d..b1c9e15a 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -55,6 +55,7 @@ class Console(Displayable):
 
 	def close(self):
 		curses.curs_set(self.last_cursor_mode)
+		self.clear()
 		self.focused = False
 		self.visible = False
 		if hasattr(self, 'on_close'):
@@ -76,7 +77,7 @@ class Console(Displayable):
 		if cmd == self.commandlist.dummy_object:
 			return
 
-		cmd.execute(self, self.fm)
+		cmd.execute(self)
 		self.env.key_clear()
 
 	def type_key(self, key):
@@ -105,6 +106,15 @@ class Console(Displayable):
 		else:
 			self.line = self.line[self.pos:]
 			self.pos = 0
+
+	def delete_word(self):
+		try:
+			i = self.line.rindex(' ', 0, self.pos - 1) + 1
+			self.line = self.line[:i] + self.line[self.pos:]
+			self.pos = len(self.line)
+		except ValueError:
+			self.line = ''
+			self.pos = 0
 	
 	def delete(self, mod):
 		if mod == -1 and len(self.line) == 0:
@@ -114,46 +124,46 @@ class Console(Displayable):
 		self.line = self.line[0:pos] + self.line[pos+1:]
 		self.move(relative = mod)
 
-	def execute(self, fm):
+	def execute(self):
 		try:
-			self.execute_funcs[self.mode] (self, fm)
+			self.execute_funcs[self.mode] (self)
 		except KeyError:
 			pass
 		self.line = ''
 		self.pos = 0
 		self.close()
 
-	def execute_search(self, fm):
+	def execute_search(self):
 		import re
-		if fm.env.pwd:
+		if self.fm.env.pwd:
 #			try:
 				regexp = re.compile(self.line, re.L | re.U | re.I)
-				fm.env.last_search = regexp
-				if fm.env.pwd.search(regexp):
-					fm.env.cf = fm.env.pwd.pointed_file
+				self.fm.env.last_search = regexp
+				if self.fm.env.pwd.search(regexp):
+					self.fm.env.cf = self.fm.env.pwd.pointed_file
 #			except:
 #				pass
 
-	def execute_openwith(self, fm):
+	def execute_openwith(self):
 		line = self.line
 		if line[0] == '!':
-			fm.execute_file(tuple(line[1:].split()) + (fm.env.cf.path, ))
+			self.fm.execute_file(tuple(line[1:].split()) + (self.fm.env.cf.path, ))
 		else:
-			fm.execute_file(tuple(line.split()) + (fm.env.cf.path, ), background = True)
+			self.fm.execute_file(tuple(line.split()) + (self.fm.env.cf.path, ), background = True)
 
-	def execute_openwith_quick(self, fm):
+	def execute_openwith_quick(self):
 		split = self.line.split()
-		app, flags, mode = get_app_flags_mode(self.line, fm)
-		fm.execute_file(
+		app, flags, mode = get_app_flags_mode(self.line, self.fm)
+		self.fm.execute_file(
 				files = [self.cf],
 				app = app,
 				flags = flags,
 				mode = mode )
 
-	def execute_noreturn(self, fm):
+	def execute_noreturn(self):
 		pass
 
-	def execute_command(self, fm):
+	def execute_command(self):
 		pass
 
 def get_app_flags_mode(line, fm):
diff --git a/ranger/gui/widgets/filelist.py b/ranger/gui/widgets/filelist.py
index 493dae24..2bca6e24 100644
--- a/ranger/gui/widgets/filelist.py
+++ b/ranger/gui/widgets/filelist.py
@@ -185,6 +185,7 @@ class FileList(Displayable):
 	# TODO: does not work if options.scroll_offset is high,
 	# relative > 1 and you scroll from scroll_begin = 1 to 0
 	def scroll(self, relative):
+		"""scroll by n lines"""
 		self.set_scroll_begin()
 		old_value = self.target.scroll_begin
 		self.target.scroll_begin += relative
n528'>528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831