about summary refs log tree commit diff stats
path: root/linkify
Commit message (Collapse)AuthorAgeFilesLines
* 4054Kartik K. Agaram2017-10-121-2/+6
|
* 3729Kartik K. Agaram2017-01-039-353/+29
|
* 3728Kartik K. Agaram2016-12-311-1/+1
|
* 3726Kartik K. Agaram2016-12-301-0/+1
|
* 3721Kartik K. Agaram2016-12-271-17/+17
| | | | | Switching my comment header for commented-out-code back after dropping Kakoune.
* 3719 - cross-link Mu waypoints to their locationKartik K. Agaram2016-12-271-1/+16
|
* 3718Kartik K. Agaram2016-12-271-0/+2
|
* 3717Kartik K. Agaram2016-12-261-2/+0
|
* 3715Kartik K. Agaram2016-12-261-0/+3
| | | | | | | | Fix cross-links in html for the edit/ app. I originally thought I'd need to provide a commandline flag like --rel-path or something. But we need to support different relative paths in a single html file. So the solution instead is appropriately engineering the tags file.
* 3713 - cross-link calls with definitions in htmlKartik K. Agaram2016-12-269-0/+543
t: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.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 */
if __name__ == '__main__': from __init__ import init; init()

import unittest
import curses
from random import randint

from ranger.gui.displayable import\
		Displayable, DisplayableContainer, OutOfBoundsException
from test import Fake, OK, raise_ok

class TestDisplayable(unittest.TestCase):
	def setUp(self):
		self.win = Fake()
		self.fm = Fake()
		self.env = Fake()
		self.settings = Fake()
		self.disp = Displayable( win=self.win,
				env=self.env, fm=self.fm, settings=self.settings)

		hei, wid = 100, 100
		self.env.termsize = (hei, wid)

	def tearDown(self):
		self.disp.destroy()

	def test_colorscheme(self):
		# Using a color method implies change of window attributes
		disp = self.disp

		self.win.chgat = raise_ok
		self.win.attrset = raise_ok

		self.assertRaises(OK, disp.color, 'a', 'b')
		self.assertRaises(OK, disp.color_at, 0, 0, 0, 'a', 'b')
		self.assertRaises(OK, disp.color_reset)

	def test_boundaries(self):
		disp = self.disp
		hei, wid = self.env.termsize

		self.assertRaises(OutOfBoundsException, disp.resize, 0, 0, hei + 1, wid)
		self.assertRaises(OutOfBoundsException, disp.resize, 0, 0, hei, wid + 1)
		self.assertRaises(OutOfBoundsException, disp.resize, -1, 0, hei, wid)
		self.assertRaises(OutOfBoundsException, disp.resize, 0, -1, hei, wid)

		box = (randint(10, 20), randint(30, 40), \
				randint(30, 40), randint(10, 20))

		def in_box(y, x):
			return (x >= box[1] and x < box[1] + box[3]) and \
					(y >= box[0] and y < box[0] + box[2])

		disp.resize(*box)
		for y, x in zip(range(10), range(10)):
			is_in_box = in_box(y, x)

			point1 = (y, x)
			self.assertEqual(is_in_box, point1 in disp)

			point2 = Fake()
			point2.x = x
			point2.y = y
			self.assertEqual(is_in_box, point2 in disp)

class TestDisplayableContainer(unittest.TestCase):
	def setUp(self):
		self.win = Fake()
		self.fm = Fake()
		self.env = Fake()
		self.settings = Fake()

		self.initdict = {'win': self.win, 'settings': self.settings,
				'fm': self.fm, 'env': self.env}

		self.disp = Displayable(**self.initdict)
		self.disc = DisplayableContainer(**self.initdict)
		self.disc.add_obj(self.disp)

		hei, wid = (100, 100)
		self.env.termsize = (hei, wid)

	def tearDown(self):
		self.disc.destroy()

	def test_container(self):
		self.assertTrue(self.disp in self.disc.container)

	def test_click(self):
		self.disp.click = raise_ok

		self.disc.resize(0, 0, 50, 50)
		self.disp.resize(0, 0, 20, 20)
		fakepos = Fake()

		fakepos.x = 10
		fakepos.y = 10
		self.assertRaises(OK, self.disc.click, fakepos)

		fakepos.x = 30
		fakepos.y = 10
		self.disc.click(fakepos)

	def test_focused_object(self):
		d1 = Displayable(**self.initdict)
		d2 = DisplayableContainer(**self.initdict)
		d2.add_obj(*[Displayable(**self.initdict) for x in range(5)])
		d3 = DisplayableContainer(**self.initdict)
		d3.add_obj(*[Displayable(**self.initdict) for x in range(5)])

		self.disc.add_obj(d1, d2, d3)

		d3.container[3].focused = True

		self.assertEqual(self.disc.get_focused_obj(), d3.container[3])

		d3.container[3].focused = False
		d2.container[0].focused = True

		self.assertEqual(self.disc.get_focused_obj(), d2.container[0])

if __name__ == '__main__':
	unittest.main()