dotfiles

*nix config files
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

duplicates.lua (1534B)


      1 local functions = require("utils.functions")
      2 
      3 local X = {}
      4 
      5 local duplicates_n = {}
      6 local duplicates_v = {}
      7 local duplicates_i = {}
      8 local duplicates_s = {}
      9 local duplicates_x = {}
     10 
     11 local function check_and_set_duplicates(input, description, check, table)
     12 	if check then
     13 		local found = table[input]
     14 
     15 		if found ~= nil then
     16 			if found ~= description then
     17 				print(input .. " already mapped (" .. found .. " so we cannot re-map (" .. description .. ")")
     18 			end
     19 		end
     20 
     21 		table[input] = description
     22 	end
     23 end
     24 
     25 X.check_duplicates = function(type, input, description)
     26 	local check_n = false
     27 	local check_v = false
     28 	local check_i = false
     29 	local check_s = false
     30 	local check_x = false
     31 
     32 	if functions.is_table(type) then
     33 		if type["n"] then
     34 			check_n = true
     35 		end
     36 		if type["v"] then
     37 			check_v = true
     38 		end
     39 		if type["i"] then
     40 			check_i = true
     41 		end
     42 		if type["s"] then
     43 			check_s = true
     44 		end
     45 		if type["x"] then
     46 			check_x = true
     47 		end
     48 	else
     49 		if type == "n" then
     50 			check_n = true
     51 		end
     52 		if type == "v" then
     53 			check_v = true
     54 		end
     55 		if type == "i" then
     56 			check_i = true
     57 		end
     58 		if type == "s" then
     59 			check_s = true
     60 		end
     61 		if type == "x" then
     62 			check_x = true
     63 		end
     64 	end
     65 
     66 	check_and_set_duplicates(input, description, check_n, duplicates_n)
     67 	check_and_set_duplicates(input, description, check_v, duplicates_v)
     68 	check_and_set_duplicates(input, description, check_i, duplicates_i)
     69 	check_and_set_duplicates(input, description, check_s, duplicates_s)
     70 	check_and_set_duplicates(input, description, check_x, duplicates_x)
     71 end
     72 
     73 return X