summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-07 19:22:26 +0200
committerhut <hut@lavabit.com>2010-04-07 19:22:26 +0200
commit7626fd1d08ccb597ef25eaebf37ffc7be33c6df2 (patch)
tree89eef9a95f1749b7a3707d01bd54dcb303f51d5f
parentbf4a79dba297d9d5b3801c5785fdf0458de7873c (diff)
downloadranger-7626fd1d08ccb597ef25eaebf37ffc7be33c6df2.tar.gz
Implement alt keys in core
-rw-r--r--ranger/container/keymap.py2
-rw-r--r--ranger/core/fm.py14
-rw-r--r--ranger/defaults/keys.py12
-rw-r--r--ranger/gui/ui.py19
4 files changed, 28 insertions, 19 deletions
diff --git a/ranger/container/keymap.py b/ranger/container/keymap.py
index dee54430..1e634f1d 100644
--- a/ranger/container/keymap.py
+++ b/ranger/container/keymap.py
@@ -295,6 +295,8 @@ special_keys = {
 }
 for char in ascii_lowercase:
 	special_keys['c-' + char] = ord(char) - 96
+
+for char in (ascii_lowercase + '0123456789'):
 	special_keys['a-' + char] = (27, ord(char))
 
 def translate_keys(obj):
diff --git a/ranger/core/fm.py b/ranger/core/fm.py
index 25e66407..a408139a 100644
--- a/ranger/core/fm.py
+++ b/ranger/core/fm.py
@@ -141,19 +141,7 @@ class FM(Actions, SignalDispatcher):
 
 				ui.set_load_mode(loader.has_work())
 
-				key = ui.get_next_key()
-
-				if key > 0:
-					if key == KEY_MOUSE:
-						ui.handle_mouse()
-					elif key == KEY_RESIZE:
-						ui.update_size()
-					else:
-						if self.input_blocked and \
-								time() > self.input_blocked_until:
-							self.input_blocked = False
-						if not self.input_blocked:
-							ui.handle_key(key)
+				ui.handle_input()
 
 				gc_tick += 1
 				if gc_tick > TICKS_BEFORE_COLLECTING_GARBAGE:
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 55f8331d..467d26e6 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -478,17 +478,25 @@ def browser_keys():
 	map('gr', 'g/', fm.cd('/'))
 	map('gm', fm.cd('/media'))
 	map('gn', fm.cd('/mnt'))
-	map('gt', fm.cd('/tmp'))
 	map('gs', fm.cd('/srv'))
 	map('gR', fm.cd(RANGERDIR))
 
+	# ------------------------------------------------------------ tabs
+	map('gc', ctrl('W'), fm.tab_close())
+	map('gt', TAB, fm.tab_move(1))
+	map('gT', KEY_BTAB, fm.tab_move(-1))
+	map('gn', ctrl('N'), fm.tab_new())
+	for n in range(10):
+		map('g' + str(n), fm.tab_open(n))
+		map('<A-' + str(n) + '>', fm.tab_open(n))
+
 	# ------------------------------------------------------- searching
 	map('/', fm.open_console(cmode.SEARCH))
 
 	map('n', fm.search())
 	map('N', fm.search(forward=False))
 
-	map(TAB, fm.search(order='tag'))
+	map('ct', fm.search(order='tag'))
 	map('cc', fm.search(order='ctime'))
 	map('cm', fm.search(order='mimetype'))
 	map('cs', fm.search(order='size'))
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index c7c2090a..c1a4bb60 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -155,13 +155,24 @@ class UI(DisplayableContainer):
 		else:
 			kbuf.clear()
 
-	def get_next_key(self):
-		"""Waits for key input and returns the pressed key"""
+	def handle_input(self):
 		key = self.win.getch()
-		if key is not -1:
+		if key in (27, 195):  # 27: alt+X, 195: unicode
+			keys = [key]
+			previous_load_mode = self.load_mode
+			self.set_load_mode(True)
+			for n in range(8):
+				getkey = self.win.getch()
+				if getkey is not -1:
+					keys.append(getkey)
+			for key in keys:
+				self.handle_key(key)
+			self.set_load_mode(previous_load_mode)
+		else:
 			if self.settings.flushinput:
 				curses.flushinp()
-		return key
+			if key > 0:
+				self.handle_key(key)
 
 	def setup(self):
 		"""