fix highlighting for selections
This commit is contained in:
17
bigtext.py
17
bigtext.py
@@ -1,9 +1,7 @@
|
||||
import math
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
from typing import Optional, List, Callable
|
||||
import PyQt6.QtGui
|
||||
from typing import Callable
|
||||
from PyQt6 import QtGui
|
||||
|
||||
from PyQt6.QtCore import *
|
||||
@@ -14,20 +12,17 @@ from PyQt6.QtWidgets import *
|
||||
import constants
|
||||
from ScaledScrollBar import ScaledScrollBar
|
||||
from conversion import humanbytes
|
||||
from highlight import Highlight
|
||||
from highlight_regex import HighlightRegex
|
||||
from highlight_selection import HighlightSelection
|
||||
from highlighted_range import HighlightedRange
|
||||
from highlightingdialog import HighlightingDialog
|
||||
from line import Line
|
||||
from logFileModel import LogFileModel
|
||||
import re
|
||||
|
||||
|
||||
from ravenui import RavenUI
|
||||
from settings import Settings
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
import threading
|
||||
|
||||
|
||||
|
||||
class FileObserver(FileSystemEventHandler):
|
||||
@@ -310,12 +305,12 @@ class InnerBigText(QWidget):
|
||||
column_in_line = self.x_pos_to_column(e.pos().x()) + self._left_offset
|
||||
column_in_line = min(column_in_line, line.length()) # x was behind the last column of this line
|
||||
char_in_line = line.column_to_char(column_in_line)
|
||||
# print("%s in line %s" % (char_in_line, line_number))
|
||||
# print("%s in line %s lcolumn_in_line=%s" % (char_in_line, line_number, column_in_line))
|
||||
byte_in_line = line.char_index_to_byte(char_in_line)
|
||||
current_byte = line.byte_offset() + byte_in_line - 1
|
||||
current_byte = line.byte_offset() + byte_in_line
|
||||
# print("%s + %s = %s" % (line.byte_offset(), char_in_line, current_byte))
|
||||
else:
|
||||
current_byte = self.model.byte_count() - 1
|
||||
current_byte = self.model.byte_count()
|
||||
return current_byte
|
||||
|
||||
def _has_selection(self):
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
01234
|
||||
01234567890123456789
|
||||
012345678901234567890123456789012345678901234567890123456789
|
||||
0123456789012345678901234567890123456789
|
||||
|
||||
@@ -5,7 +5,6 @@ from highlighted_range import HighlightedRange
|
||||
from line import Line
|
||||
from PyQt6.QtCore import *
|
||||
from PyQt6.QtGui import *
|
||||
from PyQt6.QtWidgets import *
|
||||
|
||||
from settings import Settings
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ class LogFileModel:
|
||||
offset_in_line = byte_offset - line.byte_offset()
|
||||
char_index = line.byte_index_to_char_index(offset_in_line)
|
||||
current_char = line.line()[char_index]
|
||||
# print("read_word: char_index=%s, current_char=%s, line=%s" %(char_index, current_char, line.line()))
|
||||
if not self._is_word_char(current_char):
|
||||
return current_char, byte_offset, byte_offset + 1
|
||||
start_in_line = line.byte_index_to_char_index(byte_offset - line.byte_offset())
|
||||
@@ -123,7 +124,8 @@ class LogFileModel:
|
||||
while l := f.readline():
|
||||
new_offset = f.tell()
|
||||
line = Line(offset, new_offset,
|
||||
l.decode("utf8", errors="ignore").replace("\r", "").replace("\n", ""))
|
||||
l.decode("utf8", errors="ignore") # .replace("\r", "").replace("\n", "")
|
||||
)
|
||||
# print("%s %s %s" %(line.byte_offset(), line.line(), line.byte_end()))
|
||||
if line.byte_end() <= byte_offset: # line.byte_end() returns the end byte +1
|
||||
lines_before_offset.append(line)
|
||||
|
||||
Reference in New Issue
Block a user