--- tkchat.tcl	Wed Mar 23 20:29:37 2011
+++ tkchat.tcl.new	Wed Jul 27 16:14:32 2011
@@ -47,8 +47,17 @@
 set imgdir [file join $tkchat_dir images]
 set auto_path [linsert $::auto_path 0 $tkchat_dir [file join $tkchat_dir lib]]
 
-package require Tcl 8.4		; # core Tcl
-package require Tk  8.4		; # core Tk
+# core Tcl use peer widget for seperate history if available
+if {[catch {package require Tcl 8.5}]} {
+    package require Tcl 8.4
+    package require Tk 8.4
+    set has_peer 0
+ } else {
+   package require Tk 8.5
+   set has_peer 1
+ }
+
+
 package require http 2		; # core Tcl
 package require msgcat		; # core Tcl
 package require textutil	; # tcllib 1.0
@@ -723,6 +732,7 @@
     # ... Or make the window invisible clearing it from all content
     
     variable useTile
+    global has_peer
     # remember current position in window:
     set fraction [lindex [.txt yview] 1]
     if {[winfo ismapped .cframe]} {
@@ -730,7 +740,9 @@
 	.pane2 forget .cframe
 	update idletasks
 	.clone configure -state normal
-	.clone delete 1.0 end
+  if {!$has_peer} {
+	     .clone delete 1.0 end
+  }
 	.mbar.vis entryconfigure "*current history*" -state normal
     } else {
 	# fill clone and display it:
@@ -739,7 +751,9 @@
 	} else {
 	    .pane2 add .cframe -before .txtframe
 	}
-	::tkchat::textClone .txt .clone
+  if {!$has_peer} {
+	     ::tkchat::textClone .txt .clone
+  }
 	.clone configure -state disabled
 	.mbar.vis entryconfigure "*current history*" -state disabled
     }
@@ -2964,8 +2978,8 @@
     
     # text widget to view history:
     # FIX ME: be nice to have a little theme-specific tab close button here.
-    # FIX ME: this should use the text widget clone feature if available.
     variable useClosebutton
+    global has_peer
     ${NS}::frame .cframe -relief groove
     if {$useClosebutton} {
         if {[catch {
@@ -2975,7 +2989,12 @@
         ${NS}::button .cbtn -text [mc "Close history pane"]
     }
     .cbtn configure -command ::tkchat::HistoryPaneToggle
-    ScrolledWidget text .clone 0 1 \
+    if {$has_peer} {
+      set widget_command {.txt peer create}
+    } else {
+      set widget_command text
+    }
+    ScrolledWidget $widget_command .clone 0 1 \
 	-wrap word -background #f0f0f0 -relief sunken -borderwidth 2 \
 	-font FNT -cursor left_ptr -height 1
     .clone tag bind URL <Enter> [list .clone configure -cursor hand2]
