Patch title: Release 94 bulk changes
Abstract:
File: /pliant/graphic/browser/sample/filemanager.pli
Key:
    Removed line
    Added line
module "/pliant/language/unsafe.pli"
module "/pliant/language/stream.pli"
module "/pliant/graphic/browser/server/context.pli"
module "/pliant/graphic/browser/server/api.pli"
module "/pliant/admin/file.pli"


method context display_file files i
  arg_rw BrowserServerContext context ; arg Array:FileInfo files ; arg Int i
  implicit context
    if files:i:is_directory
      style (text color (color rgb 0 0 255))
        cell
          section "name "+string:i
            para stick cursor
              text files:i:name
      cell
        text "     "
      cell
        void
      cell
        text "     "
      cell
        void
    else
      cell
        section "name "+string:i
          para stick cursor
            text files:i:name
      cell
        text "     "
      cell
        text (string files:i:datetime)
      cell
        text "     "
      cell
        text (string files:i:size)


method context file_manager path
  arg_rw BrowserServerContext context ; arg Str path
  implicit context
    style_copy "" "listing"
    style_set "listing" table padding 0
    style_set "listing" table border_size 0
    if false # not allowed:"supervisor"
      window main
        text "Only the supervisor can browse or edit files." ; eol
      window left
        button "exit" key "alt x"
          url_return
      return
    ovar Array:FileInfo files
    ovar (Dictionary Str Void) selected
    ovar Str action := "enter"
    section "all" dynamic
      window top
        para stick
          text path
        if false # FIXME center
          if false # bold
            text path
          eol
        section "parameters"
          void
      window left
        section "menu" dynamic
          button "enter" key "alt e" # selected action="enter"
            action := "enter"
            section_replay "menu"
            section_overwrite "parameters"
              void
            section_overwrite "help"
              text "Clic on the subdirectory you want to enter."
          eol
          button "exit" key "alt x"
            url_return
          para
            button "new" key "alt n" # selected action="new"
              action := "new"
              section_replay "menu"
              section_overwrite "parameters"
                input "Name: " (ovar Str new_name) focus true
                button "create new file" key "alt f"
                  (var Stream stream) open path+new_name out+safe ; stream close
                  action := "enter"
                  section_replay "all"
                button "create new directory" key "alt d"
                  file_tree_create path+new_name+"/"
                  action := "enter"
                  section_replay "all"
                button "cancel" key "escape"
                  action := "enter"
                  section_overwrite "parameters"
                    void
                  section_overwrite "help"
                    void
                  section_replay "menu"
              section_overwrite "help"
                text "Please type in the name of the new file or directory."
            eol
            button "delete" key "alt d" # selected action="delete"
              action := "delete"
              if selected:size<>0
                section_replay "all"
              section_replay "menu"
              section_overwrite "parameters"
                button "delete now" key "alt n"
                  var Pointer:Void k :> selected first
                  while exists:k
                    file_delete (selected key k)
                    k :> selected next k
                  # each k selected
                  #   file_delete (selected key k)
                  action := "enter"
                  section_replay "all"
                button "cancel" key "escape"
                  action := "enter"
                  section_overwrite "parameters"
                    void
                  section_overwrite "help"
                    void
                  section_replay "menu"
              section_overwrite "help"
                text "Select files and directories you want to delete, then clic on 'delete now'"
      window bottom
        section "help"
          void
      selected := var (Dictionary Str Void) empty_selection
      window main
        hook
          style use "listing"
            table
              files := file_list path extended+directories+relative+sorted
              for (var Int i) 0 files:size-1
                row
                  section "file "+string:i
                    display_file files i
        event
          # console "filemanager event " event " key " key " at focus " focus_section " pointer " pointer_section eol
          var Str name
          if event="press" and key="button1" and (pointer_section parse word:"name" (var Int i)) and i>=0 and i<files:size
            focus_set pointer_section pointer_index
            name := files:i name
          eif (event="press" or event="character") and key<>"button1" and (focus_section parse word:"name" (var Int i)) and i>=0 and i<files:size
            name := files:i name
          else
            return
          if event="press" and (key="button1" or key="enter") and action="enter"
            url_call context:url+name
          if (event="press" and key="button1" or event="character" and key=" ") and action="delete"
            if not exists:(selected first path+name)
              selected insert path+name void
              section_overwrite "file "+string:i
                style (cell bg_color (color rgb 255 192 192))
                  display_file files i
            else
              selected remove (selected first path+name)
              section_overwrite "file "+string:i
                display_file files i
            window bottom
              var Int count := selected size
              text string:count+" file"+(shunt count>1 "s" "")+" selected"
          if event="press"
            if key="down" and i+1<files:size
              focus_set "name "+(string i+1) 0
            eif key="up" and i>0
              focus_set "name "+(string i-1) 0
            eif key="escape"
              url_return
          eif event="character"
            part scan
              for (var Int i) 0 files:size-1
                if (files:i:name 0 1)=key
                  focus_set "name "+string:i 0
                  leave scan
      if files:size>0
        focus_set "name 0" 0


export '. file_manager'