summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-25 03:33:07 +0100
committerhut <hut@lavabit.com>2009-12-25 03:33:07 +0100
commit586f0006dd6e9c5a6477bcbf87130638cf5a4154 (patch)
tree892cd35c2ece2c76a5fddf65d1bcaa5c9626b616 /ranger
parentddf828fb5ce5a539e01d968aee5817ad1c921a01 (diff)
downloadranger-586f0006dd6e9c5a6477bcbf87130638cf5a4154.tar.gz
can now (re)move processes in pman
Diffstat (limited to 'ranger')
-rw-r--r--ranger/defaults/keys.py8
-rw-r--r--ranger/fm.py11
-rw-r--r--ranger/fsobject/directory.py14
-rw-r--r--ranger/fsobject/loader.py31
-rw-r--r--ranger/gui/widgets/process_manager.py12
5 files changed, 65 insertions, 11 deletions
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 2a775ab9..fe657fdd 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -193,14 +193,20 @@ def initialize_process_manager_commands(command_list):
 	def bind(*args):
 		command_list.bind(args[-1], *args[:-1])
 
+	def do(method, *args, **kw):
+		return lambda widget, n: getattr(widget, method)(*args, **kw)
+
 	def do_fm(method, *args, **kw):
-		return lambda con: getattr(con.fm, method)(*args, **kw)
+		return lambda widget, n: getattr(con.fm, method)(*args, **kw)
 
 	bind('j', KEY_DOWN, wdg.move(relative=1))
 	bind('k', KEY_UP, wdg.move(relative=-1))
 	bind('gg', wdg.move(absolute=0))
 	bind('G', wdg.move(absolute=-1))
+	bind('K', lambda wdg, n: wdg.process_move(0))
+	bind('J', lambda wdg, n: wdg.process_move(-1))
 
+	bind('dd', do('process_remove'))
 	bind('P', ESC, ctrl('d'), lambda wdg, n: wdg.fm.ui.close_pman())
 
 	command_list.rebuild_paths()
diff --git a/ranger/fm.py b/ranger/fm.py
index ce62e94c..a1b1339a 100644
--- a/ranger/fm.py
+++ b/ranger/fm.py
@@ -75,11 +75,12 @@ class FM(Actions):
 
 					key = self.ui.get_next_key()
 
-					if self.input_blocked and \
-							time() > self.input_blocked_until:
-						self.input_blocked = False
-					if not self.input_blocked:
-						self.ui.handle_key(key)
+					if key > 0:
+						if self.input_blocked and \
+								time() > self.input_blocked_until:
+							self.input_blocked = False
+						if not self.input_blocked:
+							self.ui.handle_key(key)
 
 					gc_tick += 1
 					if gc_tick > TICKS_BEFORE_COLLECTING_GARBAGE:
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index 8fb4d0ac..f5aeade4 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -165,8 +165,10 @@ class Directory(FileSystemObject, SettingsAware):
 
 		self.content_loaded = True
 		self.loading = False
-#		yield
-#		yield
+
+	def unload(self):
+		self.loading = False
+		self.load_generator = None
 
 	def load_content(self, schedule=False):
 		"""
@@ -175,7 +177,7 @@ class Directory(FileSystemObject, SettingsAware):
 		"""
 
 		self.load_once()
-
+		
 		if schedule is None:
 			schedule = self.size > 30
 
@@ -319,8 +321,9 @@ class Directory(FileSystemObject, SettingsAware):
 		
 	def load_content_once(self, *a, **k):
 		"""Load the contents of the directory if not done yet"""
-		if not self.content_loaded and not self.loading:
-			self.load_content(*a, **k)
+		if not self.content_loaded:
+			if not self.loading:
+				self.load_content(*a, **k)
 			return True
 		return False
 
@@ -329,6 +332,7 @@ class Directory(FileSystemObject, SettingsAware):
 		Load the contents of the directory if it's
 		outdated or not done yet
 		"""
+
 		if self.load_content_once(*a, **k): return True
 
 		if self.old_show_hidden != self.settings.show_hidden:
diff --git a/ranger/fsobject/loader.py b/ranger/fsobject/loader.py
index 5923ff95..7b051d53 100644
--- a/ranger/fsobject/loader.py
+++ b/ranger/fsobject/loader.py
@@ -35,6 +35,37 @@ class Loader(object):
 		while obj in self.queue:
 			self.queue.remove(obj)
 		self.queue.appendleft(obj)
+	
+	def move(self, _from, to):
+		try:
+			item = self.queue[_from]
+		except IndexError:
+			return
+
+		del self.queue[_from]
+
+		if to == 0:
+			self.queue.appendleft(item)
+		elif to == -1:
+			self.queue.append(item)
+		else:
+			raise NotImplementedError
+	
+	def remove(self, item=None, index=None):
+		if item is not None and index is None:
+			for test, i in zip(self.queue, range(len(self.queue))):
+				if test == item:
+					index = i 
+					break
+			else:
+				return
+
+		if index is not None:
+			if item is None:
+				item = self.queue[index]
+			if hasattr(item, 'unload'):
+				item.unload()
+			del self.queue[index]
 
 	def work(self):
 		"""
diff --git a/ranger/gui/widgets/process_manager.py b/ranger/gui/widgets/process_manager.py
index ae372112..7a0f8357 100644
--- a/ranger/gui/widgets/process_manager.py
+++ b/ranger/gui/widgets/process_manager.py
@@ -73,6 +73,18 @@ class ProcessManager(Widget, Accumulator):
 
 		self.color_reset()
 
+	def process_remove(self, i=None):
+		if i is None:
+			i = self.pointer
+
+		self.fm.loader.remove(index=i)
+	
+	def process_move(self, absolute, i=None):
+		if i is None:
+			i = self.pointer
+
+		self.fm.loader.move(_from=i, to=absolute)
+
 	def press(self, key):
 		try:
 			tup = self.env.keybuffer.tuple_without_numbers()
7-10-12 23:43:09 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2017-10-12 23:43:09 -0700 4052' href='/akkartik/mu/commit/html/subx/003trace.test.cc.html?h=hlt&id=25ad969f7582d9253f5329812aed5ed5784d8ec8'>25ad969f ^
7a219c68 ^
7328af20 ^



25ad969f ^

7a219c68 ^
7328af20 ^

7a219c68 ^
25ad969f ^

7a219c68 ^
7328af20 ^

7a219c68 ^
25ad969f ^

7a219c68 ^
7328af20 ^
7a219c68 ^
25ad969f ^





7328af20 ^




25ad969f ^
7328af20 ^



















































25ad969f ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188