Factorize
  • Overview
  • Repository
  • Tickets
  • Statistics
  • Projects

Repository

Fix plain text log display

Parent commits : 6bc6e6136b2137f0a31544428c95d48c14fb39ef,
Children commits : 68d01eef4cd8d5283ffca637159858582a94e331,

By lds on 2008-12-21 20:16:19
Fix plain text log display

git-svn-id: http://shan/svn/repos/factorize@14 51b56bfc-b269-4856-8701-af1c38ee6d62

Browse content
Difference with parent commit 6bc6e6136b2137f0a31544428c95d48c14fb39ef
Files modified:
factorize.py
--- 
+++ 
@@ -5,6 +5,8 @@
 import gui
 from optparse import OptionParser
 from copy import copy
+
+opt = None
 
 class FactorizedLine:
 	def __init__(s, parent = None):
@@ -207,10 +209,13 @@
 	
 		s.tree.build()
 
-opt_parser = OptionParser()
-opt_parser.add_option("-s", "--skip", help="skip the first X field of each line",
-		dest="skipped_fields", metavar="X")
-(opt, args) = opt_parser.parse_args()
-
-log = Log("/home/lds/Temporaire/log")
-gui.start(log)
+if __name__ == "__main__":
+	opt_parser = OptionParser()
+	opt_parser.add_option("-s", "--skip", help="skip the first X field of each line",
+			dest="skipped_fields", metavar="X")
+	(opt, args) = opt_parser.parse_args()
+	
+	if opt.skipped_fields is None:
+		opt.skipped_fields = "3"
+	log = Log("/home/lds/Temporaire/log")
+	gui.start(log)

gui.py
--- 
+++ 
@@ -300,7 +300,7 @@
 
 		while 1:
 			tree.Display()
-			plain.Display()
+			plain.Display(tree.highlighted_node)
 			gui.HandleKeys()
 
 	finally:

plain_gui.py
--- 
+++ 
@@ -1,11 +1,13 @@
 
+from factorize import CommonWord, opt
 import curses
 
 class PlainView:
 	def __init__(s, log):
+		s.x_pos = 61
 		s.x_off = 0
 		s.y_off = 0
-		s.x_size = 60
+		s.x_size = 100
 		s.y_size = 40
 		s.log = log
 		s.pad = curses.newpad(s.y_size,s.x_size)
@@ -13,7 +15,37 @@
 		s.cursor = 0
 		s.offset = 0
 
-	def Display(s):
-		for no, line in enumerate(s.log.lines[s.y_off : s.y_off + s.y_size]):
-			s.pad.refresh(0,0,0,0,s.y_size,s.x_size)
-			s.pad.addstr(no, 0, line)
+	def Match(s, line, highlighted):
+		if highlighted is None:
+			return
+
+		if opt is None:
+			return
+
+		words = line.split()[0:int(opt.skipped_fileds)]
+		word_no = 0
+
+		if len(words) < len(highlighted.factorized_words):
+			return False
+
+		for hl_word in highlighted.factorized_words:
+			if (not isinstance(hl_word, CommonWord)) and hl_word.word != words[word_no]:
+				return False
+			word_no += 1
+		return True
+			
+
+	def Display(s, highlighted):
+		for no, line in enumerate(s.log.lines[s.y_off : s.y_off + s.y_size - 1]):
+			disp = line.full_line[s.x_off:s.x_off+s.x_size]
+			#s.pad.addstr(no, 0, "a")
+			attr = 0
+			if s.Match(line.full_line, highlighted):
+				s.pad.addstr(no, 0, disp, curses.color_pair(1))
+			else:
+				s.pad.addstr(no, 0, disp)
+
+		s.pad.refresh(0,0,0,s.x_pos,s.y_size,s.x_size + s.x_pos)
+
+	#def HandleKey(s):
+		

Generated with KisssPM