Check-in [6c7a410ba0]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:merge with trunk
Timelines: family | ancestors | descendants | both | wtf-8-experiment
Files: files | file ages | folders
SHA1: 6c7a410ba0cb4dfe472e2793fa9b21366e3c4857
User & Date: chw 2019-06-12 13:05:47
Context
2019-06-13
12:55
merge with trunk check-in: cd7193897b user: chw tags: wtf-8-experiment
2019-06-12
13:05
merge with trunk check-in: 6c7a410ba0 user: chw tags: wtf-8-experiment
13:05
improve twv demos check-in: d0fc7d3af8 user: chw tags: trunk
11:35
merge with trunk check-in: 7a33036b05 user: chw tags: wtf-8-experiment
Changes

Changes to jni/sdl2tk/library/tk.tcl.

   494    494   # ----------------------------------------------------------------------
   495    495   # Setup flags/vars for SDL, screen dpi, and Android.
   496    496   # ----------------------------------------------------------------------
   497    497   
   498    498   namespace eval ::tk {
   499    499       variable sdltk [expr {[info command "sdltk"] eq "sdltk"}]
   500    500       variable dpi
   501         -    set dpi [expr int((25.4 * [winfo screenwidth .]) / [winfo screenmmwidth .])]
          501  +    set dpi [winfo screenmmwidth .]
          502  +    if {$dpi <= 0} {
          503  +	# Observed in X on Wayland in a VM, provide fallback
          504  +	set dpi 75
          505  +    } else {
          506  +	set dpi [expr {int((25.4 * [winfo screenwidth .]) / $dpi)}]
          507  +    }
   502    508       variable android 0
   503    509       if {$sdltk} {
   504    510   	set android [sdltk android]
   505    511       }
   506    512   }
   507    513   
   508    514   # ----------------------------------------------------------------------

Changes to jni/sdl2tk/unix/tkUnixEvent.c.

   163    163       */
   164    164       display = XkbOpenDisplay((char *)displayNameStr, &event, &error, &major,
   165    165   	    &minor, &reason);
   166    166   
   167    167       if (display == NULL) {
   168    168   	/*fprintf(stderr,"event=%d error=%d major=%d minor=%d reason=%d\nDisabling xkb\n",
   169    169   	event, error, major, minor, reason);*/
   170         -	display  = XOpenDisplay(displayNameStr);
          170  +	display = XOpenDisplay(displayNameStr);
   171    171       } else {
   172    172   	use_xkb = TK_DISPLAY_USE_XKB;
   173    173   	/*fprintf(stderr, "Using xkb %d.%d\n", major, minor);*/
   174    174       }
   175    175   
   176    176       if (display == NULL) {
   177    177   	return NULL;
................................................................................
   183    183   #ifdef TK_USE_INPUT_METHODS
   184    184       OpenIM(dispPtr);
   185    185       XRegisterIMInstantiateCallback(dispPtr->display, NULL, NULL, NULL,
   186    186   	    InstantiateIMCallback, (XPointer) dispPtr);
   187    187   #endif
   188    188       Tcl_CreateFileHandler(ConnectionNumber(display), TCL_READABLE,
   189    189   	    DisplayFileProc, dispPtr);
          190  +
          191  +    /*
          192  +     * Observed weird WidthMMOfScreen() in X on Wayland on a
          193  +     * Fedora 30/i386 running in a VM. Fallback to 75 dpi,
          194  +     * otherwise many other strange things may happen later.
          195  +     */
          196  +    if (WidthMMOfScreen(DefaultScreenOfDisplay(display)) <= 0) {
          197  +	int mm;
          198  +
          199  +	mm = (WidthOfScreen(DefaultScreenOfDisplay(display)) * 25.4) / 75.0;
          200  +	WidthMMOfScreen(DefaultScreenOfDisplay(display)) = mm;
          201  +    }
          202  +    if (HeightMMOfScreen(DefaultScreenOfDisplay(display)) <= 0) {
          203  +	int mm;
          204  +
          205  +	mm = (HeightOfScreen(DefaultScreenOfDisplay(display)) * 25.4) / 75.0;
          206  +	HeightMMOfScreen(DefaultScreenOfDisplay(display)) = mm;
          207  +    }
   190    208   
   191    209       /*
   192    210        * Key map info must be available immediately, because of "send event".
   193    211        */
   194    212       TkpInitKeymapInfo(dispPtr);
   195    213   
   196    214       return dispPtr;

Changes to undroid/tsb/examples/cheatsheet.tsb.

     6      6    <dd>The Webview for displaying the page.</dd>
     7      7    <dt><b>H</b></dt>
     8      8    <dd>The history array of input fields, keys are integer numbers starting from 1.</dd>
     9      9   </dl>} 5 {# current state of history array
    10     10   table 2 [array get H]} 6 {h4 "Useful procs in the global namespace"} 7 {info proc *} 8 {#HTML
    11     11   <dl>
    12     12    <dt><code><b>parray</b> arrayname ?pattern?</code></dt>
    13         - <dd>Pretty print an array using <code><b>puts</b></code> and thus outputs after the corresponding input field.</dd><br>
           13  + <dd>Pretty print an array using <code><b>puts</b></code> and thus outputs
           14  +     after the corresponding input field.</dd><br>
    14     15    <dt><code><b>htmlraw</b> html ?hidden?</code></dt>
    15         - <dd>Output raw HTML after the corresponding input field, if <code>hidden</code> is true, auto-hide the input field.</dd><br>
           16  + <dd>Output raw HTML after the corresponding input field, if <code>hidden</code>
           17  +     is true, auto-hide the input field.</dd><br>
    16     18    <dt><code><b>gets</b></code>, <code><b>read</b></code></dt>
    17         - <dd>Overriden, reading from <code>stdin</code> channel yields empty string.</dd><br>
           19  + <dd>Overriden, reading from <code>stdin</code> channel yields empty
           20  +     string.</dd><br>
    18     21    <dt><code><b>puts</b></code></dt>
    19         - <dd>Overriden, writing to <code>stdout</code>/<code>stderr</code> channels outputs after the corresponding input field.</dd><br>
           22  + <dd>Overriden, writing to <code>stdout</code>/<code>stderr</code> channels
           23  +     outputs after the corresponding input field.</dd><br>
    20     24    <dt><code><b>h1</b> string</code>, <code><b>h2..h5</b></code></dt>
    21         - <dd>Format a HTML header after the correspondig input field, auto-hide the input field.</dd><br>
           25  + <dd>Format a HTML header after the correspondig input field, auto-hide
           26  +     the input field.</dd><br>
           27  + <dt><code><b>hr</b></code></dt>
           28  + <dd>Format a horizontal ruler, auto-hide the input field.</dd><br>
    22     29    <dt><code><b>img</b> ?filename import mime?</code></dt>
    23         - <dd>Format a HTML IMG given <code>filename</code>, if file name omitted, present file selection. If <code>import</code> is true, the image is inlined. If the mime type of the image is unknown it can be specified with the <code>mime</code> parameter.</dd><br>
           30  + <dd>Format a HTML IMG given <code>filename</code>, if file name omitted,
           31  +     present file selection. If <code>import</code> is true, the image is
           32  +     inlined. If the mime type of the image is unknown it can be specified
           33  +     with the <code>mime</code> parameter.</dd><br>
    24     34    <dt><code><b>img_from_binary</b> data mime ?hidden?</code></dt>
    25         - <dd>Format a HTML IMG given the byte array <code>data</code> and mime type <code>mime</code>. If <code>hidden</code> is false, the corresponding input field is not auto-hidden.</dd><br>
           35  + <dd>Format a HTML IMG given the byte array <code>data</code> and mime
           36  +     type <code>mime</code>. If <code>hidden</code> is false, the corresponding
           37  +     input field is not auto-hidden.</dd><br>
    26     38    <dt><code><b>table</b> ncols data</code></dt>
    27         - <dd>Format a HTML table, <code>ncols</code> gives the number of columns, if negative, use the first <code>-ncols</code> items as header columns.</dd>
           39  + <dd>Format a HTML table, <code>ncols</code> gives the number of columns,
           40  +     if negative, use the first <code>-ncols</code> items as header columns.</dd>
    28     41   </dl>} 9 {h4 "Useful procs in the tsb namespace"} 10 {info proc tsb::*} 11 {#HTML
    29     42   <dl>
    30     43    <dt><code><b>tsb::load</b> ?filename?</code></dt>
    31     44    <dd>Load page from given <code>filename</code>, if file name omitted, present file selection.</dd><br>
    32     45    <dt><code><b>tsb::save</b> ?filename?</code></dt>
    33     46    <dd>Save page to given <code>filename</code>, if file name omitted, present file selection.</dd><br>
    34     47    <dt><code><b>tsb::canvas</b> ?-width w -height h?</code></dt>
................................................................................
    41     54    <dd>Re-evaluates field with number <code>id</code>.</dd><br>
    42     55    <dt><code><b>tsb::print</b></code></dt>
    43     56    <dd>Opens the print dialog to print the page.</dd>
    44     57   </dl>} 12 {h4 "Input Fields"} 13 {#HTML
    45     58   <p>Input fields have a label of the form <code>in(&lt;number&gt;)</code> where the
    46     59   number is the index in the history array. Arbitraty text can be entered which
    47     60   however should be valid Tcl code, except the very first line is <code>#HTML</code>
    48         -in which case the following lines should be valid HTML text. The input field
    49         -is evaluated when <code>&lt;Shift&gt;-&lt;Return&gt;</code> is pressed.</p>
           61  +or <code>#MARKDOWN</code>, in which case the following lines should be valid HTML
           62  +or Markdown text, respectively. The input field is evaluated when
           63  +<code>&lt;Shift&gt;-&lt;Return&gt;</code> is pressed.</p>
           64  +
    50     65   <p>Depending on the command evaluation the input field is sometimes hidden.
    51     66   A double click on the corresponding output field(s) makes the input field visible
    52     67   and thus editable, again.</p>} 14 {h4 "Output Fields"} 15 {#HTML
    53     68   <p>Each input field has two corresponding output fields which are visible/non-empty
    54     69   depending on context. One output field receives preformatted text, either the result
    55     70   or the error message of a command evaluation. The other output field receives HTML,
    56     71   e.g. for displaying an image or for the <code>#HTML</code> form from the input field.</p>} 16 {tsb::save cheatsheet.tsb}

Changes to undroid/tsb/tsb.tcl.

     1         -# Load webview.
            1  +# Load webview and other stuff.
     2      2   
     3      3   package require twv
            4  +package require Markdown
     4      5   
     5      6   # On MacOSX we need Tk early, otherwise crashes occur.
     6      7   
     7      8   if {$tcl_platform(os) eq "Darwin"} {
     8      9       package require Tk
     9     10   }
    10     11   
................................................................................
    54     55   	set n [string first "\n" $str]
    55     56   	if {$n > 4} {
    56     57   	    incr n
    57     58   	    set str [string range $str $n end]
    58     59   	}
    59     60   	$::W call Wraw $id $str 1
    60     61   	$::W call Inhide $id 1
           62  +	set newfield 1
           63  +    } elseif {[string first "#MARKDOWN" $str] == 0} {
           64  +	set n [string first "\n" $str]
           65  +	if {$n > 8} {
           66  +	    incr n
           67  +	    set str [string range $str $n end]
           68  +	}
           69  +	set str [Markdown::convert $str]
           70  +	$::W call Wraw $id $str 1
           71  +	$::W call Inhide $id 1
    61     72   	set newfield 1
    62     73       } elseif {[catch {uplevel \#0 $str} ret opts]} {
    63     74   	if {[dict get $opts -code] == 4} {
    64     75   	    # continue
    65     76   	    $::W call Wclear $id
    66     77   	} else {
    67     78   	    $::W call Werror $id $::errorInfo