Skip to content

Commit b7c52af

Browse files
committed
- correct typos
- adapt sample scripts: -- for python 3 -- for scintilla 5 setLexer(LEXER.CONTAINER) -> setILexer(0) -- corrected plugin home path -- added description that: "Multi-Edit needs to be activated in the N++ edit preferences." to be able to use the scripts ReplaceDefaultReplaceDialog.py and Swap2Words.py
1 parent 54bff32 commit b7c52af

File tree

9 files changed

+20
-18
lines changed

9 files changed

+20
-18
lines changed

PythonScript/src/ScintillaWrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3284,7 +3284,7 @@ class ScintillaWrapper : public PyProducerConsumer<CallbackExecArgs>
32843284
*/
32853285
boost::python::str DescribeKeyWordSets();
32863286

3287-
/** Bit set of LineEndType enumertion for which line ends beyond the standard
3287+
/** Bit set of LineEndType enumeration for which line ends beyond the standard
32883288
* LF, CR, and CRLF are supported by the lexer.
32893289
*/
32903290
int GetLineEndTypesSupported();

PythonScript/src/ScintillaWrapperGenerated.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6435,7 +6435,7 @@ boost::python::str ScintillaWrapper::DescribeKeyWordSets()
64356435
return boost::python::str(result.c_str());
64366436
}
64376437

6438-
/** Bit set of LineEndType enumertion for which line ends beyond the standard
6438+
/** Bit set of LineEndType enumeration for which line ends beyond the standard
64396439
* LF, CR, and CRLF are supported by the lexer.
64406440
*/
64416441
int ScintillaWrapper::GetLineEndTypesSupported()

scripts/Samples/ColumnLexer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def style_it(start, length, STYLE):
7676
line_start_pos = editor.positionFromLine(line)
7777
# split current line into columns
7878
columns = editor.getLine(line).split(self.COLUMN_SEPARATOR)
79-
if columns > 0:
79+
if len(columns) > 0:
8080
# iterate over all columns
8181
for i, column in enumerate(columns):
8282
# get the width of the current column
@@ -100,7 +100,7 @@ def init_scintilla(self):
100100
editor.setMarginWidthN(2,0)
101101

102102
if editor.getLexer() != LEXER.CONTAINER:
103-
editor.setLexer(LEXER.CONTAINER)
103+
editor.setILexer(0)
104104

105105
editor.styleSetFore(self.ODD_COLUMN_STYLE, (54,125,198))
106106
editor.styleSetFore(self.EVEN_COLUMN_STYLE, (87,166,74))

scripts/Samples/Formatter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
1313
"""
1414
from Npp import editor, notepad, console, MESSAGEBOXFLAGS
15-
from itertools import izip_longest
15+
from itertools import zip_longest
1616

1717
try:
18-
import Tkinter as tk
19-
import ttk
18+
import tkinter as tk
19+
from tkinter import ttk
2020
except ImportError as e:
2121
notepad.messageBox(('Unable to import Tkinter libraries,\n'
2222
'these are needed for the UI.\n\n'
@@ -50,7 +50,7 @@ def prepare(separator, rows, eol):
5050
column_width_list = []
5151
for row in rows:
5252
splitted_row = row.split(separator)
53-
column_width_list = [max(x) for x in izip_longest(column_width_list, [len(x.strip()) for x in splitted_row], fillvalue=(0))]
53+
column_width_list = [max(x) for x in zip_longest(column_width_list, [len(x.strip()) for x in splitted_row], fillvalue=(0))]
5454

5555
new_formatted_list = []
5656
for row in (x for x in rows):
@@ -172,7 +172,7 @@ def reformat(separator,area):
172172
size = (600,250)
173173
xpos = w/2 - size[0]/2
174174
ypos = h/2 - size[1]/2
175-
window.geometry("{}x{}+{}+{}".format(*(size + (xpos, ypos))))
175+
window.geometry("%dx%d+%d+%d" % (size + (xpos, ypos)))
176176

177177
# start app - blocks rest of the script
178178
window.mainloop()
@@ -189,7 +189,7 @@ def run_demo():
189189
_number_of_lines = 100000
190190
_s = 50
191191
_line_split_separator = ','
192-
_data = ['{0}{3}{1}{3}{2}\r\n'.format('a'*random.randint(0,_s),'b'*random.randint(0,_s),'c'*random.randint(0,_s),_line_split_separator) for i in xrange(_number_of_lines)]
192+
_data = ['{0}{3}{1}{3}{2}\r\n'.format('a'*random.randint(0,_s),'b'*random.randint(0,_s),'c'*random.randint(0,_s),_line_split_separator) for i in range(_number_of_lines)]
193193
notepad.new()
194194
editor.setText(''.join(_data))
195195
del _data

scripts/Samples/LogfileLexer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def init_scintilla(self):
103103
editor.setMarginWidthN(2,0)
104104

105105
if editor.getLexer() != LEXER.CONTAINER:
106-
editor.setLexer(LEXER.CONTAINER)
106+
editor.setILexer(0)
107107

108108
editor.styleSetFore(self.ERROR_STYLE, self.ERROR_STYLE_FOREGROUND)
109109
editor.styleSetFore(self.WARNING_STYLE, self.WARNING_STYLE_FOREGROUND)

scripts/Samples/RegexTester.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import re
3131

3232
# ---------------------------- <CONFIGURATION AREA> ------------------------------
33-
REGEX_TESTER_FILE_NAME = os.path.join(notepad.getPluginConfigDir(), r'PythonScript\scripts', 'RegexTester.txt')
33+
REGEX_TESTER_FILE_NAME = os.path.join(notepad.getPluginHomePath(), r'PythonScript\scripts', 'RegexTester.txt')
3434
COLOR_MAIN_MATCH = (100,215,100)
3535
COLOR_ODD_MATCH = (95,215,184)
3636
COLOR_EVEN_MATCH = (195,215,184)

scripts/Samples/ReplaceDefaultReplaceDialog.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
The built-in replace dialog doesn't allow to have a
66
multiline replacement value.
77
This script solves this missing feature.
8+
Multi-Edit needs to be activated in the N++ edit preferences.
89
910
In order to achieve this goal using WinAPI (ctypes) is needed.
1011
What happens is basically the following:
@@ -75,7 +76,7 @@ def return_proper_string(self, selected_text):
7576
if notepad.getEncoding() == BUFFERENCODING.ENC8BIT:
7677
_selected_text = unicode(selected_text, '{}'.format(self.GetACP()))
7778
else:
78-
_selected_text = unicode(selected_text, 'utf-8')
79+
_selected_text = selected_text
7980
return _selected_text
8081

8182

scripts/Samples/Sorter.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from Npp import editor, notepad
33
from unidecode import unidecode
44
from collections import OrderedDict
5-
import Tkinter as tk
5+
import tkinter as tk
66
import random
77

88
flags = OrderedDict() # default setting
@@ -63,11 +63,11 @@ def __sort(self, text, user_defined_key=None):
6363
if not user_defined_key is None:
6464
_key = user_defined_key
6565

66-
_lines = text.decode('utf8').splitlines()
66+
_lines = text.splitlines()
6767

6868
if flags['accent_converted']:
6969
_lines = [unidecode(line).decode('utf8') for line in _lines]
70-
print '\n'.join(_lines)
70+
print ('\n'.join(_lines))
7171

7272
if flags['sorting'] and not flags['random_sort']:
7373
_lines.sort(key=_key, reverse=flags['reverse_ordering'])
@@ -96,7 +96,7 @@ def run(self):
9696
editor.setText(line_ending.join(self.__sort(editor.getCharacterPointer())))
9797

9898
elif editor.getSelectionMode() == 1:
99-
print '-->> {}'.format(editor.getSelectionNStart(0))
99+
print ('-->> {}'.format(editor.getSelectionNStart(0)))
100100
start = editor.getSelectionNStart(0)
101101
end = editor.getSelectionNEnd(0)
102102
start_column = editor.getColumn(start)
@@ -114,7 +114,7 @@ def sort_as_int_if_possible(text):
114114
lines = self.__sort(editor.getTextRange(start_position_selected_lines, end_position_selected_lines),
115115
lambda x: sort_as_int_if_possible(x[start_column:end_column]))
116116

117-
print line_ending.join(lines)
117+
print (line_ending.join(lines))
118118
editor.setTarget(start_position_selected_lines, end_position_selected_lines)
119119
editor.replaceTarget(line_ending.join(lines))
120120
else:

scripts/Samples/Swap2Words.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# From https://sourceforge.net/p/npppythonscript/discussion/1199074/thread/988630ae/
3+
# Multi-Edit needs to be activated in the N++ edit preferences.
34

45
def getWord_Sel(selNum): # tuple of: word, word_start, word_end
56
sPos = editor.getSelectionNStart(selNum)

0 commit comments

Comments
 (0)