diff options
author | Josh Rahm <rahm@google.com> | 2024-03-14 17:12:11 +0000 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2024-03-14 17:12:11 +0000 |
commit | 0b8f5ede2d37ad302f9a892b7bc099cb3bdfaca0 (patch) | |
tree | 9099e96b442e8028b8be5bd203c7ed78b3bf542a /lua | |
parent | 8371d5a089c4ce91d77b15281c9ddaf5ea989a51 (diff) | |
download | nvim-warp-0b8f5ede2d37ad302f9a892b7bc099cb3bdfaca0.tar.gz nvim-warp-0b8f5ede2d37ad302f9a892b7bc099cb3bdfaca0.tar.bz2 nvim-warp-0b8f5ede2d37ad302f9a892b7bc099cb3bdfaca0.zip |
Change the big line to be one I generated from an Eularian tour.
Diffstat (limited to 'lua')
-rw-r--r-- | lua/warp/col_selectors/grid.lua | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/lua/warp/col_selectors/grid.lua b/lua/warp/col_selectors/grid.lua index e00d590..ce99b96 100644 --- a/lua/warp/col_selectors/grid.lua +++ b/lua/warp/col_selectors/grid.lua @@ -3,41 +3,39 @@ local vim = assert(vim) local util = require('warp.util') local M = {} -local hsel1 = "thnrdlcmwfpgkbvjxzq" -- 19 -local hsel2 = "aeiouys" -- 7 - -local function char_at(s, i) - local m = (i % #s) + 1 - return string.sub(s, m, m) -end - -local function make_big_line() - local col = 0 - local line = '' - - local v = '' - local c = nil - local i = 0 +local big_line, col_map = (function () + -- Longest possible line alternating between vowels and (vowels + consanants) + -- which does not have a repeated substring of length 2. + -- + -- Size is 5*(26 + 21) + 1 + -- + -- It can reference up 235 unique columns. That should be enough even for + -- Java. + local big_line = + "tetaoinuserahodilucemafoyiwugepabovikuxeqajozitunesarohidulecamofiyuw" + .. "egapobivukexaqojizutonasirehudelacomifuyewagopibuvekaxoqijuzenotisuri" + .. "hadalocumefeyawogipubevakoxiqujezanicimuhedosorufayoligupebavowixuqej" + .. "azokieaueoaiuaeiouooeeuuiiaat" local col_map = {} - while true do - v = char_at(hsel1, i) - if c then - if col_map[c .. v] then break end - col_map[c .. v] = col + local i = 0 + + while i < #big_line do + local sub = big_line:sub(i, i + 1) + if col_map[sub] then + -- Sanity check + error("repeated sequence: '" .. sub .. "'", 2) end - c = char_at(hsel2, i) - col = col + 1 - if col_map[v .. c] then break end - col_map[v .. c] = col - line = line .. v .. c - col = col + 1 + col_map[sub] = i i = i + 1 end - return line, col_map -end + return big_line, col_map +end)() -local big_line, col_map = make_big_line() +local function char_at(s, i) + local m = (i % #s) + 1 + return string.sub(s, m, m) +end M.strategy = function() local filter |