From 3ec6697b58e222b55f08f56ded6c7e35d5e313e8 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Fri, 28 Oct 2016 14:52:51 +0200 Subject: [PATCH] Update line_utils.py --- src/fenrir/utils/line_utils.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/fenrir/utils/line_utils.py b/src/fenrir/utils/line_utils.py index 88c99298..21088b56 100644 --- a/src/fenrir/utils/line_utils.py +++ b/src/fenrir/utils/line_utils.py @@ -40,8 +40,35 @@ def getNextLine(currX,currY, currText): currLine = wrappedLines[y] return x, y, currLine +#!/bin/python + def insertNewlines(string, every=64): - return b'\n'.join(string[i:i+every] for i in range(0, len(string), every)) + return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) def splitAtrrLines(string, every=64): return list(string[i:i+every] for i in range(0, len(string), every)) + +old = b'das ist ein test' +new = b'das axd ein test' +text = 'das iet ein test' + +text = insertNewlines(text,4) +alts = splitAtrrLines(old,4) +neus = splitAtrrLines(new,4) + +def trackHighlights(old, new, text): + result = '' + text = text.split('\n') + if len(old) != len(new): + return result + if len(text) != len(new): + return result + for line in range(len(new)): + if old[line] != new[line]: + for column in range(len(new)): + if old[line][column] != new[line][column]: + result += text[line][column] + result += ' ' + return result + +print(trackHighlights(alts,neus,text))