Tk Library Source Code

Artifact [5f27c8b005]
Login

Artifact 5f27c8b0058baffb84c9ed343188d5a8ccb65ebd:

Ticket change [5f27c8b005] - New ticket [5e324065bfb46f73|5e324065bf] <i>Improved history module of Tklib</i>. by aku 2016-10-18 05:06:17.
D 2016-10-18T05:06:17.275
J assignee nobody
J closer nobody
J cmimetype text/plain
J comment I\shave\smade\stwo\simprovements\sto\sthe\shistory\smodule:\r\n1.\sAvoid\smultiple\sadd\sof\ssame\stext\sto\sthe\sentry\shistory\r\n2.\sFixed\sweird\sbehaviour\sat\sthe\send\sof\sthe\shistory\slist:\sI\shad\sto\spress\stwo\stimes\sthe\sup\sarrow\sin\sorder\sto\sget\sthe\sprevious\slist\svalue.\r\n\r\nHere\sis\sthe\smodified\scode.\sI\shope\sit\swill\sfind\sit's\sway\sinto\sthe\snext\srelease.\r\n\r\n#\shistory.tcl\s--\r\n#\r\n#\s\s\s\s\s\s\sProvides\sa\shistory\smechanism\sfor\sentry\swidgets\r\n#\r\n#\sCopyright\s(c)\s2005\s\s\s\sAaron\sFaupell\s<[email protected]>\r\n#\r\n#\sSee\sthe\sfile\s"license.terms"\sfor\sinformation\son\susage\sand\sredistribution\r\n#\sof\sthis\sfile,\sand\sfor\sa\sDISCLAIMER\sOF\sALL\sWARRANTIES.\r\n#\r\n#\sRCS:\s@(#)\s$Id:\shistory.tcl,v\s1.4\s2005/08/25\s03:36:58\sandreas_kupries\sExp\s$\r\n\r\npackage\srequire\sTk\r\npackage\sprovide\shistory\s0.1\r\n\r\nnamespace\seval\shistory\s{\r\n\s\s\s\sbind\sHistory\s<Up>\s\s\s{::history::up\s%W}\r\n\s\s\s\sbind\sHistory\s<Down>\s{::history::down\s%W}\r\n}\r\n\r\nproc\s::history::init\s{w\s{len\s30}}\s{\r\n\s\s\s\svariable\shistory\r\n\s\s\s\svariable\sprefs\r\n\s\s\s\sset\sbt\s[bindtags\s$w]\r\n\s\s\s\sif\s{[lsearch\s$bt\sHistory]\s>\s-1}\s{\serror\s"$w\salready\shas\sa\shistory"\s}\r\n\s\s\s\sif\s{[set\si\s[lsearch\s$bt\s$w]]\s<\s0}\s{\serror\s"cant\sfind\s$w\sin\sbindtags"\s}\r\n\s\s\s\sbindtags\s$w\s[linsert\s$bt\s[expr\s{$i\s+\s1}]\sHistory]\r\n\s\s\s\sarray\sset\shistory\s[list\s$w,list\s{}\s$w,cur\s0]\r\n\s\s\s\sset\sprefs(maxlen,$w)\s$len\r\n\s\s\s\sreturn\s$w\r\n}\r\n\r\nproc\s::history::remove\s{w}\s{\r\n\s\s\s\svariable\shistory\r\n\s\s\s\svariable\sprefs\r\n\s\s\s\sset\sbt\s[bindtags\s$w]\r\n\s\s\s\sif\s{[set\si\s[lsearch\s$bt\sHistory]]\s<\s0}\s{\serror\s"$w\shas\sno\shistory"\s}\r\n\s\s\s\sbindtags\s$w\s[lreplace\s$bt\s$i\s$i]\r\n\s\s\s\sunset\sprefs(maxlen,$w)\shistory($w,list)\shistory($w,cur)\r\n}\r\n\r\nproc\s::history::add\s{w\sline}\s{\r\n\s\s\s\svariable\shistory\r\n\s\s\s\svariable\sprefs\r\n\s\s\s\sif\s{$history($w,cur)\s>\s0\s&&\s[lindex\s$history($w,list)\s$history($w,cur)]\s==\s$line}\s{\r\n\s\s\s\s\s\s\s\sset\shistory($w,list)\s[lreplace\s$history($w,list)\s$history($w,cur)\s$history($w,cur)]\r\n\s\s\s\s}\r\n\s\s\s\sset\sidx\s[lsearch\s-dictionary\s$history($w,list)\s$line]\r\n\s\s\s\sif\s{$idx>=0}\s{\r\n\s\s\s\s\s\s\s\sset\s$history($w,list)\s[lreplace\s$history($w,list)\s$idx\s$idx]\r\n\s\s\s\s}\r\n\s\s\s\sset\shistory($w,list)\s[linsert\s$history($w,list)\s0\s$line]\r\n\s\s\s\sset\shistory($w,list)\s[lrange\s$history($w,list)\s0\s$prefs(maxlen,$w)]\r\n\s\s\s\sset\shistory($w,cur)\s0\r\n}\r\n\r\nproc\s::history::up\s{w}\s{\r\n\s\s\s\svariable\shistory\r\n\s\s\s\sif\s{[lindex\s$history($w,list)\s[expr\s{$history($w,cur)\s+\s1}]]\s!=\s""}\s{\r\n\s\s\s\s\s\s\s\sif\s{$history($w,cur)\s==\s0}\s{\r\n\s\s\s\s\s\s\s\s\s\s\s\sset\shistory($w,tmp)\s[$w\sget]\r\n\s\s\s\s\s\s\s\s}\r\n\s\s\s\s\s\s\s\s$w\sdelete\s0\send\r\n\s\s\s\s\s\s\s\sincr\shistory($w,cur)\r\n\s\s\s\s\s\s\s\s$w\sinsert\send\s[lindex\s$history($w,list)\s$history($w,cur)]\r\n\s\s\s\s}\selse\s{\r\n\s\s\s\s\s\s\s\salert\s$w\r\n\s\s\s\s}\r\n}\r\n\r\nproc\s::history::down\s{w}\s{\r\n\s\s\s\svariable\shistory\r\n\s\s\s\sif\s{$history($w,cur)\s!=\s0}\s{\r\n\s\s\s\s\s\s\s\s$w\sdelete\s0\send\r\n\s\s\s\s\s\s\s\sif\s{$history($w,cur)\s==\s0}\s{\r\n\s\s\s\s\s\s\s\s\s\s\s\s$w\sinsert\send\s$history($w,tmp)\r\n\s\s\s\s\s\s\s\s\s\s\s\sset\shistory($w,cur)\s0\r\n\s\s\s\s\s\s\s\s}\selse\s{\r\n\s\s\s\s\s\s\s\s\s\s\s\sincr\shistory($w,cur)\s-1\r\n\s\s\s\s\s\s\s\s\s\s\s\s$w\sinsert\send\s[lindex\s$history($w,list)\s$history($w,cur)]\r\n\s\s\s\s\s\s\s\s}\r\n\s\s\s\s}\selse\s{\r\n\s\s\s\s\s\s\s\salert\s$w\r\n\s\s\s\s}\r\n}\r\n\r\nproc\s::history::get\s{w}\s{\r\n\s\s\s\svariable\shistory\r\n\s\s\s\sreturn\s$history($w,list)\r\n}\r\n\r\nproc\s::history::clear\s{w}\s{\r\n\s\s\s\svariable\shistory\r\n\s\s\s\sset\shistory($w,cur)\s0\r\n\s\s\s\sset\shistory($w,list)\s{}\r\n\s\s\s\sunset\s-nocomplain\shistory($w,tmp)\r\n}\r\n\r\nproc\s::history::configure\s{w\soption\s{value\s{}}}\s{\r\n\s\s\s\svariable\shistory\r\n\s\s\s\svariable\sprefs\r\n\s\s\s\sswitch\s-exact\s--\s$option\s{\r\n\s\s\s\s\s\s\s\slength\s{\r\n\s\s\s\s\s\s\s\s\s\s\s\sif\s{$value\s==\s""}\s{\sreturn\s$prefs(maxlen,$w)\s}\r\n\s\s\s\s\s\s\s\s\s\s\s\sif\s{![string\sis\sinteger\s-strict\s$value]}\s{\serror\s"length\smust\sbe\san\sinteger"\s}\r\n\s\s\s\s\s\s\s\s\s\s\s\sset\sprefs(maxlen,$w)\s$value\r\n\s\s\s\s\s\s\s\s}\r\n\s\s\s\s\s\s\s\salert\s{\r\n\s\s\s\s\s\s\s\s\s\s\s\sif\s{$value\s==\s""}\s{\sreturn\s[info\sbody\s::history::alert]\s}\r\n\s\s\s\s\s\s\s\s\s\s\s\sproc\s::history::alert\sw\s$value\r\n\s\s\s\s\s\s\s\s}\r\n\s\s\s\s\s\s\s\sdefault\s{\r\n\s\s\s\s\s\s\s\s\s\s\s\serror\s"unknown\soption\s$option"\r\n\s\s\s\s\s\s\s\s}\r\n\s\s\s\s}\r\n}\r\n\r\nproc\s::history::alert\s{w}\s{bell}
J foundin 0.1
J is_private 0
J login aku
J priority 5\sMedium
J private_contact dac83924bb70a68f6807871ce80578576828377e
J resolution None
J severity Minor
J status Open
J submitter aku
J subsystem A\sCategory\sIs\sMissing
J title Improved\shistory\smodule\sof\sTklib
J type Patch
K 5e324065bfb46f73dcbaa6ef1c7cc24890968602
U aku
Z 99a3dccacbf42019719cd6b540888f79