Re: [NTG-context] Any idea about copy or clone fieldstack?
Hi Chen, Zhichu Chen wrote: Hello everyone, I want to display dynamic system time on each page of my presentation. Displaying system time can be manipulated by JavaScript but, a field can be shown only once. So I used clone field and it works very well for me. But when I want to change the font (xxx presents the variable that gets the field): xxx.textFont = font.LucidaBright ; it can be compiled successfully, but when I open it with acrobat reader, there are many errors from javascript console. So I think that JS don't know the font, and I don't know how to embed the font into pdf file and make JS knows it. Have you tried the method described on page 402-403 of the Acrobat JavaScript Scripting Reference (AcroJS.pdf, 27.06.2005)? Search for Use of arbitrary fonts. If I understand it right, all you need is the *right name* of the font (as JS sees/names it). [ Acrobat is required, but the trial version should work. Maybe also Adobe Type Manager Light for the clean installation of a ps font under XP. ] To make sure that all clock relevant types are embeded, you can add something like \smashedhbox{\color[white]\YOURCLOCKFONT 0123456789:} to your document. This is all untested, so don't expect too much... But let me know if it works ;) Then I turned to use field stacks. I use MetaPost to draw some needles and use JS to set_Field the fieldstack to the correct frame. But when I want to display the second clock, it seems that I should write another JS code to control the other fieldstack. So is there some command that clones the fieldstack just like \copyfield? Or how to assign the font of the field as I like? As I know, there is no command that clones a complete fieldstack. This is all a bit confusing without any example code. HTH, Peter Thank you. -- Sincerely yours, Chen Zhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com http://zhichu.chen.googlepages.com | www.sinap.ac.cn http://www.sinap.ac.cn ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] Any idea about copy or clone fieldstack?
Thank you very much Peter On 10/19/06, Peter Rolf [EMAIL PROTECTED] wrote: Hi Chen,Have you tried the method described on page 402-403 of the Acrobat_javascript_ Scripting Reference ( AcroJS.pdf, 27.06.2005)? Search forUse of arbitrary fonts.If I understand it right, all you need is the *right name* of the font(as JS sees/names it).[ Acrobat is required, but the trial version should work. Maybe also Adobe Type Manager Light for the clean installation of a ps font underXP. ]To make sure that all clock relevant types are embeded, you can addsomething like\smashedhbox{\color[white]\YOURCLOCKFONT 0123456789:} to your document.This is all untested, so don't expect too much...But let me know if it works ;)As I know, there is no command that clones a complete fieldstack.This is all a bit confusing without any example code. HTH, Peter___ntg-context mailing listntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context I've only read the AcroJSGuide.pdf, and I thought it's all. Thank you to tell me that there is a more detailed reference. I'll try it now. -- Sincerely yours,ChenZhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com | www.sinap.ac.cn ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] An idea
Hans Hagen wrote: there is no need for verbatim mode when you convert anyway! Technically true, but if a simple \processinlineverbatim solves the same problem as yet-to-write code in almost any language, I's go for the former, since it does already exist. Other than that, I'd use ConTeXt's xml parser, since it requires much less escaping; and should suffice. Regards, Christopher ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] An idea
Christopher Creutzig wrote: Nikolai Weibull wrote: this than I have is welcome to finish it. The \highlight command should be defined something like this (pseudo-tex-code): \pdef\highlight[#1]{#2}% {\bgroup \setupcolorforgroup[#1]% \type{#2}% \egroup} #1 is a group name, such as Statement, Operator, or Comment. #2 may contain multiple lines, and I don’t know how well this will work on the TeX side. It may also contain special characters like {, #, , and so on. Suggestions? The most simple one I expect to work would be \def\highlight[#1]{% \bgroup \setuphighlightcolors[{#1}]% never forget those {}, %% since [] aren't balanced! \processinlineverbatim\egroup}% \egroup is an argument to % % \processinlineverbatim here OK, check the attachments for what I’ve got so far. It works well it seems. Still need to do more escaping, though. nikolai -- Nikolai Weibull: now available free of charge at http://bitwi.se/! Born in Chicago, IL USA; currently residing in Gothenburg, Sweden. main(){printf(linux[\021%six\012\0],(linux)[have]+fun-97);} Vim syntax support file Maintainer: Nikolai Weibull [EMAIL PROTECTED] Latest Revision: 2005-12-04 function! s:Format(text, group) let formatted = strtrans(a:text) let formatted = substitute(formatted, '{', '\\leftargument', 'g') let formatted = substitute(formatted, '}', '\\rightargument', 'g') TODO: Replace the reserved ConTeXt characters. TODO: make sure to escape everything. if a:group != let formatted = \\highlight[ . a:group . ']{' . formatted . '}' endif return formatted endfunction function! s:Append(text) exe s:new_win . 'wincmd w' call append(line('$'), a:text) exe s:org_win . 'wincmd w' endfunction function! s:AppendFillers(filler, diff_fillchar) let n = filler while n 0 let new = repeat(diff_fillchar, 3) if n 2 n filler !exists('context_whole_filler') let new .= ' ' . filler . ' inserted lines ' let n = 2 endif let new .= repeat(diff_fillchar, columns - strlen(new)) call s:Append(s:Format(new, 'DiffDelete')) let n -= 1 endwhile endfunction function! s:GetFillChar(char, default) let fillchar = fillchars[matchend(fillchars, a:char . ':')] return (fillchar != '' ? fillchar : default) endfunction function! s:MainLoop() Set up stuff for handling folding. if has('folding') !exists('context_ignore_folding') let fold_fillchar = s:GetFillChar('fold', '-') endif Set up stuff for handling diffs. let diff_fillchar = s:GetFillChar('diff', '-') let lnum = 1 let last = line('$') while lnum = last If there are filler lines for diff mode, show these above the line. let filler = diff_filler(lnum) if filler 0 call s:AppendFillers(filler, diff_fillchar) endif let new = if has('folding') !exists('context_ignore_folding') foldclosed(lnum) -1 let new = s:Format(new . foldtextresult(lnum), 'Folded') let lnum = foldclosedend(lnum) else let line = getline(lnum) let len = strlen(line) let diff_attr = diff_hlID(lnum, 1) let col = 1 while col = len || (col == 1 diff_attr) let start_col = col The start column for processing text. if diff_attr let id = diff_hlID(lnum, col) let col += 1 while col = len id == diff_hlID(lnum, col) | let col += 1 | endwhile if len columns Add spaces at the end to mark the changed line. let line = line . repeat(' ', columns - len) let len = columns endif else TODO: why not use synIDtrans here instead? That’t give longest possible matches. let id = synID(lnum, col, 1) let col += 1 while col = len id == synID(lnum, col, 1) | let col += 1 | endwhile endif Expand tabs. TODO: make a function? let new .= s:ExpandAndFormat(strpart(...), id) let expanded = strpart(line, start_col - 1, col - start_col) let idx = stridx(expanded, \t) while idx = 0 let i = ts - (idx + start_col - 1) % ts let expanded = substitute(expanded, '\t', repeat(' ', i), '') let idx = stridx(expanded, \t) endwhile if expanded =~ '^\s*$' let new .= expanded else let new .= s:Format(expanded, synIDattr(synIDtrans(id), 'name')) endif endwhile endif call s:Append(new) let lnum = lnum + 1 endwhile endfunction Set up options. let s:old_title = title let s:old_icon = icon let s:old_search = @/ set notitle noicon Split window to create a buffer with the ConTeXt file. let s:org_bufnr = winbufnr(0) if expand(%) == new untitled.tex else new %.tex endif let s:new_win = winnr() let s:org_win = bufwinnr(s:org_bufnr) Set up the new buffer. set
Re: [NTG-context] An idea
Christopher Creutzig wrote: Nikolai Weibull wrote: this than I have is welcome to finish it. The \highlight command should be defined something like this (pseudo-tex-code): \pdef\highlight[#1]{#2}% {\bgroup \setupcolorforgroup[#1]% \type{#2}% \egroup} #1 is a group name, such as Statement, Operator, or Comment. #2 may contain multiple lines, and I don�t know how well this will work on the TeX side. It may also contain special characters like {, #, , and so on. Suggestions? The most simple one I expect to work would be \def\highlight[#1]{% \bgroup \setuphighlightcolors[{#1}]% never forget those {}, %% since [] aren't balanced! \processinlineverbatim\egroup}% \egroup is an argument to % % \processinlineverbatim here (I did have some mildly elaborate low-level code here, but upon searching for the ConTeXt way of switching of everything, I came upon \processinlineverbatim, which probably does everything you want. If it does not, please come back and I'll send you something more low-level that should.) there is no need for verbatim mode when you convert anyway! Hans ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] An idea
Nikolai Weibull wrote: It would require very little programming. syntax/2html.vim, which converts the buffer to a HTML document with syntax highlighting, is 526 lines in the current CVS incarnation. A syntax/2context.vim would be even shorter, perhaps 150 to 200 lines. If I find the time I’ll write something this weekend. I’m catching a could though, so I might not :-(. A splitting headache notwithstanding, here’s a syntax/2context.vim that weighs in at 170 lines. There are still things to do, like figuring out how to complement this on the ConTeXt side (i.e., defining \highlight) and things will depend on how this is done. Some sort of \type environment would be nice, as it is better to not do escaping of special characters on the Vim side. Someone with better knowledge of how to do this than I have is welcome to finish it. The \highlight command should be defined something like this (pseudo-tex-code): \pdef\highlight[#1]{#2}% {\bgroup \setupcolorforgroup[#1]% \type{#2}% \egroup} #1 is a group name, such as Statement, Operator, or Comment. #2 may contain multiple lines, and I don’t know how well this will work on the TeX side. It may also contain special characters like {, #, , and so on. Suggestions? nikolai -- Nikolai Weibull: now available free of charge at http://bitwi.se/! Born in Chicago, IL USA; currently residing in Gothenburg, Sweden. main(){printf(linux[\021%six\012\0],(linux)[have]+fun-97);} Vim syntax support file Maintainer: Nikolai Weibull [EMAIL PROTECTED] Latest Revision: 2005-12-03 function! s:Format(text, group) let formatted = strtrans(a:text) TODO: Replace the reserved ConTeXt characters. return \\highlight[ . a:group . ']{' . formatted . '}' endfun Set up options. let s:old_title = title let s:old_icon = icon let s:old_et = l:et let s:old_report = report let s:old_search = @/ set notitle noicon setlocal et set report=100 Split window to create a buffer with the HTML file. let s:org_bufnr = winbufnr(0) if expand(%) == new untitled.tex else new %.tex endif let s:new_win = winnr() let s:org_win = bufwinnr(s:org_bufnr) Set up options in the new buffer. set modifiable %d let s:old_paste = paste set paste let s:old_magic = magic set magic Set up the buffer’s “header”. exe normal! a\\startlines\n\e Switch to the original window. exe s:org_win . 'wincmd w' Variables to keep track of the range to convert. let s:lnum = 1 let s:end = line('$') Set up stuff for handling folding. if has('folding') !exists('context_ignore_folding') let s:foldfillchar = fillchars[matchend(fillchars, 'fold:')] if s:foldfillchar == '' let s:foldfillchar = '-' endif endif Set up stuff for handling diffs. let s:difffillchar = fillchars[matchend(fillchars, 'diff:')] if s:difffillchar == '' let s:difffillchar = '-' endif Now, loop over all lines in the range. while s:lnum = s:end If there are filler lines for diff mode, show these above the line. let s:filler = diff_filler(s:lnum) if s:filler 0 let s:n = s:filler while s:n 0 let s:new = repeat(s:difffillchar, 3) if s:n 2 s:n s:filler !exists('context_whole_filler') let s:new = s:new . . s:filler . ' inserted lines ' let s:n = 2 endif let s:new = s:new . repeat(s:difffillchar, columns - strlen(s:new)) let s:new = s:Format(s:new, 'DiffDelete') exe s:new_win . 'wincmd w' exe 'normal! a' . s:new . \n\e exe s:org_win . 'wincmd w' let s:n -= 1 endwhile unlet s:n endif unlet s:filler let s:new = if has('folding') !exists('context_ignore_folding') foldclosed(s:lnum) -1 let s:new = s:Format(s:new . foldtextresult(s:lnum), 'Folded') let s:lnum = foldclosedend(s:lnum) else let s:line = getline(s:lnum) let s:len = strlen(s:line) let s:diffattr = diff_hlID(s:lnum, 1) let s:col = 1 while s:col = s:len || (s:col == 1 s:diffattr) let s:startcol = s:col The start column for processing text. if s:diffattr let s:id = diff_hlID(s:lnum, s:col) let s:col += 1 while s:col = s:len s:id == diff_hlID(s:lnum, s:col) | let s:col += 1 | endwhile if s:len columns Add spaces at the end to mark the changed line. let s:line = s:line . repeat(' ', columns - s:len) let s:len = columns endif else let s:id = synID(s:lnum, s:col, 1) let s:col += 1 while s:col = s:len s:id == synID(s:lnum, s:col, 1) | let s:col += 1 | endwhile endif Expand tabs. let s:expanded = strpart(s:line, s:startcol - 1, s:col - s:startcol) let idx = stridx(s:expanded, \t) while idx = 0 let i = ts - (idx + s:startcol - 1) % ts let s:expanded = substitute(s:expanded, '\t', repeat(' ', i), '') let idx = stridx(s:expanded, \t) endwhile Output the text with the same synID, with class set to {s:id_name}.
Re: [NTG-context] An idea
Zeljko Vrba wrote: A motivation and idea that came to mind while writing a post to comp.text.tex: == Then again, most (all?) of publishers require Latex source, if my document ever makes it that far.. And Latex has nicer source code formatting than Context. so I'm really split between Latex and Context.. what do you mean with source code formatting? None of them individually fit all (I admit, vague) requirements.. Context being able to chew up Latex .cls files and still allowing for its advanced formatting directives, long tables, and other goodies would be a perfect match. == Basically, rewrite standard Latex environments and commands (\chapter, \section, itemize, enumerate, etc..) present in article.cls and report.cls to expand to Context commands that give an equivalent layout.. How much work would it be? Either a Latex emulation environment or a new implementation of Latex classes for Context? I have to admit that I don't have time to start implementing either. I'm just interested in some feasibility opinions.. 80% of LatexContext transition can be done with a few simple regexes. Other 20% have to be translated by hand, and it is very painful, esp. if tables are in question.. brooks is working on that so maybe you should team up with him Hans ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] An idea
Zeljko Vrba wrote: A motivation and idea that came to mind while writing a post to comp.text.tex: == Then again, most (all?) of publishers require Latex source, if my document ever makes it that far.. And Latex has nicer source code formatting than Context. so I'm really split between Latex and Context.. None of them individually fit all (I admit, vague) requirements.. Context being able to chew up Latex .cls files and still allowing for its advanced formatting directives, long tables, and other goodies would be a perfect match. == We were planning on using Vim for preprocessing things like this instead of hacking TeX to do the lexing. I think Mojca (?) had some ideas for this and perhaps even a simple implementation, and given that there is now structured support for preprocessing in texexec I think that this can be done quite easily. A lot easier than writing something in TeX. nikolai -- Nikolai Weibull: now available free of charge at http://bitwi.se/! Born in Chicago, IL USA; currently residing in Gothenburg, Sweden. main(){printf(linux[\021%six\012\0],(linux)[have]+fun-97);} ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] An idea
Nikolai Weibull wrote: We were planning on using Vim for preprocessing things like this instead of hacking TeX to do the lexing. I think Mojca (?) had some ideas for this and perhaps even a simple implementation, and given that there is now structured support for preprocessing in texexec I think that this can be done quite easily. A lot easier than writing something in TeX. Speak for yourself. I'll take TeX over VIM anytime :-) Taco ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] An idea
On Fri, Dec 02, 2005 at 03:14:30PM +0100, Hans Hagen wrote: what do you mean with source code formatting? Something akin to lgrind. Pretty-printing C++ source code. I tried to adapt some existing Context code to C and C++ keywords, but failed somewhere.. AFAIR, I may have even once asked on this list about problems about variable declarations like a where the got swallowed up.. Anyway, I'm happy with the default typing environments, so that's one of the reasons I've given up on making it work. There isn't much use of color in black-white printing anyway. Grayscales just reduce the contrast and make the text harder to read. brooks is working on that so maybe you should team up with him hm! maybe I could find a little spare time to help him. i'm really annoyed by many of Latex's misfeatures... Best regards, Zeljko. ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] An idea
On Fri, Dec 02, 2005 at 05:56:36PM +0100, Nikolai Weibull wrote: We were planning on using Vim for preprocessing things like this instead Vim for preprocessing? Isn't it a bit too painful compared to using a real programming language? of hacking TeX to do the lexing. I think Mojca (?) had some ideas for I would agree with that. I never did any serious programming in TeX apart from few simple \defs. this and perhaps even a simple implementation, and given that there is now structured support for preprocessing in texexec I think that this can be done quite easily. A lot easier than writing something in TeX. any links to the project? ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context