about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorarg@mig29 <unknown>2007-01-02 16:29:01 +0100
committerarg@mig29 <unknown>2007-01-02 16:29:01 +0100
commit21898c6049ea66dae34a660598684a7babec1097 (patch)
tree04bec17fb42610ca5b5faf8cb490cdb304f32e0a
parent6a9300e8158ec0c35d92f09e886c653758408948 (diff)
downloaddwm-21898c6049ea66dae34a660598684a7babec1097.tar.gz
using more thinkpad compliant colors
-rw-r--r--config.arg.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/config.arg.h b/config.arg.h
index 85d86c9..cbf181a 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -15,7 +15,7 @@ const char *tags[] = { "dev", "work", "net", "fnord", NULL };
 #define SELBGCOLOR		"#444444"
 #define SELFGCOLOR		"#ffffff"
 #define STATUSBGCOLOR		"#222222"
-#define STATUSFGCOLOR		"#99ccff"
+#define STATUSFGCOLOR		"#ccff00"
 
 #define MASTER			600		/* per thousand */
 #define MODKEY			Mod1Mask
8 129 130 131 132 133 134
# -*- coding: utf-8 -*-
# This file is part of ranger, the console file manager.
# License: GNU GPL version 3, see the file "AUTHORS" for details.
# Author: Wojciech Siewierski <wojciech.siewierski@onet.pl>, 2018

from __future__ import (absolute_import, division, print_function)

import re

from ranger.container.directory import accept_file, InodeFilterConstants

# pylint: disable=too-few-public-methods


class BaseFilter(object):
    def decompose(self):
        return [self]


SIMPLE_FILTERS = {}
FILTER_COMBINATORS = {}


def stack_filter(filter_name):
    def decorator(cls):
        SIMPLE_FILTERS[filter_name] = cls
        return cls
    return decorator


def filter_combinator(combinator_name):
    def decorator(cls):
        FILTER_COMBINATORS[combinator_name] = cls
        return cls
    return decorator


@stack_filter("name")
class NameFilter(BaseFilter):
    def __init__(self, pattern):
        self.pattern = pattern
        self.regex = re.compile(pattern)

    def __call__(self, fobj):
        return self.regex.search(fobj.relative_path)

    def __str__(self):
        return "<Filter: name =~ /{}/>".format(self.pattern)


@stack_filter("type")
class TypeFilter(BaseFilter):
    type_to_function = {
        InodeFilterConstants.DIRS:
        (lambda fobj: fobj.is_directory),
        InodeFilterConstants.FILES:
        (lambda fobj: fobj.is_file and not fobj.is_link),
        InodeFilterConstants.LINKS:
        (lambda fobj: fobj.is_link),
    }

    def __init__(self, filetype):
        if filetype not in self.type_to_function:
            raise KeyError(filetype)
        self.filetype = filetype

    def __call__(self, fobj):
        return self.type_to_function[self.filetype](fobj)

    def __str__(self):
        return "<Filter: type == '{}'>".format(self.filetype)


@filter_combinator("or")
class OrFilter(BaseFilter):
    def __init__(self, stack):
        self.subfilters = [stack[-2], stack[-1]]

        stack.pop()
        stack.pop()

        stack.append(self)

    def __call__(self, fobj):
        # Turn logical AND (accept_file()) into a logical OR with the
        # De Morgan's laws.
        return not accept_file(
            fobj,
            ((lambda x, f=filt: not f(x))
             for filt
             in self.subfilters),
        )

    def __str__(self):
        return "<Filter: {}>".format(" or ".join(map(str, self.subfilters)))

    def decompose(self):
        return self.subfilters


@filter_combinator("and")
class AndFilter(BaseFilter):
    def __init__(self, stack):
        self.subfilters = [stack[-2], stack[-1]]

        stack.pop()
        stack.pop()

        stack.append(self)

    def __call__(self, fobj):
        return accept_file(fobj, self.subfilters)

    def __str__(self):
        return "<Filter: {}>".format(" and ".join(map(str, self.subfilters)))

    def decompose(self):
        return self.subfilters


@filter_combinator("not")
class NotFilter(BaseFilter):
    def __init__(self, stack):
        self.subfilter = stack.pop()
        stack.append(self)

    def __call__(self, fobj):
        return not self.subfilter(fobj)

    def __str__(self):
        return "<Filter: not {}>".format(str(self.subfilter))

    def decompose(self):
        return [self.subfilter]