Esempio n. 1
0
 def test_annotationSetText_clear(self):
     editor.write('One\r\nTwo\r\nThree')
     editor.annotationSetText(1, 'This is line two')
     before = editor.annotationGetText(1)
     editor.annotationSetText(1, None)
     after = editor.annotationGetText(1)
     self.assertEqual(before, 'This is line two')
     self.assertEqual(after, '')
Esempio n. 2
0
    def __set_annotation(self, line, text):
        '''
            Shows an annotated line under the caret line
            Args:
                line = integer, 0-based line number of the caret line
                text = string, text to be shown
            Returns:
                None
        '''

        editor.styleSetFore(self.ANON_STYLE, (128, 255, 0))
        editor.styleSetBack(self.ANON_STYLE,
                            notepad.getEditorDefaultBackgroundColor())
        editor.annotationSetVisible(ANNOTATIONVISIBLE.STANDARD)
        editor.annotationSetText(line, text)
        editor.annotationSetStyle(line, self.ANON_STYLE)
Esempio n. 3
0
 def peek_definition_response_handler(self, decoded_message):
     log(decoded_message)
     if decoded_message['result']:
         _file = url2pathname(decoded_message['result'][0]['uri'].replace(
             'file:', ''))
         _line_number = decoded_message['result'][0]['range']['start'][
             'line']
         with open(_file) as f:
             for i, line in enumerate(f):
                 if i == _line_number:
                     break
         cursor_line = editor.lineFromPosition(editor.getCurrentPos())
         editor.annotationSetText(
             cursor_line,
             '\n{}\n'.format(line[:-1] if line.endswith('\n') else line))
         editor.annotationSetStyle(cursor_line, self.PEEK_STYLE)
         editor.annotationSetVisible(ANNOTATIONVISIBLE.STANDARD)
Esempio n. 4
0
 def test_annotationSetText_as_text(self):
     editor.write('One\r\nTwo\r\nThree')
     editor.annotationSetText(1, 'This is line two')
     text = editor.annotationGetText(1)
     self.assertEqual(text, 'This is line two')
Esempio n. 5
0
# -*- coding: utf-8 -*-
"""
    InsertRuler - Demo

    Inserts a basic ruler using annotation

    Usage:
        Run script.
"""
from Npp import editor

ruler_header = ''.join(['{:>10}'.format(x) for x in range(1,21)])
ruler_footer = ''.join(['{0} '.format('123456789') for x in range(1,21)])

editor.annotationSetText(0, '{}\r\n{}'.format(ruler_header,ruler_footer))
editor.annotationSetStyle(0, 0)
editor.annotationSetVisible(not editor.annotationGetVisible())