2002-04-26 05:16:26 -07:00
|
|
|
##ifdef CAMLTK
|
|
|
|
|
|
|
|
(* sp to avoid being picked up by doc scripts *)
|
|
|
|
type index_constrs =
|
|
|
|
CNumber
|
|
|
|
| CActiveElement
|
|
|
|
| CEnd
|
|
|
|
| CLast
|
|
|
|
| CNoIndex
|
|
|
|
| CInsert
|
|
|
|
| CSelFirst
|
|
|
|
| CSelLast
|
|
|
|
| CAt
|
|
|
|
| CAtXY
|
|
|
|
| CAnchorPoint
|
|
|
|
| CPattern
|
|
|
|
| CLineChar
|
|
|
|
| CMark
|
|
|
|
| CTagFirst
|
|
|
|
| CTagLast
|
|
|
|
| CEmbedded
|
|
|
|
;;
|
|
|
|
|
|
|
|
let index_any_table =
|
|
|
|
[CNumber; CActiveElement; CEnd; CLast; CNoIndex; CInsert; CSelFirst;
|
|
|
|
CSelLast; CAt; CAtXY; CAnchorPoint; CPattern; CLineChar;
|
|
|
|
CMark; CTagFirst; CTagLast; CEmbedded]
|
|
|
|
;;
|
|
|
|
|
|
|
|
let index_canvas_table =
|
|
|
|
[CNumber; CEnd; CInsert; CSelFirst; CSelLast; CAtXY]
|
|
|
|
;;
|
|
|
|
let index_entry_table =
|
|
|
|
[CNumber; CAnchorPoint; CEnd; CInsert; CSelFirst; CSelLast; CAt]
|
|
|
|
;;
|
|
|
|
let index_listbox_table =
|
|
|
|
[CNumber; CActiveElement; CAnchorPoint; CEnd; CAtXY]
|
|
|
|
;;
|
|
|
|
let index_menu_table =
|
|
|
|
[CNumber; CActiveElement; CEnd; CLast; CNoIndex; CAt; CPattern]
|
|
|
|
;;
|
|
|
|
let index_text_table =
|
|
|
|
[CLineChar; CAtXY; CEnd; CMark; CTagFirst; CTagLast; CEmbedded]
|
|
|
|
;;
|
|
|
|
|
|
|
|
let cCAMLtoTKindex table = function
|
|
|
|
Number x -> chk_sub "Number" table CNumber; TkToken (string_of_int x)
|
|
|
|
| ActiveElement -> chk_sub "ActiveElement" table CActiveElement; TkToken "active"
|
|
|
|
| End -> chk_sub "End" table CEnd; TkToken "end"
|
|
|
|
| Last -> chk_sub "Last" table CLast; TkToken "last"
|
|
|
|
| NoIndex -> chk_sub "NoIndex" table CNoIndex; TkToken "none"
|
|
|
|
| Insert -> chk_sub "Insert" table CInsert; TkToken "insert"
|
|
|
|
| SelFirst -> chk_sub "SelFirst" table CSelFirst; TkToken "sel.first"
|
|
|
|
| SelLast -> chk_sub "SelLast" table CSelLast; TkToken "sel.last"
|
|
|
|
| At n -> chk_sub "At" table CAt; TkToken ("@"^string_of_int n)
|
|
|
|
| AtXY (x,y) -> chk_sub "AtXY" table CAtXY;
|
|
|
|
TkToken ("@"^string_of_int x^","^string_of_int y)
|
|
|
|
| AnchorPoint -> chk_sub "AnchorPoint" table CAnchorPoint; TkToken "anchor"
|
|
|
|
| Pattern s -> chk_sub "Pattern" table CPattern; TkToken s
|
|
|
|
| LineChar (l,c) -> chk_sub "LineChar" table CLineChar;
|
|
|
|
TkToken (string_of_int l^"."^string_of_int c)
|
|
|
|
| Mark s -> chk_sub "Mark" table CMark; TkToken s
|
|
|
|
| TagFirst t -> chk_sub "TagFirst" table CTagFirst;
|
|
|
|
TkToken (t^".first")
|
|
|
|
| TagLast t -> chk_sub "TagLast" table CTagLast;
|
|
|
|
TkToken (t^".last")
|
|
|
|
| Embedded w -> chk_sub "Embedded" table CEmbedded;
|
|
|
|
cCAMLtoTKwidget widget_any_table w
|
|
|
|
;;
|
|
|
|
|
|
|
|
let char_index c s =
|
|
|
|
let rec find i =
|
|
|
|
if i >= String.length s
|
|
|
|
then raise Not_found
|
|
|
|
else if String.get s i = c then i
|
|
|
|
else find (i+1) in
|
|
|
|
find 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
(* Assume returned values are only numerical and l.c *)
|
|
|
|
(* .menu index returns none if arg is none, but blast it *)
|
|
|
|
let cTKtoCAMLindex s =
|
|
|
|
try
|
|
|
|
let p = char_index '.' s in
|
|
|
|
LineChar(int_of_string (String.sub s 0 p),
|
|
|
|
int_of_string (String.sub s (p+1) (String.length s - p - 1)))
|
|
|
|
with
|
|
|
|
Not_found ->
|
|
|
|
try Number (int_of_string s)
|
|
|
|
with _ -> raise (Invalid_argument ("TKtoCAMLindex: "^s))
|
|
|
|
;;
|
|
|
|
|
|
|
|
##else
|
|
|
|
|
1999-11-30 06:59:39 -08:00
|
|
|
let cCAMLtoTKindex (* Don't put explicit typing *) = function
|
2000-02-16 03:51:37 -08:00
|
|
|
| `Num x -> TkToken (string_of_int x)
|
1999-11-30 06:59:39 -08:00
|
|
|
| `Active -> TkToken "active"
|
|
|
|
| `End -> TkToken "end"
|
|
|
|
| `Last -> TkToken "last"
|
|
|
|
| `None -> TkToken "none"
|
|
|
|
| `Insert -> TkToken "insert"
|
|
|
|
| `Selfirst -> TkToken "sel.first"
|
|
|
|
| `Sellast -> TkToken "sel.last"
|
2000-02-16 03:51:37 -08:00
|
|
|
| `At n -> TkToken ("@" ^ string_of_int n)
|
|
|
|
| `Atxy (x,y) -> TkToken ("@" ^ string_of_int x ^ "," ^ string_of_int y)
|
1999-11-30 06:59:39 -08:00
|
|
|
| `Anchor -> TkToken "anchor"
|
|
|
|
| `Pattern s -> TkToken s
|
2000-02-16 03:51:37 -08:00
|
|
|
| `Linechar (l,c) -> TkToken (string_of_int l ^ "." ^ string_of_int c)
|
1999-11-30 06:59:39 -08:00
|
|
|
| `Mark s -> TkToken s
|
2000-02-16 03:51:37 -08:00
|
|
|
| `Tagfirst t -> TkToken (t ^ ".first")
|
|
|
|
| `Taglast t -> TkToken (t ^ ".last")
|
1999-11-30 06:59:39 -08:00
|
|
|
| `Window (w : any widget) -> cCAMLtoTKwidget w
|
|
|
|
| `Image s -> TkToken s
|
2002-04-26 05:16:26 -07:00
|
|
|
;;
|
1999-11-30 06:59:39 -08:00
|
|
|
|
2002-04-26 05:16:26 -07:00
|
|
|
let cCAMLtoTKcanvas_index = (cCAMLtoTKindex : canvas_index -> tkArgs);;
|
|
|
|
let cCAMLtoTKentry_index = (cCAMLtoTKindex : entry_index -> tkArgs);;
|
|
|
|
let cCAMLtoTKlistbox_index = (cCAMLtoTKindex : listbox_index -> tkArgs);;
|
|
|
|
let cCAMLtoTKmenu_index = (cCAMLtoTKindex : menu_index -> tkArgs);;
|
|
|
|
let cCAMLtoTKtext_index = (cCAMLtoTKindex : text_index -> tkArgs);;
|
1999-11-30 06:59:39 -08:00
|
|
|
|
|
|
|
(* Assume returned values are only numerical and l.c *)
|
|
|
|
|
|
|
|
let cTKtoCAMLtext_index s =
|
|
|
|
try
|
2000-04-02 18:57:52 -07:00
|
|
|
let p = String.index s '.' in
|
2000-04-11 20:43:25 -07:00
|
|
|
`Linechar (int_of_string (String.sub s ~pos:0 ~len:p),
|
|
|
|
int_of_string (String.sub s ~pos:(p + 1)
|
|
|
|
~len:(String.length s - p - 1)))
|
1999-11-30 06:59:39 -08:00
|
|
|
with
|
|
|
|
Not_found ->
|
2000-02-16 03:51:37 -08:00
|
|
|
raise (Invalid_argument ("TKtoCAMLtext_index: " ^ s))
|
2002-04-26 05:16:26 -07:00
|
|
|
;;
|
1999-11-30 06:59:39 -08:00
|
|
|
|
|
|
|
let cTKtoCAMLlistbox_index s =
|
|
|
|
try `Num (int_of_string s)
|
2000-02-16 03:51:37 -08:00
|
|
|
with _ -> raise (Invalid_argument ("TKtoCAMLlistbox_index: " ^ s))
|
2002-04-26 05:16:26 -07:00
|
|
|
;;
|
|
|
|
|
|
|
|
##endif
|