How to use long_text method in Slash

Best Python code snippet using slash

config_data.py

Source:config_data.py Github

copy

Full Screen

1#!/usr/bin/env python32# vim:fileencoding=utf-83# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>4# Utils {{{5from functools import partial6from gettext import gettext as _7from typing import Any, Dict, Sequence, Union8from kitty.conf.definition import Option, Shortcut, option_func9from kitty.conf.utils import (10 positive_int, python_string, to_color, to_color_or_none11)12# }}}13all_options: Dict[str, Union[Option, Sequence[Shortcut]]] = {}14o, k, g, all_groups = option_func(all_options, {15 'colors': [_('Colors')],16 'diff': [_('Diffing'), ],17 'shortcuts': [_('Keyboard shortcuts')],18})19g('diff')20def syntax_aliases(raw: str) -> Dict[str, str]:21 ans = {}22 for x in raw.split():23 a, b = x.partition(':')[::2]24 if a and b:25 ans[a.lower()] = b26 return ans27o('syntax_aliases', 'pyj:py pyi:py recipe:py', option_type=syntax_aliases, long_text=_('''28File extension aliases for syntax highlight29For example, to syntax highlight :file:`file.xyz` as30:file:`file.abc` use a setting of :code:`xyz:abc`31'''))32o('num_context_lines', 3, option_type=positive_int, long_text=_('''33The number of lines of context to show around each change.'''))34o('diff_cmd', 'auto', long_text=_('''35The diff command to use. Must contain the placeholder :code:`_CONTEXT_`36which will be replaced by the number of lines of context. The default37is to search the system for either git or diff and use that, if found.38'''))39o('replace_tab_by', r'\x20\x20\x20\x20', option_type=python_string, long_text=_('''40The string to replace tabs with. Default is to use four spaces.'''))41g('colors')42o('pygments_style', 'default', long_text=_('''43The pygments color scheme to use for syntax highlighting.44See :link:`pygments colors schemes <https://help.farbox.com/pygments.html>` for a list of schemes.'''))45c = partial(o, option_type=to_color)46c('foreground', 'black', long_text=_('Basic colors'))47c('background', 'white')48c('title_fg', 'black', long_text=_('Title colors'))49c('title_bg', 'white')50c('margin_bg', '#fafbfc', long_text=_('Margin colors'))51c('margin_fg', '#aaaaaa')52c('removed_bg', '#ffeef0', long_text=_('Removed text backgrounds'))53c('highlight_removed_bg', '#fdb8c0')54c('removed_margin_bg', '#ffdce0')55c('added_bg', '#e6ffed', long_text=_('Added text backgrounds'))56c('highlight_added_bg', '#acf2bd')57c('added_margin_bg', '#cdffd8')58c('filler_bg', '#fafbfc', long_text=_('Filler (empty) line background'))59c('margin_filler_bg', 'none', option_type=to_color_or_none, long_text=_(60 'Filler (empty) line background in margins, defaults to the filler background'))61c('hunk_margin_bg', '#dbedff', long_text=_('Hunk header colors'))62c('hunk_bg', '#f1f8ff')63c('search_bg', '#444', long_text=_('Highlighting'))64c('search_fg', 'white')65c('select_bg', '#b4d5fe')66c('select_fg', 'black')67g('shortcuts')68k('quit', 'q', 'quit', _('Quit'))69k('quit', 'esc', 'quit', _('Quit'))70k('scroll_down', 'j', 'scroll_by 1', _('Scroll down'))71k('scroll_down', 'down', 'scroll_by 1', _('Scroll down'))72k('scroll_up', 'k', 'scroll_by -1', _('Scroll up'))73k('scroll_up', 'up', 'scroll_by -1', _('Scroll up'))74k('scroll_top', 'home', 'scroll_to start', _('Scroll to top'))75k('scroll_bottom', 'end', 'scroll_to end', _('Scroll to bottom'))76k('scroll_page_down', 'page_down', 'scroll_to next-page', _('Scroll to next page'))77k('scroll_page_down', 'space', 'scroll_to next-page', _('Scroll to next page'))78k('scroll_page_up', 'page_up', 'scroll_to prev-page', _('Scroll to previous page'))79k('next_change', 'n', 'scroll_to next-change', _('Scroll to next change'))80k('prev_change', 'p', 'scroll_to prev-change', _('Scroll to previous change'))81k('all_context', 'a', 'change_context all', _('Show all context'))82k('default_context', '=', 'change_context default', _('Show default context'))83k('increase_context', '+', 'change_context 5', _('Increase context'))84k('decrease_context', '-', 'change_context -5', _('Decrease context'))85k('search_forward', '/', 'start_search regex forward', _('Search forward'))86k('search_backward', '?', 'start_search regex backward', _('Search backward'))87k('next_match', '.', 'scroll_to next-match', _('Scroll to next search match'))88k('prev_match', ',', 'scroll_to prev-match', _('Scroll to previous search match'))89k('next_match', '>', 'scroll_to next-match', _('Scroll to next search match'))90k('prev_match', '<', 'scroll_to prev-match', _('Scroll to previous search match'))91k('search_forward_simple', 'f', 'start_search substring forward', _('Search forward (no regex)'))92k('search_backward_simple', 'b', 'start_search substring backward', _('Search backward (no regex)'))93def type_convert(name: str, val: Any) -> Any:94 o = all_options.get(name)95 if isinstance(o, Option):96 val = o.option_type(val)...

Full Screen

Full Screen

ScrollLabel.py

Source:ScrollLabel.py Github

copy

Full Screen

1import skin2from HTMLComponent import HTMLComponent3from GUIComponent import GUIComponent4from enigma import eLabel, eWidget, eSlider, fontRenderClass, ePoint, eSize5class ScrollLabel(HTMLComponent, GUIComponent):6 def __init__(self, text=""):7 GUIComponent.__init__(self)8 self.message = text9 self.instance = None10 self.long_text = None11 self.scrollbar = None12 self.pages = None13 self.total = None14 def applySkin(self, desktop, parent):15 ret = False16 if self.skinAttributes is not None:17 skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale)18 widget_attribs = [ ]19 scrollbar_attribs = [ ]20 for (attrib, value) in self.skinAttributes:21 if "borderColor" in attrib or "borderWidth" in attrib:22 scrollbar_attribs.append((attrib,value))23 if "transparent" in attrib or "backgroundColor" in attrib:24 widget_attribs.append((attrib,value))25 skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale)26 skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs+widget_attribs, parent.scale)27 ret = True28 s = self.long_text.size()29 self.instance.move(self.long_text.position())30 lineheight=fontRenderClass.getInstance().getLineHeight( self.long_text.getFont() )31 if not lineheight:32 lineheight = 30 # assume a random lineheight if nothing is visible33 lines = int(s.height() / lineheight)34 self.pageHeight = int(lines * lineheight)35 self.instance.resize(eSize(s.width(), self.pageHeight+ int(lineheight/6)))36 self.scrollbar.move(ePoint(s.width()-10,0))37 self.scrollbar.resize(eSize(10,self.pageHeight+ int(lineheight/6)))38 self.scrollbar.setOrientation(eSlider.orVertical)39 self.scrollbar.setRange(0,100)40 self.scrollbar.setBorderWidth(1)41 self.long_text.move(ePoint(0,0))42 self.long_text.resize(eSize(s.width()-30, self.pageHeight*40))43 self.setText(self.message)44 return ret45 def setText(self, text):46 self.message = text47 if self.long_text is not None and self.pageHeight:48 self.long_text.move(ePoint(0,0))49 self.long_text.setText(self.message)50 text_height=self.long_text.calculateSize().height()51 total=self.pageHeight52 pages=153 while total < text_height:54 total += self.pageHeight55 pages += 156 if pages > 1:57 self.scrollbar.show()58 self.total = total59 self.pages = pages60 self.updateScrollbar()61 else:62 self.scrollbar.hide()63 self.total = None64 self.pages = None65 def appendText(self, text):66 old_text = self.getText()67 if len(str(old_text)) >0:68 self.message += text69 else:70 self.message = text71 if self.long_text is not None:72 self.long_text.setText(self.message)73 text_height=self.long_text.calculateSize().height()74 total=self.pageHeight75 pages=176 while total < text_height:77 total += self.pageHeight78 pages += 179 if pages > 1:80 self.scrollbar.show()81 self.total = total82 self.pages = pages83 self.updateScrollbar()84 else:85 self.scrollbar.hide()86 self.total = None87 self.pages = None88 def updateScrollbar(self):89 start = -self.long_text.position().y() * 100 / self.total90 vis = self.pageHeight * 100 / self.total91 self.scrollbar.setStartEnd(start, start+vis)92 def getText(self):93 return self.message94 def GUIcreate(self, parent):95 self.instance = eWidget(parent)96 self.scrollbar = eSlider(self.instance)97 self.long_text = eLabel(self.instance)98 def GUIdelete(self):99 self.long_text = None100 self.scrollbar = None101 self.instance = None102 def pageUp(self):103 if self.total is not None:104 curPos = self.long_text.position()105 if curPos.y() < 0:106 self.long_text.move( ePoint( curPos.x(), curPos.y() + self.pageHeight ) )107 self.updateScrollbar()108 def pageDown(self):109 if self.total is not None:110 curPos = self.long_text.position()111 if self.total-self.pageHeight >= abs( curPos.y() - self.pageHeight ):112 self.long_text.move( ePoint( curPos.x(), curPos.y() - self.pageHeight ) )113 self.updateScrollbar()114 def lastPage(self):115 if self.pages is not None:116 i = 1117 while i < self.pages:118 self.pageDown()119 i += 1120 def isAtLastPage(self):121 if self.total is not None:122 curPos = self.long_text.position()123 return self.total - self.pageHeight < abs( curPos.y() - self.pageHeight )124 else:125 return True126 def produceHTML(self):...

Full Screen

Full Screen

ODScrollLabel.py

Source:ODScrollLabel.py Github

copy

Full Screen

1import skin2from Components.VariableText import VariableText3from Components.config import config4from Renderer import Renderer5from enigma import eLabel, eWidget, ePoint, eSize, gFont, fontRenderClass, eTimer6class ODScrollLabel(VariableText, Renderer):7 def __init__(self):8 Renderer.__init__(self)9 VariableText.__init__(self)10 self.step = 111 self.steptime = int(config.usage.scroll_label_speed.value)12 self.startdelay = int(config.usage.scroll_label_delay.value)13 self.long_text = None14 self.text_height = 015 self.page_height = 016 self.updateTimer = eTimer()17 self.updateTimer.callback.append(self.lineScroll)18 def postWidgetCreate(self, instance):19 self.long_text = eLabel(instance)20 def applySkin(self, desktop, parent):21 attribs = []22 longtext_attribs = []23 for attrib, value in self.skinAttributes:24 if attrib.find('step') != -1:25 self.step = int(value)26 if attrib.find('steptime') != -1:27 self.steptime = int(value)28 if attrib.find('startdelay') != -1:29 self.startdelay = int(value)30 if attrib.find('font') != -1 or attrib.find('size') != -1 or attrib.find('zPosition') != -1 or attrib.find('transparent') != -1 or attrib.find('backgroundColor') != -1 or attrib.find('foregroundColor') != -1 or attrib.find('valign') != -1 or attrib.find('halign') != -1:31 longtext_attribs.append((attrib, value))32 if attrib != 'font' and attrib != 'valign' and attrib != 'halign' and attrib != 'foregroundColor' and attrib != 'step' and attrib != 'steptime' and attrib != 'startdelay' and attrib != 'css':33 attribs.append((attrib, value))34 if attrib.find('css') != -1:35 from skin import cascadingStyleSheets36 styles = value.split(',')37 for style in styles:38 for _attrib in cascadingStyleSheets[style].keys():39 _value = cascadingStyleSheets[style][_attrib]40 if _attrib.find('step') != -1:41 self.step = int(_value)42 if _attrib.find('steptime') != -1:43 self.steptime = int(_value)44 if _attrib.find('startdelay') != -1:45 self.startdelay = int(_value)46 if _attrib.find('font') != -1 or _attrib.find('size') != -1 or _attrib.find('zPosition') != -1 or _attrib.find('transparent') != -1 or _attrib.find('backgroundColor') != -1 or _attrib.find('foregroundColor') != -1 or _attrib.find('valign') != -1 or _attrib.find('halign') != -1:47 longtext_attribs.append((_attrib, _value))48 if _attrib != 'font' and _attrib != 'valign' and _attrib != 'halign' and _attrib != 'foregroundColor' and _attrib != 'step' and _attrib != 'steptime' and _attrib != 'startdelay':49 attribs.append((_attrib, _value))50 skin.applyAllAttributes(self.long_text, desktop, longtext_attribs, parent.scale)51 self.long_text.move(ePoint(0, 0))52 self.skinAttributes = attribs53 ret = Renderer.applySkin(self, desktop, parent)54 self.changed((self.CHANGED_DEFAULT,))55 return ret56 GUI_WIDGET = eWidget57 def connect(self, source):58 Renderer.connect(self, source)59 self.changed((self.CHANGED_DEFAULT,))60 def changed(self, what):61 if what[0] == self.CHANGED_CLEAR:62 if self.long_text is not None:63 self.long_text.move(ePoint(0, 0))64 self.long_text.setText('')65 self.long_text.resize(self.instance.size())66 self.updateTimer.stop()67 elif self.long_text is not None:68 self.long_text.move(ePoint(0, 0))69 if self.source.text is None:70 self.long_text.setText('')71 else:72 self.long_text.setText(self.source.text)73 self.page_height = int(self.instance.size().height())74 self.text_height = int(self.long_text.calculateSize().height() + fontRenderClass.getInstance().getLineHeight(self.long_text.getFont()))75 self.long_text.resize(eSize(self.instance.size().width(), self.text_height))76 if self.text_height > self.page_height:77 self.updateTimer.start(self.startdelay)78 else:79 self.updateTimer.stop()80 def lineScroll(self):81 if self.long_text is not None and config.usage.scroll_label_delay.value != 'noscrolling':82 if self.text_height > self.page_height:83 curPos = self.long_text.position()84 if self.text_height - self.step >= abs(curPos.y() - self.step):85 self.long_text.move(ePoint(curPos.x(), curPos.y() - self.step))86 else:87 self.long_text.move(ePoint(curPos.x(), self.page_height))88 self.updateTimer.start(self.steptime)89 else:...

Full Screen

Full Screen

EGScrollLabel.py

Source:EGScrollLabel.py Github

copy

Full Screen

1import skin2from Components.VariableText import VariableText3from Components.config import config4from Renderer import Renderer5from enigma import eLabel, eWidget, ePoint, eSize, gFont, fontRenderClass, eTimer6class EGScrollLabel(VariableText, Renderer):7 def __init__(self):8 Renderer.__init__(self)9 VariableText.__init__(self)10 self.step = 111 self.steptime = int(config.usage.scroll_label_speed.value)12 self.startdelay = int(config.usage.scroll_label_delay.value)13 self.long_text = None14 self.text_height = 015 self.page_height = 016 self.updateTimer = eTimer()17 self.updateTimer.callback.append(self.lineScroll)18 def postWidgetCreate(self, instance):19 self.long_text = eLabel(instance)20 def applySkin(self, desktop, parent):21 attribs = []22 longtext_attribs = []23 for attrib, value in self.skinAttributes:24 if attrib.find('step') != -1:25 self.step = int(value)26 if attrib.find('steptime') != -1:27 self.steptime = int(value)28 if attrib.find('startdelay') != -1:29 self.startdelay = int(value)30 if attrib.find('font') != -1 or attrib.find('size') != -1 or attrib.find('zPosition') != -1 or attrib.find('transparent') != -1 or attrib.find('backgroundColor') != -1 or attrib.find('foregroundColor') != -1 or attrib.find('valign') != -1 or attrib.find('halign') != -1:31 longtext_attribs.append((attrib, value))32 if attrib != 'font' and attrib != 'valign' and attrib != 'halign' and attrib != 'foregroundColor' and attrib != 'step' and attrib != 'steptime' and attrib != 'startdelay' and attrib != 'css':33 attribs.append((attrib, value))34 if attrib.find('css') != -1:35 from skin import cascadingStyleSheets36 styles = value.split(',')37 for style in styles:38 for _attrib in cascadingStyleSheets[style].keys():39 _value = cascadingStyleSheets[style][_attrib]40 if _attrib.find('step') != -1:41 self.step = int(_value)42 if _attrib.find('steptime') != -1:43 self.steptime = int(_value)44 if _attrib.find('startdelay') != -1:45 self.startdelay = int(_value)46 if _attrib.find('font') != -1 or _attrib.find('size') != -1 or _attrib.find('zPosition') != -1 or _attrib.find('transparent') != -1 or _attrib.find('backgroundColor') != -1 or _attrib.find('foregroundColor') != -1 or _attrib.find('valign') != -1 or _attrib.find('halign') != -1:47 longtext_attribs.append((_attrib, _value))48 if _attrib != 'font' and _attrib != 'valign' and _attrib != 'halign' and _attrib != 'foregroundColor' and _attrib != 'step' and _attrib != 'steptime' and _attrib != 'startdelay':49 attribs.append((_attrib, _value))50 skin.applyAllAttributes(self.long_text, desktop, longtext_attribs, parent.scale)51 self.long_text.move(ePoint(0, 0))52 self.skinAttributes = attribs53 ret = Renderer.applySkin(self, desktop, parent)54 self.changed((self.CHANGED_DEFAULT,))55 return ret56 GUI_WIDGET = eWidget57 def connect(self, source):58 Renderer.connect(self, source)59 self.changed((self.CHANGED_DEFAULT,))60 def changed(self, what):61 if what[0] == self.CHANGED_CLEAR:62 if self.long_text is not None:63 self.long_text.move(ePoint(0, 0))64 self.long_text.setText('')65 self.long_text.resize(self.instance.size())66 self.updateTimer.stop()67 elif self.long_text is not None:68 self.long_text.move(ePoint(0, 0))69 if self.source.text is None:70 self.long_text.setText('')71 else:72 self.long_text.setText(self.source.text)73 self.page_height = int(self.instance.size().height())74 self.text_height = int(self.long_text.calculateSize().height() + fontRenderClass.getInstance().getLineHeight(self.long_text.getFont()))75 self.long_text.resize(eSize(self.instance.size().width(), self.text_height))76 if self.text_height > self.page_height:77 self.updateTimer.start(self.startdelay)78 else:79 self.updateTimer.stop()80 def lineScroll(self):81 if self.long_text is not None and config.usage.scroll_label_delay.value != 'noscrolling':82 if self.text_height > self.page_height:83 curPos = self.long_text.position()84 if self.text_height - self.step >= abs(curPos.y() - self.step):85 self.long_text.move(ePoint(curPos.x(), curPos.y() - self.step))86 else:87 self.long_text.move(ePoint(curPos.x(), self.page_height))88 self.updateTimer.start(self.steptime)89 else:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful