2002-04-26 05:16:26 -07:00
|
|
|
let cCAMLtoTKtextMark x = TkToken x;;
|
|
|
|
let cTKtoCAMLtextMark x = x;;
|
1999-11-30 06:59:39 -08:00
|
|
|
|
2002-04-26 05:16:26 -07:00
|
|
|
let cCAMLtoTKtextTag x = TkToken x;;
|
|
|
|
let cTKtoCAMLtextTag x = x;;
|
|
|
|
|
|
|
|
##ifdef CAMLTK
|
|
|
|
|
|
|
|
(* TextModifiers are never returned by Tk *)
|
|
|
|
let ppTextModifier = function
|
|
|
|
CharOffset n ->
|
|
|
|
if n > 0 then "+" ^ (string_of_int n) ^ "chars"
|
|
|
|
else if n = 0 then ""
|
|
|
|
else (string_of_int n) ^ "chars"
|
|
|
|
| LineOffset n ->
|
|
|
|
if n > 0 then "+" ^ (string_of_int n) ^ "lines"
|
|
|
|
else if n = 0 then ""
|
|
|
|
else (string_of_int n) ^ "lines"
|
|
|
|
| LineStart -> " linestart"
|
|
|
|
| LineEnd -> " lineend"
|
|
|
|
| WordStart -> " wordstart"
|
|
|
|
| WordEnd -> " wordend"
|
|
|
|
;;
|
|
|
|
|
|
|
|
let ppTextIndex = function
|
|
|
|
| TextIndexNone -> ""
|
|
|
|
| TextIndex (base, ml) ->
|
|
|
|
match cCAMLtoTKindex index_text_table base with
|
|
|
|
| TkToken ppbase -> List.fold_left (^) ppbase (List.map ppTextModifier ml)
|
|
|
|
| _ -> assert false
|
|
|
|
;;
|
|
|
|
|
|
|
|
let cCAMLtoTKtextIndex i =
|
|
|
|
TkToken (ppTextIndex i)
|
|
|
|
;;
|
|
|
|
|
|
|
|
##else
|
1999-11-30 06:59:39 -08:00
|
|
|
|
|
|
|
(* TextModifiers are never returned by Tk *)
|
1999-12-16 00:37:38 -08:00
|
|
|
let cCAMLtoTKtextIndex (i : textIndex) =
|
|
|
|
let ppTextModifier = function
|
2000-02-16 03:51:37 -08:00
|
|
|
| `Char n ->
|
1999-12-16 00:37:38 -08:00
|
|
|
if n > 0 then "+" ^ (string_of_int n) ^ "chars"
|
|
|
|
else if n = 0 then ""
|
|
|
|
else (string_of_int n) ^ "chars"
|
|
|
|
| `Line n ->
|
|
|
|
if n > 0 then "+" ^ (string_of_int n) ^ "lines"
|
|
|
|
else if n = 0 then ""
|
|
|
|
else (string_of_int n) ^ "lines"
|
|
|
|
| `Linestart -> " linestart"
|
|
|
|
| `Lineend -> " lineend"
|
|
|
|
| `Wordstart -> " wordstart"
|
|
|
|
| `Wordend -> " wordend"
|
|
|
|
in
|
|
|
|
let ppTextIndex (base, ml : textIndex) =
|
|
|
|
match cCAMLtoTKtext_index base with
|
|
|
|
TkToken ppbase ->
|
2000-04-11 20:43:25 -07:00
|
|
|
String.concat ~sep:"" (ppbase :: List.map ~f:ppTextModifier ml)
|
1999-12-16 00:37:38 -08:00
|
|
|
| _ -> assert false
|
|
|
|
in
|
1999-11-30 06:59:39 -08:00
|
|
|
TkToken (ppTextIndex i)
|
2002-04-26 05:16:26 -07:00
|
|
|
;;
|
1999-11-30 06:59:39 -08:00
|
|
|
|
2002-04-26 05:16:26 -07:00
|
|
|
##endif
|