about summary refs log tree commit diff stats
path: root/config.default.h
blob: ec1804f0d2941a4f86e9aeeaf6fbefb399478205 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
 * See LICENSE file for license details.
 */

enum { Tfnord, Tdev, Tnet, Twork, Tmisc, TLast };
#define TAGS \
const char *tags[TLast] = { \
	[Tfnord] = "fnord", \
	[Tdev] = "dev", \
	[Tnet] = "net", \
	[Twork] = "work", \
	[Tmisc] = "misc", \
};

#define DEFMODE			dotile /* dofloat */
#define DEFTAG			Tdev
#define FONT			"fixed"
#define BGCOLOR			"#666699"
#define FGCOLOR			"#eeeeee"
#define BORDERCOLOR		"#9999CC"
#define MODKEY			Mod1Mask
#define NUMLOCKMASK		Mod2Mask
#define MASTERW			60 /* percent */

#define KEYS \
	const char *term[] = { "xterm", NULL }; \
static Key key[] = { \
	/* modifier		key		function	arguments */ \
	{ MODKEY,		XK_0,		view,		{ .i = Tfnord } }, \
	{ MODKEY,		XK_1,		view,		{ .i = Tdev } }, \
	{ MODKEY,		XK_2,		view,		{ .i = Tnet } }, \
	{ MODKEY,		XK_3,		view,		{ .i = Twork } }, \
	{ MODKEY,		XK_4,		view,		{ .i = Tmisc} }, \
	{ MODKEY,		XK_h,		viewprev,	{ 0 } }, \
	{ MODKEY,		XK_j,		focusnext,	{ 0 } }, \
	{ MODKEY,		XK_k,		focusprev,	{ 0 } }, \
	{ MODKEY,		XK_l,		viewnext,	{ 0 } }, \
	{ MODKEY,		XK_m,		togglemax,	{ 0 } }, \
	{ MODKEY,		XK_space,	togglemode,	{ 0 } }, \
	{ MODKEY,		XK_Return,	zoom,		{ 0 } }, \
	{ MODKEY|ControlMask,	XK_0,		appendtag,	{ .i = Tfnord } }, \
	{ MODKEY|ControlMask,	XK_1,		appendtag,	{ .i = Tdev } }, \
	{ MODKEY|ControlMask,	XK_2,		appendtag,	{ .i = Tnet } }, \
	{ MODKEY|ControlMask,	XK_3,		appendtag,	{ .i = Twork } }, \
	{ MODKEY|ControlMask,	XK_4,		appendtag,	{ .i = Tmisc } }, \
	{ MODKEY|ShiftMask,	XK_0,		replacetag,	{ .i = Tfnord } }, \
	{ MODKEY|ShiftMask,	XK_1,		replacetag,	{ .i = Tdev } }, \
	{ MODKEY|ShiftMask,	XK_2,		replacetag,	{ .i = Tnet } }, \
	{ MODKEY|ShiftMask,	XK_3,		replacetag,	{ .i = Twork } }, \
	{ MODKEY|ShiftMask,	XK_4,		replacetag,	{ .i = Tmisc } }, \
	{ MODKEY|ShiftMask,	XK_c,		killclient,	{ 0 } }, \
	{ MODKEY|ShiftMask,	XK_q,		quit,		{ 0 } }, \
	{ MODKEY|ShiftMask,	XK_Return,	spawn,		{ .argv = term } }, \
};

#define RULES \
static Rule rule[] = { \
	/* class:instance	tags				isfloat */ \
	{ "Firefox.*",		{ [Tnet] = True },		False }, \
	{ "Gimp.*",		{ 0 },				True}, \
};
lect.lua?id=4ab901c92e11f47828bc7f5f16d8d2250812d53f'>^
1bdb931 ^
a655c21 ^
3850fba ^
876d629 ^
3850fba ^
e2696fc ^
1bdb931 ^


2ae9cac ^
9656e13 ^
3114176 ^

0d52962 ^
188bbc7 ^
9d792a2 ^

0d52962 ^

9656e13 ^
0d52962 ^

188bbc7 ^




0d52962 ^







a655c21 ^

0d52962 ^
a655c21 ^
0d52962 ^

a655c21 ^
0d52962 ^
a655c21 ^
0d52962 ^
a655c21 ^
e77157d ^
0d52962 ^
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

                                         
                                                                                   


                                                                                
                                                                                               
                                                 
                                                           


                                                              
                 
                           
                                     
      
                                                    
     

                                         

                         








                                                                           














                                               
                                                                                                            

                                                          
                                                          
            


                                                  



                     
                                                           
                               
       
                                                   
                              
                                                                              
                         
                


     
                              
                                          

                                                             
     
                                               

                                                                    

       
                                                                                               

   




                                                              







                           

                                                              
                      
                                                               

                     
                                                         
                        
                                             
     
                                                                   
                                   
   
-- helpers for selecting portions of text

-- Return any intersection of the region from State.selection1 to State.cursor1 (or
-- current mouse, if mouse is pressed; or recent mouse if mouse is pressed and
-- currently over a drawing) with the region between {line=line_index, pos=apos}
-- and {line=line_index, pos=bpos}.
-- apos must be less than bpos. However State.selection1 and State.cursor1 can be in any order.
-- Result: positions spos,epos between apos,bpos.
function Text.clip_selection(State, line_index, apos, bpos)
  if State.selection1.line == nil then return nil,nil end
  -- min,max = sorted(State.selection1,State.cursor1)
  local minl,minp = State.selection1.line,State.selection1.pos
  local maxl,maxp
  if App.mouse_down(1) then
    maxl,maxp = Text.mouse_pos(State)
  else
    maxl,maxp = State.cursor1.line,State.cursor1.pos
  end
  if Text.lt1({line=maxl, pos=maxp},
              {line=minl, pos=minp}) then
    minl,maxl = maxl,minl
    minp,maxp = maxp,minp
  end
  -- check if intervals are disjoint
  if line_index < minl then return nil,nil end
  if line_index > maxl then return nil,nil end
  if line_index == minl and bpos <= minp then return nil,nil end
  if line_index == maxl and apos >= maxp then return nil,nil end
  -- compare bounds more carefully (start inclusive, end exclusive)
  local a_ge = Text.le1({line=minl, pos=minp}, {line=line_index, pos=apos})
  local b_lt = Text.lt1({line=line_index, pos=bpos}, {line=maxl, pos=maxp})
  if a_ge and b_lt then
    -- fully contained
    return apos,bpos
  elseif a_ge then
    assert(maxl == line_index)
    return apos,maxp
  elseif b_lt then
    assert(minl == line_index)
    return minp,bpos
  else
    assert(minl == maxl and minl == line_index)
    return minp,maxp
  end
end

-- draw highlight for line corresponding to (lo,hi) given an approximate x,y and pos on the same screen line
-- Creates text objects every time, so use this sparingly.
-- Returns some intermediate computation useful elsewhere.
function Text.draw_highlight(State, line, x,y, pos, lo,hi)
  if lo then
    local lo_offset = Text.offset(line.data, lo)
    local hi_offset = Text.offset(line.data, hi)
    local pos_offset = Text.offset(line.data, pos)
    local lo_px
    if pos == lo then
      lo_px = 0
    else
      local before = line.data:sub(pos_offset, lo_offset-1)
      lo_px = App.width(before)
    end
    local s = line.data:sub(lo_offset, hi_offset-1)
    App.color(Highlight_color)
    love.graphics.rectangle('fill', x+lo_px,y, App.width(s),State.line_height)
    App.color(Text_color)
    return lo_px
  end
end

function Text.mouse_pos(State)
  local x,y = App.mouse_x(), App.mouse_y()
  if y < State.line_cache[State.screen_top1.line].starty then
    return State.screen_top1.line, State.screen_top1.pos
  end
  for line_index,line in ipairs(State.lines) do
    if Text.in_line(State, line_index, x,y) then
      return line_index, Text.to_pos_on_line(State, line_index, x,y)
    end
  end
  return State.screen_bottom1.line, Text.pos_at_end_of_screen_line(State, State.screen_bottom1)
end

function Text.selection(State)
  if State.selection1.line == nil then return end
  -- min,max = sorted(State.selection1,State.cursor1)
  local minl,minp = State.selection1.line,State.selection1.pos
  local maxl,maxp = State.cursor1.line,State.cursor1.pos
  if minl > maxl then
    minl,maxl = maxl,minl
    minp,maxp = maxp,minp
  elseif minl == maxl then
    if minp > maxp then
      minp,maxp = maxp,minp
    end
  end
  local min_offset = Text.offset(State.lines[minl].data, minp)
  local max_offset = Text.offset(State.lines[maxl].data, maxp)
  if minl == maxl then
    return State.lines[minl].data:sub(min_offset, max_offset-1)
  end
  assert(minl < maxl)
  local result = {State.lines[minl].data:sub(min_offset)}
  for i=minl+1,maxl-1 do
    table.insert(result, State.lines[i].data)
  end
  table.insert(result, State.lines[maxl].data:sub(1, max_offset-1))
  return table.concat(result, '\n')
end