let s shift globally

This commit is contained in:
Xinhao Yuan 2019-07-05 10:26:37 -04:00
parent 14d055c118
commit 512811d3a7
2 changed files with 15 additions and 6 deletions

View File

@ -33,7 +33,7 @@ Undefined parameters are (mostly) treated as 1.
1. `Up`/`Down`: restore to the history command sequence 1. `Up`/`Down`: restore to the history command sequence
2. `h`/`v`: split the current region horizontally/vertically into 2 regions. The split will respect the ratio A:B. 2. `h`/`v`: split the current region horizontally/vertically into 2 regions. The split will respect the ratio A:B.
3. `w`: Take two parameters (A, B), and split the current region equally into A columns and B rows. If no parameter is defined, behave the same as `Space` without parameters. 3. `w`: Take two parameters (A, B), and split the current region equally into A columns and B rows. If no parameter is defined, behave the same as `Space` without parameters.
4. `s`: shift the current editing region with other open sibling regions. If A is defined, shift for A times. 4. `s`: shift the current editing region with other open regions. If A is defined, shift for A times.
5. `Space` or `-`: Without parameters, close the current region and move to the next open region. With parameters, set the maximum depth of splitting (default is 2). 5. `Space` or `-`: Without parameters, close the current region and move to the next open region. With parameters, set the maximum depth of splitting (default is 2).
6. `Enter`/`.`: close all open regions. When all regions are closed, press `Enter` will save the layout and exit the editor. 6. `Enter`/`.`: close all open regions. When all regions are closed, press `Enter` will save the layout and exit the editor.
7. `Backspace`: undo the last command. 7. `Backspace`: undo the last command.

View File

@ -125,7 +125,8 @@ function start_editor(data)
height = screen.workarea.height, height = screen.workarea.height,
border = 15, border = 15,
depth = 0, depth = 0,
-- we do not want to rely on bitop group_id = 0,
-- we do not want to rely on BitOp
bl = true, br = true, bu = true, bd = true, bl = true, br = true, bu = true, bd = true,
} }
local kg local kg
@ -289,7 +290,11 @@ function start_editor(data)
infobox.bgimage = draw_info infobox.bgimage = draw_info
end end
local split_count = 0
local function handle_split(method, alt) local function handle_split(method, alt)
split_count = split_count + 1
if num_1 == nil then num_1 = 1 end if num_1 == nil then num_1 = 1 end
if num_2 == nil then num_2 = 1 end if num_2 == nil then num_2 = 1 end
@ -309,12 +314,14 @@ function start_editor(data)
x = a.x, y = a.y, x = a.x, y = a.y,
width = a.width / (num_1 + num_2) * num_1, height = a.height, width = a.width / (num_1 + num_2) * num_1, height = a.height,
depth = a.depth + 1, depth = a.depth + 1,
group_id = split_count,
bl = a.bl, br = false, bu = a.bu, bd = a.bd, bl = a.bl, br = false, bu = a.bu, bd = a.bd,
} }
rd = { rd = {
x = a.x + lu.width, y = a.y, x = a.x + lu.width, y = a.y,
width = a.width - lu.width, height = a.height, width = a.width - lu.width, height = a.height,
depth = a.depth + 1, depth = a.depth + 1,
group_id = split_count,
bl = false, br = a.br, bu = a.bu, bd = a.bd, bl = false, br = a.br, bu = a.bu, bd = a.bd,
} }
open_areas[#open_areas + 1] = rd open_areas[#open_areas + 1] = rd
@ -324,12 +331,14 @@ function start_editor(data)
x = a.x, y = a.y, x = a.x, y = a.y,
width = a.width, height = a.height / (num_1 + num_2) * num_1, width = a.width, height = a.height / (num_1 + num_2) * num_1,
depth = a.depth + 1, depth = a.depth + 1,
group_id = split_count,
bl = a.bl, br = a.br, bu = a.bu, bd = false bl = a.bl, br = a.br, bu = a.bu, bd = false
} }
rd = { rd = {
x = a.x, y = a.y + lu.height, x = a.x, y = a.y + lu.height,
width = a.width, height = a.height - lu.height, width = a.width, height = a.height - lu.height,
depth = a.depth + 1, depth = a.depth + 1,
group_id = split_count,
bl = a.bl, br = a.br, bu = false, bd = a.bd, bl = a.bl, br = a.br, bu = false, bd = a.bd,
} }
open_areas[#open_areas + 1] = rd open_areas[#open_areas + 1] = rd
@ -344,7 +353,8 @@ function start_editor(data)
y = a.y + y_interval * (y - 1), y = a.y + y_interval * (y - 1),
width = x_interval, width = x_interval,
height = y_interval, height = y_interval,
depth = a.depth + 1 depth = a.depth + 1,
group_id = split_count,
} }
if x == 1 then r.bl = a.bl else r.bl = false end if x == 1 then r.bl = a.bl else r.bl = false end
if x == num_1 then r.br = a.br else r.br = false end if x == num_1 then r.br = a.br else r.br = false end
@ -387,9 +397,8 @@ function start_editor(data)
if #open_areas > 0 then if #open_areas > 0 then
key = "s" key = "s"
local times = num_1 or 1 local times = num_1 or 1
local top = pop_open_area() local t = {}
local t = {top} while #open_areas > 0 do
while #open_areas > 0 and open_areas[#open_areas].depth == top.depth do
t[#t + 1] = pop_open_area() t[#t + 1] = pop_open_area()
end end
for i = #t, 1, -1 do for i = #t, 1, -1 do