about summary refs log tree commit diff stats
path: root/html/apps
Commit message (Expand)AuthorAgeFilesLines
* 6081 - ctags for .mu filesKartik Agaram2020-03-055-14/+14
* 6080Kartik Agaram2020-03-056-9369/+9711
* 6078 - highlight hex literals in VimKartik Agaram2020-03-022-2/+2
* 6077Kartik Agaram2020-03-025-54/+55
* 6070Kartik Agaram2020-02-291-1/+1
* 6069Kartik Agaram2020-02-291-21/+21
* 6068Kartik Agaram2020-02-283-10/+10
* 6066 - Vim syntax highlighting for Mu filesKartik Agaram2020-02-284-21/+21
* 6065Kartik Agaram2020-02-271-2/+2
* 6063Kartik Agaram2020-02-271-8816/+8893
* 6061Kartik Agaram2020-02-271-22/+22
* 6056Kartik Agaram2020-02-272-8506/+9028
* 6042Kartik Agaram2020-02-212-8415/+8477
* 6038Kartik Agaram2020-02-201-8112/+8313
* 6026Kartik Agaram2020-02-181-13/+13
* 6025Kartik Agaram2020-02-182-6715/+7029
* 6018Kartik Agaram2020-02-171-3935/+3975
* 6016Kartik Agaram2020-02-171-5/+5
* 6015Kartik Agaram2020-02-1718-223/+304
* 6012Kartik Agaram2020-02-161-6330/+6264
* 6001Kartik Agaram2020-02-0912-7083/+7290
* 5995Kartik Agaram2020-02-081-7408/+7804
* 5975Kartik Agaram2020-02-021-7427/+7137
* 5972Kartik Agaram2020-02-011-6480/+6703
* 5966 - document all supported Mu instructionsKartik Agaram2020-01-311-9/+9
* 5963Kartik Agaram2020-01-301-3956/+3992
* 5958Kartik Agaram2020-01-302-2537/+2550
* 5954 - 'factorial' working!Kartik Agaram2020-01-291-0/+79
* 5952Kartik Agaram2020-01-291-2231/+2573
* 5949Kartik Agaram2020-01-292-6293/+7058
* 5944Kartik Agaram2020-01-281-5289/+5461
* 5941Kartik Agaram2020-01-271-5176/+5289
* 5937Kartik Agaram2020-01-272-3231/+3271
* 5933Kartik Agaram2020-01-271-2/+2
* 5932Kartik Agaram2020-01-271-0/+70
* 5931Kartik Agaram2020-01-271-1/+1
* 5930Kartik Agaram2020-01-271-5132/+5290
* 5925Kartik Agaram2020-01-2722-2719/+2761
* 5922Kartik Agaram2020-01-261-5556/+5674
* 5917Kartik Agaram2020-01-221-4299/+4293
* 5912Kartik Agaram2020-01-201-4115/+4450
* 5904Kartik Agaram2020-01-191-9/+9
* 5903Kartik Agaram2020-01-191-1575/+1576
* 5901Kartik Agaram2020-01-199-71/+71
* 5897 - rename comparison instructionsKartik Agaram2020-01-1622-377/+377
* 5896Kartik Agaram2020-01-161-21/+21
* 5895Kartik Agaram2020-01-161-21/+21
* 5894Kartik Agaram2020-01-161-5/+5
* 5889Kartik Agaram2020-01-146-4132/+4301
* 5884Kartik Agaram2020-01-1214-5212/+5210
self.markup = None self.lines = [] def move_horizontal(self, *a, **k): """For compatibility""" self.fm.notify("Your keys.py is out of date. Can't scroll!", bad=True) def open(self): self.scroll_begin = 0 self.markup = None self.startx = 0 self.need_redraw = True def close(self): if self.source and self.source_is_stream: self.source.close() def finalize(self): self.fm.ui.win.move(self.y, self.x) def draw(self): if self.old_source != self.source: self.old_source = self.source self.need_redraw = True if self.old_scroll_begin != self.scroll_begin or \ self.old_startx != self.startx: self.old_startx = self.startx self.old_scroll_begin = self.scroll_begin self.need_redraw = True if self.need_redraw: self.win.erase() line_gen = self._generate_lines( starty=self.scroll_begin, startx=self.startx) for line, i in zip(line_gen, range(self.hei)): self._draw_line(i, line) self.need_redraw = False def _draw_line(self, i, line): if self.markup is None: self.addstr(i, 0, line) elif self.markup is 'help': self.addstr(i, 0, line) baseclr = ('in_pager', 'help_markup') if line.startswith('===='): self.color_at(i, 0, len(line), 'seperator', *baseclr) return if line.startswith(' ') and \ len(line) >= 16 and line[15] == ' ': self.color_at(i, 0, 16, 'key', *baseclr) for m in BAR_REGEXP.finditer(line): start, length = m.start(), m.end() - m.start() self.color_at(i, start, length, 'bars', *baseclr) self.color_at(i, start + 1, length - 2, 'link', *baseclr) for m in QUOTES_REGEXP.finditer(line): start, length = m.start(), m.end() - m.start() self.color_at(i, start, length, 'quotes', *baseclr) self.color_at(i, start + 1, length - 2, 'text', *baseclr) for m in SPECIAL_CHARS_REGEXP.finditer(line): start, length = m.start(), m.end() - m.start() self.color_at(i, start, length, 'special', *baseclr) if TITLE_REGEXP.match(line): self.color_at(i, 0, -1, 'title', *baseclr) def move(self, narg=None, **kw): direction = Direction(kw) if direction.horizontal(): self.startx = direction.move( direction=direction.right(), override=narg, maximum=self._get_max_width(), current=self.startx, pagesize=self.wid, offset=-self.wid) if direction.vertical(): if self.source_is_stream: self._get_line(self.scroll_begin + self.hei * 2) self.scroll_begin = direction.move( direction=direction.down(), override=narg, maximum=len(self.lines), current=self.scroll_begin, pagesize=self.hei, offset=-self.hei) def press(self, key): self.env.keymanager.use_context(self.embedded and 'embedded_pager' or 'pager') self.env.key_append(key) kbuf = self.env.keybuffer cmd = kbuf.command if kbuf.failure: kbuf.clear() return elif not cmd: return self.env.cmd = cmd if cmd.function: try: cmd.function(CommandArgs.from_widget(self)) except Exception as error: self.fm.notify(error) if kbuf.done: kbuf.clear() else: kbuf.clear() def set_source(self, source, strip=False): if self.source and self.source_is_stream: self.source.close() if isinstance(source, str): self.source_is_stream = False self.lines = source.split('\n') elif hasattr(source, '__getitem__'): self.source_is_stream = False self.lines = source elif hasattr(source, 'readline'): self.source_is_stream = True self.lines = [] else: self.source = None self.source_is_stream = False return False if not self.source_is_stream and strip: self.lines = map(lambda x: x.strip(), self.lines) self.source = source return True def click(self, event): n = event.ctrl() and 1 or 3 direction = event.mouse_wheel_direction() if direction: self.move(relative=direction) return True def _get_line(self, n, attempt_to_read=True): assert isinstance(n, int), n try: return self.lines[n] except (KeyError, IndexError): if attempt_to_read and self.source_is_stream: try: for l in self.source: self.lines.append(l) if len(self.lines) > n: break except UnicodeError: pass return self._get_line(n, attempt_to_read=False) return "" def _generate_lines(self, starty, startx): i = starty if not self.source: raise StopIteration while True: try: line = self._get_line(i).expandtabs(4) line = line[startx:self.wid + startx].rstrip() yield line except IndexError: raise StopIteration i += 1 def _get_max_width(self): return max(len(line) for line in self.lines)