Skip to content

Commit 7289861

Browse files
committed
Improved separator to adjust for multiple highlights (#11)
1 parent 32799ef commit 7289861

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

searchsploit.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def highlightTerm(line, term):
215215
return line
216216

217217

218-
def separater(lim, line1, line2):
218+
def separater(lim, line1:str, line2:str):
219219
""" Splits the two texts to fit perfectly within the terminal width
220220
"""
221221
lim = int(lim)
@@ -229,14 +229,22 @@ def separater(lim, line1, line2):
229229
format_string = "{{title:{title_length}.{title_length}s}}\033[0m | {{path:{path_length}.{path_length}s}}\033[0m"
230230

231231
# increase lim by markers to not include highlights in series
232-
if "\033[91m" in line1[:line1_length + 5]:
232+
last_mark = 0
233+
while (line1.find("\033[91m", last_mark, line1_length + 5) >= 0):
233234
line1_length += 5
234-
if "\033[0m" in line1[:line1_length + 4]:
235+
last_mark = line1.find("\033[91m", last_mark, line1_length + 5) + 5
236+
last_mark = 0
237+
while (line1.find("\033[0m", last_mark, line1_length + 4) >= 0):
235238
line1_length += 4
236-
if "\033[91m" in line2[:line2_length + 5]:
239+
last_mark = line1.find("\033[0m", last_mark, line1_length + 4) + 4
240+
last_mark = 0
241+
while (line2.find("\033[91m", last_mark, line2_length + 5) >= 0):
237242
line2_length += 5
238-
if "\033[0m" in line2[:line2_length + 4]:
243+
last_mark = line2.find("\033[91m", last_mark, line2_length + 5) + 5
244+
last_mark = 0
245+
while (line2.find("\033[0m", last_mark, line2_length + 4) >= 0):
239246
line2_length += 4
247+
last_mark = line2.find("\033[0m", last_mark, line2_length + 4) + 4
240248

241249

242250
# Creating format string for print

0 commit comments

Comments
 (0)