about summary refs log blame commit diff stats
path: root/cpp/.traces/copy_literal
blob: c587d0f793efddb1230ee642d6cd38f657252b8b (plain) (tree)
1
2
3
4
5
6
7
8
                       

                                                                                     

                          
                         
                         
                               
parse/0: instruction: 1
parse/0:   ingredient: {name: "23", value: 0, type: 0, properties: ["23": "literal"]}
parse/0:   product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]}
after-brace/0: recipe main
after-brace/0: copy ...
run/0: instruction main/0
run/0: ingredient 0 is 23
mem/0: storing 23 in location 1
cs/ranger/commit/ranger/gui/widgets/filelist.py?h=v1.9.3&id=d88232a386dbc2153aa12bea7f30c9c53c414010'>d88232a3 ^
9506fb8e ^
49ae0dd1 ^

9506fb8e ^
d88232a3 ^
3de15ddd ^

9506fb8e ^
d88232a3 ^

9506fb8e ^

9506fb8e ^







d88232a3 ^
9506fb8e ^


419e4aa5 ^
65cb1a32 ^
419e4aa5 ^








9506fb8e ^
d88232a3 ^
3de15ddd ^
5805deca ^
f027adc0 ^
871c502d ^
dd7a4f63 ^
419e4aa5 ^
f027adc0 ^
5805deca ^
f027adc0 ^


dd7a4f63 ^
9506fb8e ^
f027adc0 ^
9506fb8e ^
f027adc0 ^
9506fb8e ^
dd7a4f63 ^
8b60e8ca ^





dd7a4f63 ^

419e4aa5 ^
dd7a4f63 ^
f027adc0 ^
5805deca ^




dd7a4f63 ^
b810fe28 ^
f027adc0 ^



419e4aa5 ^
f027adc0 ^
419e4aa5 ^
f027adc0 ^
419e4aa5 ^
5805deca ^


f027adc0 ^

dd7a4f63 ^
f027adc0 ^
dd7a4f63 ^
f027adc0 ^
dd7a4f63 ^
f027adc0 ^
dd7a4f63 ^
9506fb8e ^



dd7a4f63 ^
f027adc0 ^



9506fb8e ^
dd7a4f63 ^
d88232a3 ^
65cb1a32 ^
dd7a4f63 ^









d494f019 ^


dd7a4f63 ^





db9bb0c9 ^



dd7a4f63 ^













d88232a3 ^
dd7a4f63 ^

9506fb8e ^
d494f019 ^


22449efd ^
d494f019 ^







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
189
190
191
192
193
194
195
196
197
198
199
200
201
                                                                       
                    
 
                       




                                       
                                          
                                  
 

                                         
                                                                
 


                                                              







                                                                    
                                                                           

                                                            
                                                                              


                                                                         
                                                                            




                                            
                                                    
 

                           
                       
                                                                 

                                                               
 

                                                           

                                       







                                                                                   
                                                                          


                                                                                    
                
                                               








                                                                                                       
                                 
                                                      
                                                               
                           
 
                                 
                                                      
                                              
 
                                           


                                                        
 
                                              
                                                       
                                                                                    
                                          
                              
 





                                                                           

                                       
                                                      
                                            
                                                    




                                                       
 
                                                                             



                                                             
                                                         
                                                              
                             
                                                         
 


                                                                                          

                                                         
 
                                                
                                             
                                                                                                      
                             
                                                                                                  
 



                                                                         
                                                                                          



                                                                                  
 
                                   
                                                                                        
                                                    









                                                      


                                





                                                                                     



                                                                    













                                                                             
                                                    

                                                            
 


                                                                
                                       







                                                                     
"""The FileList widget displays the contents of a directory or file."""
from . import Widget

class FileList(Widget):
	main_display = False
	display_infostring = False
	scroll_begin = 0

	def __init__(self, win, level):
		Widget.__init__(self, win)
		self.level = level

	def click(self, event):
		"""Handle a MouseEvent"""
		from ranger.fsobject.fsobject import T_DIRECTORY

		if not (event.pressed(1) or event.pressed(3)):
			return False

		if self.target is None:
			pass

		elif self.target.type is T_DIRECTORY:
			index = self.scroll_begin + event.y - self.y

			if event.pressed(1):
				if not self.main_display:
					self.fm.enter_dir(self.target.path)

				if index < len(self.target):
					self.fm.move_pointer(absolute = index)
			elif event.pressed(3):
				try:
					clicked_file = self.target[index]
					self.fm.enter_dir(clicked_file.path)
				except:
					pass

		else:
			if self.level > 0:
				self.fm.move_right()

		return True

	def draw(self):
		"""Call either draw_file() or draw_directory()"""
		from ranger.fsobject.file import File
		from ranger.fsobject.directory import Directory

		self.target = self.env.at_level(self.level)

		if self.target is None:
			pass
		elif type(self.target) == File:
			self.draw_file()
		elif type(self.target) == Directory:
			self.draw_directory()
		else:
			self.win.addnstr(self.y, self.x, "unknown type.", self.wid)

	def draw_file(self):
		"""Draw a preview of the file, if the settings allow it"""
		if not self.target.accessible:
			self.win.addnstr(self.y, self.x, "not accessible", self.wid)
			return
		
		if self.settings.preview_files:
			try:
				if self.target.size < 1024 * 20:
					f = open(self.target.path, 'r')
					for line in range(self.hei):
						read = f.readline().expandtabs()
						self.win.addnstr(self.y + line, self.x, read, self.wid)
			except:
				pass

	def draw_directory(self):
		"""Draw the contents of a directory"""
		from ranger.fsobject.directory import Directory
		import stat

		self.target.use()
		self.target.load_content_if_outdated()
		self.target.sort_if_outdated()

		base_color = ['in_display']

		if self.main_display:
			base_color.append('maindisplay')

		if not self.target.accessible:
			self.color(base_color, 'error')
			self.win.addnstr(self.y, self.x, "not accessible", self.wid)
			self.color_reset()
			return

		if self.target.empty():
			self.color(base_color, 'empty')
			self.win.addnstr(self.y, self.x, "empty", self.wid)
			self.color_reset()
			return

		self.set_scroll_begin()

		selected_i = self.target.pointed_index
		for line in range(self.hei):
			i = line + self.scroll_begin

			try:
				drawed = self.target[i]
			except IndexError:
				break

			this_color = base_color + list(drawed.mimetype_tuple)

			if i == selected_i:
				this_color.append('selected')

			if isinstance(drawed, Directory):
				this_color.append('directory')
			else:
				this_color.append('file')

			if drawed.stat is not None and drawed.stat.st_mode & stat.S_IXUSR:
				this_color.append('executable')

			if drawed.islink:
				this_color.append('link')

			string = drawed.basename
			if self.main_display:
				self.win.addnstr(self.y + line, self.x+1, drawed.basename, self.wid-2)
			else:
				self.win.addnstr(self.y + line, self.x, drawed.basename, self.wid)

			if self.display_infostring and drawed.infostring:
				info = drawed.infostring
				x = self.x + self.wid - 1 - len(info)
				if x > self.x:
					self.win.addstr(self.y + line, x, str(info) + ' ')

			self.color_at(self.y + line, self.x, self.wid, this_color)

			self.color_reset()

	def get_scroll_begin(self):
		"""Determines scroll_begin (the position of the first displayed file)"""
		offset = self.settings.scroll_offset
		dirsize = len(self.target)
		winsize = self.hei
		halfwinsize = winsize // 2
		index = self.target.pointed_index or 0
		original = self.target.scroll_begin
		projected = index - original

		upper_limit = winsize - 1 - offset
		lower_limit = offset

		if original < 0:
			return 0

		if dirsize < winsize:
			return 0

		if halfwinsize < offset:
			return min( dirsize - winsize, max( 0, index - halfwinsize ))

		if original > dirsize - winsize:
			self.target.scroll_begin = dirsize - winsize
			return self.get_scroll_begin()

		if projected < upper_limit and projected > lower_limit:
			return original

		if projected > upper_limit:
			return min( dirsize - winsize,
					original + (projected - upper_limit))

		if projected < upper_limit:
			return max( 0,
					original - (lower_limit - projected))
		
		return original

	def set_scroll_begin(self):
		"""Updates the scroll_begin value"""
		self.scroll_begin = self.get_scroll_begin()
		self.target.scroll_begin = self.scroll_begin

	# 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
		self.set_scroll_begin()

		if self.target.scroll_begin == old_value:
			self.target.move_pointer(relative = relative)
			self.target.scroll_begin += relative