Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

textutils.tcl File Reference


Detailed Description

This file contains some arbitrary usefull textutilities, mainly used in the CdgShell.

Author:
Michael Daum
Id
textutils.tcl,v 1.8 2004/09/06 13:40:54 micha Exp

Definition in file textutils.tcl.

Go to the source code of this file.

Distances between line segments

The following code to compute distances between line segments and points stolen shamelessly from Rory Daulton (rorydaulton@email.com), who posted it to delphi-talk@elists.org.

 dot (TclNumber x0, TclNumber y0, TclNumber x1, TclNumber y1)
 par_area (TclNumber x1, TclNumber y1, TclNumber x2, TclNumber y2)
 point_segment_distance (TclNumber x, TclNumber y, TclNumber ex0, TclNumber ey0, TclNumber ex1, TclNumber ey1)
 segment_length (TclNumber x0, TclNumber y0, TclNumber x1, TclNumber y1)
 segments_to_vectors (TclNumber ex0, TclNumber ey0, TclNumber ex1, TclNumber ey1, TclNumber x, TclNumber y)

Functions

 forAllMatches (TextWidget w, Index from, Index to, TclString pattern, TclCommand script)
 lfilter (TclList list, TclString pattern)
 smartCompare (TclString a, TclString b)


Function Documentation

dot TclNumber  x0,
TclNumber  y0,
TclNumber  x1,
TclNumber  y1
 

Find the dot product of two vectors.

Definition at line 124 of file textutils.tcl.

References dot().

Referenced by dot().

forAllMatches TextWidget  w,
Index  from,
Index  to,
TclString  pattern,
TclCommand  script
 

execute a script on every match in a text widget.

Parameters:
w a text widget
from the starting position from which to scan the text widget
to the ending position from which to scan the text widget
pattern the regular expression pattern to be matched
script a pice of code executed in the callers context
Definition at line 29 of file textutils.tcl.

References forAllMatches().

Referenced by forAllMatches().

lfilter TclList  list,
TclString  pattern
 

filter out items from a TclList.

Parameters:
list a TclList
pattern a regular expression pattern to be matched on each list item
Returns:
a new TclList only consisting of the items matching the pattern
Definition at line 47 of file textutils.tcl.

References lfilter().

Referenced by lfilter().

par_area TclNumber  x1,
TclNumber  y1,
TclNumber  x2,
TclNumber  y2
 

Calculate the signed area of the parallelogram that is formed by two vectors (by the origin and two given points). Definition at line 139 of file textutils.tcl.

References par_area().

Referenced by par_area().

point_segment_distance TclNumber  x,
TclNumber  y,
TclNumber  ex0,
TclNumber  ey0,
TclNumber  ex1,
TclNumber  ey1
 

Give distance of a point from a line segment.

Definition at line 146 of file textutils.tcl.

References point_segment_distance().

Referenced by point_segment_distance().

segment_length TclNumber  x0,
TclNumber  y0,
TclNumber  x1,
TclNumber  y1
 

Find the length of a line segment.

Definition at line 131 of file textutils.tcl.

References segment_length().

Referenced by segment_length().

segments_to_vectors TclNumber  ex0,
TclNumber  ey0,
TclNumber  ex1,
TclNumber  ey1,
TclNumber  x,
TclNumber  y
 

Convert two directed line segments, starting from the same point, to vectors Definition at line 110 of file textutils.tcl.

References segments_to_vectors().

Referenced by segments_to_vectors().

smartCompare TclString  a,
TclString  b
 

compare strings intelligently like ls -v does

Definition at line 61 of file textutils.tcl.

References smartCompare().

Referenced by smartCompare().


XCDG 0.95 (20 Oct 2004)