Posted to tcl by thomas at Tue Mar 02 21:26:05 GMT 2010view raw

  1. proc getInsertionLineNb { } {
  2. return [expr [lindex [scan [.t index end] %d.%d] 0] -1]
  3. }
  4.  
  5. text .t
  6. pack .t -expand yes -fill both
  7.  
  8. .t tag configure lp -foreground blue
  9.  
  10. .t insert end "\[timestamp1] "
  11. .t tag add lp [getInsertionLineNb].0 [getInsertionLineNb].end
  12. .t insert end "text1 to log\n"
  13.  
  14.  
  15. .t insert end "\[timestamp2] "
  16. .t tag add lp [getInsertionLineNb].0 [getInsertionLineNb].end
  17. .t insert end "text2 to log\n"