summary refs log tree commit diff stats
path: root/compiler/lists.nim
blob: bfd052204767f9dc44e9b6433edde91868348e4e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
#
#           The Nim Compiler
#        (c) Copyright 2012 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

# This module is deprecated, don't use it.
# TODO Remove this

import os

static:
  echo "WARNING: imported deprecated module compiler/lists.nim, use seq ore lists from the standard library"

proc appendStr*(list: var seq[string]; data: string) {.deprecated.} =
  # just use system.add
  list.add(data)

proc includeStr(list: var seq[string]; data: string): bool {.deprecated.} =
  if list.contains(data):
    result = true
  else:
    result = false
    list.add data
'>f027adc0 ^
728fb838 ^
f027adc0 ^

9dc6fe07 ^
f027adc0 ^
65cb1a32 ^
9dc6fe07 ^
f027adc0 ^
65cb1a32 ^
9dc6fe07 ^
aea67778 ^
f027adc0 ^


9dc6fe07 ^
f027adc0 ^
728fb838 ^
f027adc0 ^

9dc6fe07 ^
f027adc0 ^

9dc6fe07 ^
9dc6fe07 ^
9dc6fe07 ^
728fb838 ^
b4b0eb24 ^


728fb838 ^

f027adc0 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
                                  
                                                                          
                                       

                                                
                                                                            
                                                                            
                              

                                                                           
                                                 
                                             
                            
 





















                                                                               
                                            
 
                          

                               
 
                             
                                                                             

                                               
 
                                
                                              
 
                                                
                                                            
 
                                                                           


                                                 
 
                                  
                                                                            

                                                      
 

                                                                  
 
 
                               
                                                                             


                                                                   

                                                           
 
CONTEXT_KEYS = [ 'reset', 'error',
		'in_display', 'in_statusbar', 'in_titlebar', 'in_console',
		'in_notify', 'in_pman',
		'directory', 'file', 'hostname',
		'executable', 'media', 'link',
		'video', 'audio', 'image', 'media', 'document', 'container',
		'selected', 'empty', 'maindisplay', 'message', 'background',
		'good', 'bad',
		'space', 'permissions', 'owner', 'group', 'mtime', 'nlink',
		'scroll', 'all', 'bot', 'top', 'percentage',
		'marked', 'tagged', 'tag_marker',
		'title', 'text', 'highlight',
		'keybuffer']

# colorscheme specification:
#
# A colorscheme must...
#
# 1. be inside either of these directories:
# ~/.ranger/colorschemes/
# path/to/ranger/colorschemes/
#
# 2. be a subclass ofranger.gui.colorscheme.ColorScheme
# 
# 3. have a use(self, context) method which returns a tuple of 3 integers.
# the first integer is the foreground color, the second is the background
# color, the third is the attribute, as specified by the curses module.
#
#
# define which colorscheme to use by having this to your options.py:
# from ranger import colorschemes
# colorscheme = colorschemes.filename
# 
# If your colorscheme-file contains more than one colorscheme, specify it with:
# colorscheme = colorschemes.filename.classname

from ranger.ext.openstruct import OpenStruct

class ColorScheme(object):
	def __init__(self):
		self.cache = {}

	def get(self, *keys):
		"""Determine the (fg, bg, attr) tuple or get it from cache"""
		try:
			return self.cache[keys]

		except KeyError:
			context = OpenStruct()

			for key in CONTEXT_KEYS:
				context[key] = (key in keys)

			# add custom error messages for broken colorschemes
			color = self.use(context)
			self.cache[keys] = color
			return color

	def get_attr(self, *keys):
		"""Returns the curses attr integer for the specified keys"""
		from ranger.gui.color import get_color
		import curses

		fg, bg, attr = self.get(*keys)
		return attr | curses.color_pair(get_color(fg, bg))


	def use(self, context):
		"""Use the colorscheme to determine the (fg, bg, attr) tuple.
      This is a dummy function which always returns default_colors.
      Override this in your custom colorscheme!
      """
		from ranger.gui.color import default_colors
		return default_colors