about summary refs log tree commit diff stats
path: root/apps/browse/paginated-screen.mu
Commit message (Expand)AuthorAgeFilesLines
* 7159 - explicitly use 'return' everywhereKartik Agaram2020-11-021-11/+4
* 6771 - first passing test for the browser itselfKartik Agaram2020-09-111-21/+141
* 6770Kartik Agaram2020-09-101-70/+140
* 6767Kartik Agaram2020-09-101-3/+49
* 6766Kartik Agaram2020-09-101-24/+24
* 6765Kartik Agaram2020-09-101-0/+22
* 6764Kartik Agaram2020-09-101-168/+0
* 6763Kartik Agaram2020-09-101-0/+83
* 6762Kartik Agaram2020-09-101-8/+210
* 6761Kartik Agaram2020-09-081-1/+1
* 6759 - first test for app/browse/Kartik Agaram2020-09-071-6/+21
* 6758Kartik Agaram2020-09-071-13/+29
* 6757Kartik Agaram2020-09-071-2/+3
* 6755Kartik Agaram2020-09-071-82/+95
* 6754Kartik Agaram2020-09-071-5/+12
* 6753Kartik Agaram2020-09-071-10/+78
* 6752Kartik Agaram2020-09-071-0/+173
*/ .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 */
ALLOWED_FLAGS = 'sdpSDP'

class Applications(object):
	def get(self, app):
		try:
			return getattr(self, 'app_' + app)
		except AttributeError:
			return self.app_default

	def has(self, app):
		return hasattr(self, 'app_' + app)

	def all(self):
		return [x for x in self.__dict__ if x.startswith('app_')]

import os
null = open(os.devnull, 'a')

def run(*args, **kw):
	from subprocess import Popen
	from subprocess import PIPE
	from ranger.ext import waitpid_no_intr

	flags, fm = kw['flags'], kw['fm']
	for flag in flags:
		if ord(flag) <= 90:
			bad = flag + flag.lower()
			flags = ''.join(c for c in flags if c not in bad)

	args = map(str, args)
	popen_kw = {}

	if kw['stdin'] is not None:
		popen_kw['stdin'] = kw['stdin']

	if 's' in flags or 'd' in flags:
		popen_kw['stdout'] = popen_kw['stderr'] = popen_kw['stdin'] = null
	
	if 'p' in flags:
		popen_kw['stdout'] = PIPE
		process1 = Popen(args, **popen_kw)
		kw['stdin'] = process1.stdout
		kw['files'] = ()
		kw['flags'] = ''.join(f for f in kw['flags'] if f in 'd')
		process2 = kw['apps'].app_pager(**kw)
		return process2
	if 'd' in flags:
		process = Popen(args, **popen_kw)
		return process
	else:
		fm.ui.exit()
		p = Popen(args, **popen_kw)
		waitpid_no_intr(p.pid)
		fm.ui.initialize()
		return p