summaryrefslogtreecommitdiff
path: root/tex/context/base/java-imp-fld.mkiv
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2011-02-04 01:40:12 +0200
committerMarius <mariausol@gmail.com>2011-02-04 01:40:12 +0200
commit9f01e839943b3edf71e6272d9d9e40d9cb74d2ee (patch)
tree3d6937e032ebda2b57a9d983bc56029af65dd703 /tex/context/base/java-imp-fld.mkiv
parent9cad29f0d0ae5b3e2d4eb31218ad9f6c83d40b9f (diff)
downloadcontext-9f01e839943b3edf71e6272d9d9e40d9cb74d2ee.tar.gz
beta 2011.02.04 00:30
Diffstat (limited to 'tex/context/base/java-imp-fld.mkiv')
-rw-r--r--tex/context/base/java-imp-fld.mkiv453
1 files changed, 243 insertions, 210 deletions
diff --git a/tex/context/base/java-imp-fld.mkiv b/tex/context/base/java-imp-fld.mkiv
index 93a90dc0a..30847b201 100644
--- a/tex/context/base/java-imp-fld.mkiv
+++ b/tex/context/base/java-imp-fld.mkiv
@@ -11,216 +11,249 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-% will be simplified, since we now parse functions
-
-% nu nog alles geladen, moet dus anders
-
-\startJSpreamble {Sanitize_TeX_Input} used later
-
- function Sanitized_TeX_String (value)
- { var v = value ;
- v = v.replace( /\\\\oe/g,"\\234") ;
- v = v.replace( /\\\\<</g,"\\253") ;
- v = v.replace( /\\\\>>/g,"\\273") ;
- v = v.replace( /\\\\`A/g,"\\300") ;
- v = v.replace( /\\\\'A/g,"\\301") ;
- v = v.replace( /\\\\^A/g,"\\302") ;
- v = v.replace( /\\\\~A/g,"\\303") ;
- v = v.replace( /\\\\"A/g,"\\304") ;
- v = v.replace( /\\\\oA/g,"\\305") ;
- v = v.replace( /\\\\AE/g,"\\306") ;
- v = v.replace( /\\\\,C/g,"\\307") ;
- v = v.replace( /\\\\`E/g,"\\310") ;
- v = v.replace( /\\\\'E/g,"\\311") ;
- v = v.replace( /\\\\^E/g,"\\312") ;
- v = v.replace( /\\\\"E/g,"\\313") ;
- v = v.replace( /\\\\`I/g,"\\314") ;
- v = v.replace( /\\\\'I/g,"\\315") ;
- v = v.replace( /\\\\^I/g,"\\316") ;
- v = v.replace( /\\\\"I/g,"\\317") ;
- v = v.replace( /\\\\~N/g,"\\321") ;
- v = v.replace( /\\\\`O/g,"\\322") ;
- v = v.replace( /\\\\'O/g,"\\323") ;
- v = v.replace( /\\\\^O/g,"\\324") ;
- v = v.replace( /\\\\~O/g,"\\325") ;
- v = v.replace( /\\\\"O/g,"\\326") ;
- v = v.replace( /\\\\`U/g,"\\331") ;
- v = v.replace( /\\\\'U/g,"\\332") ;
- v = v.replace( /\\\\^U/g,"\\333") ;
- v = v.replace( /\\\\"U/g,"\\334") ;
- v = v.replace( /\\\\'Y/g,"\\335") ;
- v = v.replace( /\\\\ss/g,"\\337") ;
- v = v.replace( /\\\\`a/g,"\\340") ;
- v = v.replace( /\\\\'a/g,"\\341") ;
- v = v.replace( /\\\\^a/g,"\\342") ;
- v = v.replace( /\\\\~a/g,"\\343") ;
- v = v.replace( /\\\\"a/g,"\\344") ;
- v = v.replace( /\\\\oa/g,"\\345") ;
- v = v.replace( /\\\\ae/g,"\\346") ;
- v = v.replace( /\\\\,c/g,"\\347") ;
- v = v.replace( /\\\\`e/g,"\\350") ;
- v = v.replace( /\\\\'e/g,"\\351") ;
- v = v.replace( /\\\\^e/g,"\\352") ;
- v = v.replace( /\\\\"e/g,"\\353") ;
- v = v.replace( /\\\\`i/g,"\\354") ;
- v = v.replace( /\\\\'i/g,"\\355") ;
- v = v.replace( /\\\\^i/g,"\\356") ;
- v = v.replace( /\\\\"i/g,"\\357") ;
- v = v.replace( /\\\\~n/g,"\\361") ;
- v = v.replace( /\\\\`o/g,"\\362") ;
- v = v.replace( /\\\\'o/g,"\\363") ;
- v = v.replace( /\\\\^o/g,"\\364") ;
- v = v.replace( /\\\\~o/g,"\\365") ;
- v = v.replace( /\\\\"o/g,"\\366") ;
- v = v.replace( /\\\\`u/g,"\\371") ;
- v = v.replace( /\\\\'u/g,"\\372") ;
- v = v.replace( /\\\\^u/g,"\\373") ;
- v = v.replace( /\\\\"u/g,"\\374") ;
- v = v.replace( /\\\\'y/g,"\\375") ;
- v = v.replace( /\\\\"y/g,"\\377") ;
- return(v) }
-
- var TeX_Key_Mode = 0 ;
-
- function Initialize_TeX_Keystroke ()
- { TeX_Key_Char = "" ;
- TeX_Key_Mode = 0 }
-
- function Sanitized_TeX_Keystroke (change)
- { if (change=="\\\\")
- { TeX_Key_Mode = 1 ;
- return("") }
- else if (TeX_Key_Mode==1)
- { TeX_Key_Mode = 2 ;
- TeX_Key_Char = change ;
- return("") }
- else if (TeX_Key_Mode==2)
- { TeX_Key_Mode = 0 ;
- TeX_Key_Char = "\\\\"+TeX_Key_Char+change ;
- return(Sanitized_TeX_String(TeX_Key_Char)) }
- else
- { TeX_Key_Mode = 0 ;
- return(change) } }
+%D In \LUATEX\ the following does not work out well:
+%D
+%D \starttyping
+%D v = v.replace(/\\\\"e/g,"\\353") ;
+%D \stoptyping
+%D
+%D But this does:
+%D
+%D \starttyping
+%D v = String(v).replace(/\\\\"e/g,"\\353") ;
+%D \stoptyping
+%D
+%D Probably a \UNICODE\ issue. Beware, in \MKIV\ we have a
+%D different escaping of \type {\\}.
+
+\startluasetups javascript:pdfencoding
+ local verbatim = context.verbatim
+ verbatim("{\n")
+ for accent, group in table.sortedhash(characters.tex.accentmapping) do
+ for character, mapping in table.sortedhash(group) do
+ if character == "" then
+ character = " "
+ end
+ if accent == '"' then
+ verbatim(" '%s%s' : '\\u%04X',\n",accent,character,utf.byte(mapping))
+ else
+ verbatim(' "%s%s" : "\\u%04X",\n',accent,character,utf.byte(mapping))
+ end
+ end
+ end
+ verbatim(" 'OE' : '\\u0152',\n")
+ verbatim(" 'oe' : '\\u0153',\n")
+ verbatim(" 'AE' : '\\u00C6',\n")
+ verbatim(" 'ae' : '\\u00C7',\n")
+ verbatim(" '<<' : '\\u00AB',\n")
+ verbatim(" '>>' : '\\u00BB',\n")
+ verbatim(" 'ss' : '\\u00DF' \n")
+ verbatim("}\n")
+\stopluasetups
+
+% maybe make { } tex braces in javascript code so that we can call lua
+
+\def\JavaScriptTeXAccentMapping{\luasetup{javascript:pdfencoding}}
+
+\startJSpreamble SanitizeTeXInput used later
+
+var TeXAccentMapping = \JavaScriptTeXAccentMapping
+
+function TeX_Replacer(original,str) {
+ return (TeXAccentMapping[str] || str) ;
+}
-\stopJSpreamble
+function Sanitized_TeX_String(value) {
+ return (value.replace(/\\(..)/g, TeX_Replacer)) ;
+}
-\startJScode {Initialize_TeX_Key} uses {Sanitize_TeX_Input}
- Initialize_TeX_Keystroke() ;
-\stopJScode
+var TeX_Key_Mode = 0 ;
+var TeX_Key_Char = "" ;
-\startJScode {Convert_TeX_Key} uses {Sanitize_TeX_Input}
- if (!event.willCommit)
- { event.change = Sanitized_TeX_Keystroke(event.change) }
-\stopJScode
+function Initialize_TeX_Keystroke() {
+ TeX_Key_Char = "" ;
+ TeX_Key_Mode = 0 ;
+}
-\startJScode{Convert_TeX_String} uses {Sanitize_TeX_Input}
- event.value = Sanitized_TeX_String(event.value) ;
-\stopJScode
+function Sanitized_TeX_Keystroke(change) {
+ if (!event.willCommit) {
+ if (change=="\\") {
+ TeX_Key_Mode = 1 ;
+ return ("")
+ } else if (TeX_Key_Mode == 1) {
+ TeX_Key_Mode = 2 ;
+ TeX_Key_Char = change ;
+ return ("")
+ } else if (TeX_Key_Mode == 2) {
+ TeX_Key_Mode = 0 ;
+ TeX_Key_Char = "\\"+TeX_Key_Char+change ;
+ return (Sanitized_TeX_String(TeX_Key_Char))
+ } else {
+ TeX_Key_Mode = 0 ;
+ return (change)
+ }
+ }
+}
+
+function Initialize_TeX_Key() {
+ Initialize_TeX_Keystroke() ;
+}
-\startJSpreamble fields_1 used now
+function Convert_TeX_Key() {
+ if (!event.willCommit) {
+ event.change = Sanitized_TeX_Keystroke(event.change) ;
+ }
+}
+
+function Convert_TeX_String() {
+ event.value = Sanitized_TeX_String(event.value) ;
+}
+
+\stopJSpreamble
+
+% \startJScode {Initialize_TeX_Key} uses {SanitizeTeXInput}
+% Initialize_TeX_Keystroke() ;
+% \stopJScode
+%
+% \startJScode {Convert_TeX_Key} uses {SanitizeTeXInput}
+% if (!event.willCommit) {
+% event.change = Sanitized_TeX_Keystroke(event.change) ;
+% }
+% \stopJScode
+%
+% \startJScode{Convert_TeX_String} uses {SanitizeTeXInput}
+% event.value = Sanitized_TeX_String(event.value) ;
+% \stopJScode
+
+% was used now but we autocheck anyway so lets test this for a while
+
+\startJSpreamble FieldsStates used later
var visible_field = new Array() ;
var visible_fields = 0 ;
-function PresetFields ( )
- { this.syncAnnotScan() }
+function PresetFields() {
+ this.syncAnnotScan() ;
+}
-function Preset_Fields ( )
- { this.syncAnnotScan() }
+function Preset_Fields() {
+ this.syncAnnotScan() ;
+}
-function Hide_When_Down ( )
- { event.target.hidden = true }
+function Hide_When_Down() {
+ event.target.hidden = true ;
+}
-function Hide_Field ( Name )
- { var v = this.getField(Name) ;
- if (v)
- { v.hidden = true ;
+function Hide_Field(Name) {
+ var v = this.getField(Name) ;
+ if (v) {
+ v.hidden = true ;
v.readonly = true ;
- this.dirty = false } }
+ this.dirty = false ;
+ }
+}
-function Do_Vide_Field ( Name, Closable )
- { var v = this.getField(Name) ;
- if (v)
- { ++visible_fields ;
+function Do_Vide_Field(Name, Closable) {
+ var v = this.getField(Name) ;
+ if (v) {
+ ++visible_fields ;
visible_field[visible_fields] = Name ;
v.hidden = false ;
- if (Closable)
- { v.readonly = false ;
- v.value = "On" }
- this.dirty = false } }
-
-function Vide_Field ( Name )
- { Do_Vide_Field(Name,false) }
-
-function Vide_Hide_Field ( Name )
- { Do_Vide_Field(Name,true) }
-
-function Hide_Fields ()
- { while (visible_fields>0)
- { Hide_Field(visible_field[visible_fields]) ;
- --visible_fields } }
-
-function Vide_Fields ( Name )
- { Hide_Fields () ;
- Vide_Field ( Name) }
-
-function Vide_Hide_Fields ( Name )
- { Hide_Fields () ;
- Vide_Hide_Field ( Name) }
-
-function Toggle_Hide ( Name )
- { var v = this.getField(Name) ;
- if (v)
- { v.hidden = !v.hidden ;
- this.dirty = false } }
-
-function Field_On ( Name )
- { v = this.getField(Name) ;
- if (v) { v.value = "On" ; this.dirty = false } }
-
-function Field_Off ( Name )
- { var v = this.getField(Name) ;
- if (v) { v.value = "Off" ; this.dirty = false } }
-
-function Toggle_Value ( Name )
- { var v = this.getField(Name) ;
- if (v)
- { if (v.value=="On")
- { v.value = "Off" }
- else
- { v.value = "On" } }
- this.dirty = false }
-
-function Toggle_Read ( Name )
- { var v = this.getField(Name);
- if (v) { v.readonly = !v.readonly } }
-
-function Flip_Fields ( Name )
- { var Names = Name.split(",") ;
- for (var i=0;i<Names.length;i++)
- { v = this.getField(Names[i]) ;
- if (v)
- { v.hidden = !v.hidden ;
- v.value = "On" } } }
-
-function Forget_Changes ()
- { this.dirty = false }
-
-function ForgetChanges ()
- { this.dirty = false }
-\stopJSpreamble
+ if (Closable) {
+ v.readonly = false ;
+ v.value = "On" ;
+ }
+ this.dirty = false ;
+ }
+}
-%\startJScode{Hide_When_Down} Hide_When_Down() \stopJScode
-%\startJScode{Hide_Field} Hide_Field(JS_S_1) \stopJScode
-%\startJScode{Vide_Field} Vide_Field(JS_S_1) \stopJScode
-%\startJScode{Toggle_Hide} Toggle_Hide(JS_S_1) \stopJScode
-%\startJScode{Field_On} Field_On(JS_S_1) \stopJScode
-%\startJScode{Field_Off} Field_Off(JS_S_1) \stopJScode
-%\startJScode{Toggle_Value} Toggle_Value(JS_S_1) \stopJScode
-%\startJScode{Toggle_Read} Toggle_Read(JS_S_1) \stopJScode
-%\startJScode{Flip_Fields} Flip_Fields(JS_S_1) \stopJScode
-%
-%\startJScode{Forget_Changes} this.dirty = false \stopJScode
+function Vide_Field(Name) {
+ Do_Vide_Field(Name,false) ;
+}
+
+function Vide_Hide_Field(Name) {
+ Do_Vide_Field(Name,true) ;
+}
+
+function Hide_Fields() {
+ while (visible_fields>0) {
+ Hide_Field(visible_field[visible_fields]) ;
+ --visible_fields ;
+ }
+}
+
+function Vide_Fields(Name) {
+ Hide_Fields() ;
+ Vide_Field(Name) ;
+}
+
+function Vide_Hide_Fields(Name) {
+ Hide_Fields() ;
+ Vide_Hide_Field(Name) ;
+}
+
+function Toggle_Hide(Name) {
+ var v = this.getField(Name) ;
+ if (v) {
+ v.hidden = !v.hidden ;
+ this.dirty = false ;
+ }
+}
+
+function Field_On(Name) {
+ v = this.getField(Name) ;
+ if (v) {
+ v.value = "On" ;
+ this.dirty = false ;
+ }
+}
+
+function Field_Off(Name) {
+ var v = this.getField(Name) ;
+ if (v) {
+ v.value = "Off" ;
+ this.dirty = false ;
+ }
+}
+
+function Toggle_Value(Name) {
+ var v = this.getField(Name) ;
+ if (v) {
+ if (v.value == "On") {
+ v.value = "Off" ;
+ } else {
+ v.value = "On" ;
+ }
+ }
+ this.dirty = false ;
+}
+
+function Toggle_Read(Name) {
+ var v = this.getField(Name);
+ if (v) {
+ v.readonly = !v.readonly ;
+ }
+}
+
+function Flip_Fields(Name) {
+ var Names = Name.split(",") ;
+ for (var i=0; i < Names.length; i++) {
+ v = this.getField(Names[i]) ;
+ if (v) {
+ v.hidden = !v.hidden ;
+ v.value = "On" ;
+ }
+ }
+}
+
+function Forget_Changes() {
+ this.dirty = false ;
+}
+
+function ForgetChanges() {
+ this.dirty = false ;
+}
+\stopJSpreamble
\definereference[ForgetChanges][JS(Forget_Changes)]
@@ -229,7 +262,7 @@ function ForgetChanges ()
\startJSpreamble FieldStack used later
-function Reset_Fields ( FieldSet ) {
+function Reset_Fields(FieldSet) {
var i = 1 ;
while (true) {
v = this.getField(FieldSet+":"+i) ;
@@ -242,7 +275,7 @@ function Reset_Fields ( FieldSet ) {
}
}
-function Set_Fields ( FieldSet ) {
+function Set_Fields(FieldSet) {
var i = 1 ;
while (true) {
v = this.getField(FieldSet+":"+i) ;
@@ -255,7 +288,7 @@ function Set_Fields ( FieldSet ) {
}
}
-function Set_Field ( FieldSet, FieldName ) {
+function Set_Field(FieldSet, FieldName) {
Reset_Fields(FieldSet) ;
v = this.getField(FieldSet+":"+FieldName) ;
if (v) {
@@ -263,7 +296,7 @@ function Set_Field ( FieldSet, FieldName ) {
}
}
-function Reset_Field ( FieldSet, FieldName ) {
+function Reset_Field(FieldSet, FieldName) {
Set_Fields(FieldSet) ;
v = this.getField(FieldSet+":"+FieldName) ;
if (v) {
@@ -271,7 +304,7 @@ function Reset_Field ( FieldSet, FieldName ) {
}
}
-function Walk_Field ( FieldSet ) {
+function Walk_Field(FieldSet) {
var i = 1 ;
while (true) {
v = this.getField(FieldSet+":"+i) ;
@@ -298,7 +331,7 @@ function Walk_Field ( FieldSet ) {
var FieldSets = new Array() ;
-function Do_Get_Check_Walk_Field ( FieldSet ) {
+function Do_Get_Check_Walk_Field(FieldSet) {
var f = FieldSets[FieldSet]
if (! f) {
f = new Array() ;
@@ -313,7 +346,7 @@ function Do_Get_Check_Walk_Field ( FieldSet ) {
return f
}
-function Do_Next_Auto_Walk_Field ( FieldSet ) {
+function Do_Next_Auto_Walk_Field(FieldSet) {
var fieldset = Do_Get_Check_Walk_Field(FieldSet) ;
if (fieldset) {
var v = this.getField(FieldSet + ":" + fieldset.number) ;
@@ -329,12 +362,12 @@ function Do_Next_Auto_Walk_Field ( FieldSet ) {
v = this.getField(FieldSet + ":" + fieldset.number) ;
}
if (v) {
- v.value = "On"
+ v.value = "On" ;
}
}
}
-function Do_Stop_Auto_Walk_Field ( FieldSet ) {
+function Do_Stop_Auto_Walk_Field(FieldSet) {
var fieldset = Do_Get_Check_Walk_Field(FieldSet) ;
if (fieldset) {
try {
@@ -345,7 +378,7 @@ function Do_Stop_Auto_Walk_Field ( FieldSet ) {
}
}
-function Do_Start_Auto_Walk_Field ( FieldSet ) {
+function Do_Start_Auto_Walk_Field(FieldSet) {
var fieldset = Do_Get_Check_Walk_Field(FieldSet) ;
if (fieldset) {
Do_Stop_Auto_Walk_Field(FieldSet) ;
@@ -353,7 +386,7 @@ function Do_Start_Auto_Walk_Field ( FieldSet ) {
}
}
-function Start_Walk_Field ( FieldSet, Delay ) {
+function Start_Walk_Field(FieldSet, Delay) {
var fieldset = Do_Get_Check_Walk_Field(FieldSet) ;
if (fieldset) {
fieldset.number = 0 ;
@@ -367,7 +400,7 @@ function Start_Walk_Field ( FieldSet, Delay ) {
}
}
-function Pause_Walk_Field ( FieldSet ) {
+function Pause_Walk_Field(FieldSet) {
var fieldset = Do_Get_Check_Walk_Field(FieldSet) ;
if (fieldset) {
if (fieldset.running) {
@@ -382,7 +415,7 @@ function Pause_Walk_Field ( FieldSet ) {
}
}
-function Stop_Walk_Field ( FieldSet ) {
+function Stop_Walk_Field(FieldSet) {
var fieldset = Do_Get_Check_Walk_Field(FieldSet) ;
if (fieldset) {
Do_Stop_Auto_Walk_Field(FieldSet) ;
@@ -391,7 +424,7 @@ function Stop_Walk_Field ( FieldSet ) {
}
}
-function Reset_Walk_Field ( FieldSet ) {
+function Reset_Walk_Field(FieldSet) {
var fieldset = Do_Get_Check_Walk_Field(FieldSet) ;
if (fieldset) {
Do_Stop_Auto_Walk_Field(FieldSet) ;
@@ -402,7 +435,7 @@ function Reset_Walk_Field ( FieldSet ) {
}
}
-function Previous_Walk_Field ( FieldSet ) {
+function Previous_Walk_Field(FieldSet) {
var fieldset = Do_Get_Check_Walk_Field(FieldSet) ;
if (fieldset) {
Do_Stop_Auto_Walk_Field(FieldSet) ;
@@ -424,7 +457,7 @@ function Previous_Walk_Field ( FieldSet ) {
}
}
-function Next_Walk_Field ( FieldSet ) {
+function Next_Walk_Field(FieldSet) {
var fieldset = Do_Get_Check_Walk_Field(FieldSet) ;
if (fieldset) {
Do_Stop_Auto_Walk_Field(FieldSet) ;
@@ -448,7 +481,7 @@ function Next_Walk_Field ( FieldSet ) {
}
}
-function Set_Walk_Field_Delay ( FieldSet, Delay ) {
+function Set_Walk_Field_Delay(FieldSet, Delay) {
var fieldset = Do_Get_Check_Walk_Field(FieldSet) ;
if (fieldset) {
if (Delay) {