summary refs log tree commit diff stats
path: root/ranger
Commit message (Expand)AuthorAgeFilesLines
...
* help.movement: updated 1.6: there is no "tab 0" anymorehut2010-05-021-1/+1
* ranger.help: fixed topicshut2010-05-023-3/+5
* widgets.browsercolumn: call move_parent when scrolling in second columnhut2010-05-023-8/+19
* bugfix: scroll faster with ctrlhut2010-05-021-1/+1
* added help chapter 5, ranger/help/invocation.pyhut2010-04-303-1/+109
* extended and documented u* key combinationshut2010-04-302-2/+6
* defaults.keys: implement I keyhut2010-04-302-1/+5
* defaults.keys: new tabs start in the home directoryhut2010-04-301-1/+4
* api.commands: bugfix (renamed Command.quick_open to Command.quick)hut2010-04-302-3/+3
* some more doc updatesSitaram Chamarty2010-04-302-10/+15
* Added documentation for remaining key combinations (excluding z*, g*,...)hut2010-04-293-4/+29
* help.console: updatedhut2010-04-281-4/+10
* widgets.console: added macro %dhut2010-04-281-0/+5
* widgets.console: give a local variable a more meaningful namehut2010-04-281-7/+7
* widgets.console: added macros %t and %c in the OpenConsolehut2010-04-272-2/+15
* Merge branch 'generic'hut2010-04-272-64/+41
|\
| * defaults.apps: added a hinthut2010-04-271-0/+1
| * api.apps: more stuffhut2010-04-271-9/+13
| * api.apps: simplified generic app handlerhut2010-04-272-38/+27
| * api.apps: added generic app handlershut2010-04-272-62/+45
* | Fixed #85: no automatic reload after using :filterhut2010-04-271-0/+1
* | defaults.options: slight rearranginghut2010-04-271-4/+4
* | defaults.commands: Added :unmarkhut2010-04-272-8/+17
* | defaults.commands: redraw after using :markhut2010-04-271-0/+2
* | defaults.commands: added optional "minus" argument for :markhut2010-04-272-4/+8
* | Added :mark commandhut2010-04-272-0/+25
|/
* defaults.apps: don't run *.swf in elinks ;(hut2010-04-261-2/+2
* defaults.apps: moved INTERPRETED_LANGUAGES to the bottomhut2010-04-261-5/+5
* defaults.apps: use "f = c.file" in the examplehut2010-04-261-2/+3
* api.apps: Removed unnecessary (?) docstringhut2010-04-261-4/+0
* removed trailing whitespacehut2010-04-261-1/+1
* api.options: removed unused importhut2010-04-261-1/+0
* defaults.commands: use octal literal instead of decimal number in chmod()hut2010-04-261-1/+1
* defaults.commands: fixed :find with uppercase search stringshut2010-04-261-1/+5
* widgets.pager: Fixed off-by-one error for boundarieshut2010-04-261-2/+2
* Fixed bug #65 by adding flag "--fail-if-run"hut2010-04-261-1/+4
* fixed bug #78: broken preview when deleting all files in a directoryhut2010-04-261-0/+1
* core.actions: implemented "move_parent", improve this later!hut2010-04-261-0/+5
* widgets.browsercolumn: fixed width-check for infostringhut2010-04-261-1/+1
* shutil_generatorized: fixed bad destination name on move+overwritehut2010-04-261-2/+2
* gui.colorscheme: fixed error when using custom colorschemeshut2010-04-261-0/+4
* fsobject.directory: removed invalid signal binding 'setopt.filter'hut2010-04-261-1/+1
* ranger.defaults.apps: use "make" for Makefileshut2010-04-231-0/+3
* main: fixed "ranger /path/to/a/file"hut2010-04-231-4/+6
* main: new function "load_apps"hut2010-04-231-0/+13
* main: new function "allow_access_to_confdir"hut2010-04-231-6/+14
* Move loader.py from ranger.fsobject to ranger.corehut2010-04-204-3/+2
* ext.shutil_generatorized: fixed __all__hut2010-04-201-1/+1
* ext.shutil_generatorized: little optimizationhut2010-04-201-2/+2
* ext.shutil_generatorized: remove unused functions/importshut2010-04-201-36/+0
ring.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
-----------------------------------------------------------------------------
-- LuaSocket helper module
-- Author: Diego Nehab
-----------------------------------------------------------------------------

local _M = socket

-----------------------------------------------------------------------------
-- Exported auxiliar functions
-----------------------------------------------------------------------------
function _M.connect4(address, port, laddress, lport)
    return socket.connect(address, port, laddress, lport, "inet")
end

function _M.connect6(address, port, laddress, lport)
    return socket.connect(address, port, laddress, lport, "inet6")
end

function _M.bind(host, port, backlog)
    if host == "*" then host = "0.0.0.0" end
    local addrinfo, err = socket.dns.getaddrinfo(host);
    if not addrinfo then return nil, err end
    local sock, res
    err = "no info on address"
    for i, alt in ipairs(addrinfo) do
        if alt.family == "inet" then
            sock, err = socket.tcp4()
        else
            sock, err = socket.tcp6()
        end
        if not sock then return nil, err end
        sock:setoption("reuseaddr", true)
        res, err = sock:bind(alt.addr, port)
        if not res then
            sock:close()
        else
            res, err = sock:listen(backlog)
            if not res then
                sock:close()
            else
                return sock
            end
        end
    end
    return nil, err
end

_M.try = _M.newtry()

function _M.choose(table)
    return function(name, opt1, opt2)
        if type(name) ~= "string" then
            name, opt1, opt2 = "default", name, opt1
        end
        local f = table[name or "nil"]
        if not f then error("unknown key (".. tostring(name) ..")", 3)
        else return f(opt1, opt2) end
    end
end

-----------------------------------------------------------------------------
-- Socket sources and sinks, conforming to LTN12
-----------------------------------------------------------------------------
-- create namespaces inside LuaSocket namespace
local sourcet, sinkt = {}, {}
_M.sourcet = sourcet
_M.sinkt = sinkt

_M.BLOCKSIZE = 2048

sinkt["close-when-done"] = function(sock)
    return setmetatable({
        getfd = function() return sock:getfd() end,
        dirty = function() return sock:dirty() end
    }, {
        __call = function(self, chunk, err)
            if not chunk then
                sock:close()
                return 1
            else return sock:send(chunk) end
        end
    })
end

sinkt["keep-open"] = function(sock)
    return setmetatable({
        getfd = function() return sock:getfd() end,
        dirty = function() return sock:dirty() end
    }, {
        __call = function(self, chunk, err)
            if chunk then return sock:send(chunk)
            else return 1 end
        end
    })
end

sinkt["default"] = sinkt["keep-open"]

_M.sink = _M.choose(sinkt)

sourcet["by-length"] = function(sock, length)
    return setmetatable({
        getfd = function() return sock:getfd() end,
        dirty = function() return sock:dirty() end
    }, {
        __call = function()
            if length <= 0 then return nil end
            local size = math.min(socket.BLOCKSIZE, length)
            local chunk, err = sock:receive(size)
            if err then return nil, err end
            length = length - string.len(chunk)
            return chunk
        end
    })
end

sourcet["until-closed"] = function(sock)
    local done
    return setmetatable({
        getfd = function() return sock:getfd() end,
        dirty = function() return sock:dirty() end
    }, {
        __call = function()
            if done then return nil end
            local chunk, err, partial = sock:receive(socket.BLOCKSIZE)
            if not err then return chunk
            elseif err == "closed" then
                sock:close()
                done = 1
                return partial
            else return nil, err end
        end
    })
end


sourcet["default"] = sourcet["until-closed"]

_M.source = _M.choose(sourcet)

return _M