about summary refs log tree commit diff stats
path: root/README
blob: 4860bbe53e4101c125319ff65857917f01e1da33 (plain) (blame)
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
dwm - dynamic window manager
----------------------------
dwm is an extremely fast, small, and dynamic window manager for X.


Requirements
------------
In order to build dwm you need the Xlib header files.


Installation
------------
Edit config.mk to match your local setup (dwm is installed into
the /usr/local namespace by default).

Afterwards enter the following command to build and install dwm (if
necessary as root):

    make clean install


Running dwm
-----------
Add the following line to your .xinitrc to start dwm using startx:

    exec dwm

In order to connect dwm to a specific display, make sure that
the DISPLAY environment variable is set correctly, e.g.:

    DISPLAY=foo.bar:1 exec dwm

(This will start dwm on display :1 of the host foo.bar.)

In order to display status info in the bar, you can do something
like this in your .xinitrc:

    while true
    do
        echo `date` `uptime | sed 's/.*://; s/,//g'`
        sleep 1
    done | dwm


Configuration
-------------
The configuration of dwm is done by creating a custom config.h
and (re)compiling the source code.
;hut@lavabit.com> 2009-12-15 11:15:01 +0100 different way of squeezing the last column' href='/akspecs/ranger/commit/ranger/gui/widgets/filelistcontainer.py?id=705c14a48645f6e7e4b318a5a3f4f7a6c7b96c80'>705c14a4 ^
49ae0dd1 ^




8db3c4b1 ^
a6791aee ^
49ae0dd1 ^

8db3c4b1 ^
49ae0dd1 ^
8db3c4b1 ^
49ae0dd1 ^
8db3c4b1 ^
77f59786 ^
06aefcf5 ^
c1033553 ^
a6791aee ^
08f21ae5 ^













28e13b12 ^
08f21ae5 ^
28e13b12 ^
08f21ae5 ^
501f5014 ^



08f21ae5 ^




4f51adb3 ^
49ae0dd1 ^

8db3c4b1 ^
49ae0dd1 ^
d3eff0a9 ^
d621586e ^
705c14a4 ^

d621586e ^

705c14a4 ^
d621586e ^


06aefcf5 ^

d621586e ^
49ae0dd1 ^
705c14a4 ^
06aefcf5 ^
705c14a4 ^

06aefcf5 ^
d3eff0a9 ^
06aefcf5 ^
49ae0dd1 ^
d3eff0a9 ^
49ae0dd1 ^

705c14a4 ^
49ae0dd1 ^
d621586e ^
b4cb1f7d ^








06aefcf5 ^
a6791aee ^

06aefcf5 ^

a6791aee ^

06aefcf5 ^



a6791aee ^

06aefcf5 ^

a6791aee ^

06aefcf5 ^


d621586e ^

ef81960b ^
06aefcf5 ^
d621586e ^

d3eff0a9 ^
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
                                                      
                    
                                        
                        

                                              
                                                

                      
                                
                             
                          




                                                        

                                      


                                                                         
 
                                         


                                                                                     




                                                
                                                                    
                                          

                    
                                                                               
                                  
                                               
                     
                                                                  
                                                           
 
                                                           
                                          













                                                         
                                                            
                                
                                                                     
 



                                                                                  




                                                             
                                                                             

                                         
                                                                         
                                                                 
                        
 

                                                                            

                                
                                                                                     


                                                                             

                                             
                                          
                                                   
 
                                       

                                                              
                                           
                                                                                        
 
                            
                                                                                     

                                        
 
                                   
        








                                                               
                             

                                         

                                 

                                                          



                                  

                                          

                                  

                                                         


                                  

                                               
                                                                   
                                                                      

                                                                    
                                                                               
"""The BrowserView manages a set of BrowserColumns."""
from . import Widget
from .browsercolumn import BrowserColumn
from .pager import Pager
from ..displayable import DisplayableContainer

class BrowserView(Widget, DisplayableContainer):
	ratios = None
	preview = True
	preview_available = True
	stretch_ratios = None
	need_clear = False

	def __init__(self, win, ratios, preview = True):
		DisplayableContainer.__init__(self, win)
		from functools import reduce
		self.ratios = ratios
		self.preview = preview

		# normalize ratios:
		ratio_sum = float(reduce(lambda x,y: x + y, ratios))
		self.ratios = tuple(map(lambda x: x / ratio_sum, ratios))

		if len(self.ratios) >= 2:
			self.stretch_ratios = self.ratios[:-2] + \
					((self.ratios[-2] + self.ratios[-1] * 0.9), \
					(self.ratios[-1] * 0.1))
		
		offset = 1 - len(ratios)
		if preview: offset += 1

		for level in range(len(ratios)):
			fl = BrowserColumn(self.win, level + offset)
			self.add_child(fl)

		try:
			self.main_column = self.container[preview and -2 or -1]
		except IndexError:
			self.main_column = None
		else:
			self.main_column.display_infostring = True
			self.main_column.main_column = True

		self.pager = Pager(self.win, embedded=True)
		self.add_child(self.pager)

	def draw(self):
		if str(self.env.keybuffer) in ("`", "'"):
			self._draw_bookmarks()
		else:
			if self.need_clear:
				self.win.erase()
				self.need_redraw = True
				self.need_clear = False
			DisplayableContainer.draw(self)
	
	def _draw_bookmarks(self):
		self.need_clear = True

		sorted_bookmarks = sorted(self.fm.bookmarks)
		def generator():
			return zip(range(self.hei), sorted_bookmarks)

		try:
			maxlen = max(len(item[1].path) for i, item in generator())
		except ValueError:
			return
		maxlen = min(maxlen + 5, self.wid)

		for line, items in generator():
			key, mark = items
			string = " " + key + ": " + mark.path
			self.addnstr(line, 0, string.ljust(maxlen), self.wid)
	
	def resize(self, y, x, hei, wid):
		"""Resize all the columns according to the given ratio"""
		DisplayableContainer.resize(self, y, x, hei, wid)
		left = 0

		cut_off_last = self.preview and not self.preview_available \
				and self.stretch_ratios

		if cut_off_last:
			generator = zip(self.stretch_ratios, range(len(self.ratios)))
		else:
			generator = zip(self.ratios, range(len(self.ratios)))

		last_i = len(self.ratios) - 1

		for ratio, i in generator:
			wid = int(ratio * self.wid)

			if i == last_i:
				wid = int(self.wid - left + 1)

			if i == last_i - 1:
				self.pager.resize(0, left, hei, max(1, self.wid - left))

			try:
				self.container[i].resize(0, left, hei, max(1, wid-1))
			except KeyError:
				pass

			left += wid
	
	def click(self, event):
		n = event.ctrl() and 1 or 3
		if event.pressed(4):
			self.fm.scroll(relative = -n)
		elif event.pressed(2) or event.key_invalid():
			self.fm.scroll(relative = n)
		else:
			DisplayableContainer.click(self, event)
	
	def open_pager(self):
		self.pager.visible = True
		self.pager.focused = True
		self.pager.open()
		try:
			self.container[-2].visible = False
			self.container[-3].visible = False
		except IndexError:
			pass
	
	def close_pager(self):
		self.pager.visible = False
		self.pager.focused = False
		self.pager.close()
		try:
			self.container[-2].visible = True
			self.container[-3].visible = True
		except IndexError:
			pass
	
	def poke(self):
		DisplayableContainer.poke(self)
		if self.settings.collapse_preview and self.preview:
			has_preview = self.container[-2].has_preview()
			if self.preview_available != has_preview:
				self.preview_available = has_preview
				self.resize(self.y, self.x, self.hei, self.wid)