summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2015-03-18 22:27:21 +0100
committerhut <hut@lepus.uberspace.de>2015-03-18 22:27:21 +0100
commita5a84e52ec20867d114e0450477477be19b8227c (patch)
tree02e6e433451161b55cff4f6db803fb400bd347b4
parent7993ed4b19d57cfda0a22426cb0c3bcf88232bc3 (diff)
parent38214674f4279e8cdb2fc6e19a3eb0ccdaaebebd (diff)
downloadranger-a5a84e52ec20867d114e0450477477be19b8227c.tar.gz
Merge branch 'colorscheme_tab_complete' of git://github.com/randynobx/ranger
-rw-r--r--ranger/config/commands.py8
-rw-r--r--ranger/container/fsobject.py20
2 files changed, 26 insertions, 2 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index b47cb6ad..e129aac4 100644
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -344,12 +344,20 @@ class set_(Command):
             return (self.firstpart + setting for setting in settings \
                     if setting.startswith(name))
         if not value:
+            # Cycle through colorschemes when name, but no value is specified
+            if name == "colorscheme":
+                return (self.firstpart + colorscheme
+                    for colorscheme in self.fm.thisfile.colorscheme_dict.keys())
             return self.firstpart + str(settings[name])
         if bool in settings.types_of(name):
             if 'true'.startswith(value.lower()):
                 return self.firstpart + 'True'
             if 'false'.startswith(value.lower()):
                 return self.firstpart + 'False'
+        # Tab complete colorscheme values if incomplete value is present
+        if name == "colorscheme":
+            return (self.firstpart + colorscheme for colorscheme in self.fm.thisfile.colorscheme_dict.keys() \
+                    if colorscheme.startswith(value))
 
 
 class setlocal(set_):
diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py
index 6cdaa727..585bbb26 100644
--- a/ranger/container/fsobject.py
+++ b/ranger/container/fsobject.py
@@ -14,8 +14,8 @@ BAD_INFO = '?'
 
 import re
 from grp import getgrgid
-from os import lstat, stat, getcwd
-from os.path import abspath, basename, dirname, realpath, splitext, extsep, relpath
+from os import lstat, stat, getcwd, listdir
+from os.path import abspath, basename, dirname, realpath, splitext, extsep, relpath, expanduser, isdir
 from pwd import getpwuid
 from ranger.core.linemode import *
 from ranger.core.shared import FileManagerAware, SettingsAware
@@ -23,6 +23,7 @@ from ranger.ext.shell_escape import shell_escape
 from ranger.ext.spawn import spawn
 from ranger.ext.lazy_property import lazy_property
 from ranger.ext.human_readable import human_readable
+from ranger import RANGERDIR,CONFDIR
 
 if hasattr(str, 'maketrans'):
     maketrans = str.maketrans
@@ -89,6 +90,21 @@ class FileSystemObject(FileManagerAware, SettingsAware):
         [DefaultLinemode, TitleLinemode, PermissionsLinemode]
     )
 
+    _colorscheme = "default"
+    colorschemes = []
+    # Load colorscheme names from main ranger/colorschemes dir
+    for item in listdir(RANGERDIR + '/colorschemes'):
+        if not item.startswith('__'):
+            colorschemes.append(item.rsplit('.', 1)[0])
+    # Load colorscheme names from ~/.config/ranger/colorschemes if dir exists
+    if isdir(expanduser(CONFDIR + '/colorschemes')):
+        for item in listdir(expanduser(CONFDIR + '/colorschemes')):
+            if not item.startswith('__'):
+                colorschemes.append(item.rsplit('.', 1)[0])
+    colorscheme_dict = dict(
+        (colorscheme, colorscheme + '.py') for colorscheme in colorschemes
+    )
+
     def __init__(self, path, preload=None, path_is_abs=False, basename_is_rel_to=None):
         if not path_is_abs:
             path = abspath(path)
'n283' href='#n283'>283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430