PreviousUpNext

15.4.1428  src/lib/x-kit/widget/edit/texteditor.pkg

## texteditor.pkg
#
# Create the imp network constituting our emacs-flavored
# text editing infrastructure.
#
# See also:
#     src/lib/x-kit/widget/edit/textmill.pkg
#     src/lib/x-kit/widget/edit/textpane.pkg
#     src/lib/x-kit/widget/edit/screenline.pkg

# Compiled by:
#     src/lib/x-kit/widget/xkit-widget.sublib





# This package gets used in:
#
#     

stipulate
    include package   threadkit;                                                # threadkit                     is from   src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg
    include package   geometry2d;                                               # geometry2d                    is from   src/lib/std/2d/geometry2d.pkg
    #
    package chr =  char;                                                        # char                          is from   src/lib/std/char.pkg
    package evt =  gui_event_types;                                             # gui_event_types               is from   src/lib/x-kit/widget/gui/gui-event-types.pkg
    package g2p =  gadget_to_pixmap;                                            # gadget_to_pixmap              is from   src/lib/x-kit/widget/theme/gadget-to-pixmap.pkg
    package gd  =  gui_displaylist;                                             # gui_displaylist               is from   src/lib/x-kit/widget/theme/gui-displaylist.pkg
    package gt  =  guiboss_types;                                               # guiboss_types                 is from   src/lib/x-kit/widget/gui/guiboss-types.pkg
    package wt  =  widget_theme;                                                # widget_theme                  is from   src/lib/x-kit/widget/theme/widget/widget-theme.pkg
    package wti =  widget_theme_imp;                                            # widget_theme_imp              is from   src/lib/x-kit/widget/xkit/theme/widget/default/widget-theme-imp.pkg
    package r8  =  rgb8;                                                        # rgb8                          is from   src/lib/x-kit/xclient/src/color/rgb8.pkg
    package r64 =  rgb;                                                         # rgb                           is from   src/lib/x-kit/xclient/src/color/rgb.pkg
    package wi  =  widget_imp;                                                  # widget_imp                    is from   src/lib/x-kit/widget/xkit/theme/widget/default/look/widget-imp.pkg
    package g2d =  geometry2d;                                                  # geometry2d                    is from   src/lib/std/2d/geometry2d.pkg
    package g2j =  geometry2d_junk;                                             # geometry2d_junk               is from   src/lib/std/2d/geometry2d-junk.pkg
    package mt  =  millboss_types;                                              # millboss_types                is from   src/lib/x-kit/widget/edit/millboss-types.pkg
    package mtx =  rw_matrix;                                                   # rw_matrix                     is from   src/lib/std/src/rw-matrix.pkg
    package pp  =  standard_prettyprinter;                                      # standard_prettyprinter        is from   src/lib/prettyprint/big/src/standard-prettyprinter.pkg
    package gtg =  guiboss_to_guishim;                                          # guiboss_to_guishim            is from   src/lib/x-kit/widget/theme/guiboss-to-guishim.pkg
#   package sl  =  screenline;                                                  # screenline                    is from   src/lib/x-kit/widget/edit/screenline.pkg
    package tp  =  textpane;                                                    # textpane                      is from   src/lib/x-kit/widget/edit/textpane.pkg
    package frm =  frame;                                                       # frame                         is from   src/lib/x-kit/widget/leaf/frame.pkg
    package p2l =  textpane_to_screenline;                                      # textpane_to_screenline        is from   src/lib/x-kit/widget/edit/textpane-to-screenline.pkg
    #
    package em  =  eval_mode;                                                   # eval_mode                     is from   src/lib/x-kit/widget/edit/eval-mode.pkg
    package mm  =  minimill_mode;                                               # minimill_mode                 is from   src/lib/x-kit/widget/edit/minimill-mode.pkg
    package fm  =  fundamental_mode;                                            # fundamental_mode              is from   src/lib/x-kit/widget/edit/fundamental-mode.pkg
    package mtp =  make_textpane;                                               # make_textpane                 is from   src/lib/x-kit/widget/edit/make-textpane.pkg

    nb =  log::note_on_stderr;                                                  # log                           is from   src/lib/std/src/log.pkg

# XXX SUCKO FIXME: Kludge to force compilation during early development:
dummy = em::input_done;

herein

    package texteditor
    :       Texteditor                                                          # Texteditor                    is from   src/lib/x-kit/widget/edit/texteditor.api
    {
        Option  = ID                    Id
                #
                | UTF8                  String                                  # Text to draw inside button.  Default is "".
# TBD           | HTML                  String                                  # Text to draw inside button.  Default is "".
                #
                | FONT_SIZE             Int                                     # Show any text in this pointsize.  Default is 12.
                | FONTS                 List(String)                            # Override theme font:  Font to use for text label, e.g. "-*-courier-bold-r-*-*-20-*-*-*-*-*-*-*".  We'll use the first font in list which is found on X server, else "9x15" (which X guarantees to have).
                #
                | ROMAN                                                         # Show any text in plain  font from widget-theme.  This is the default.
                | ITALIC                                                        # Show any text in italic font from widget-theme.
                | BOLD                                                          # Show any text in bold   font from widget-theme.  NB: Text is either bold or italic, not both.
                ;
                
        fun process_options
            ( options: List(Option),
              #
              { widget_id,
                #
                text,
                #
                fonts,
                font_weight,
                font_size
              }
            )
            =
            {   my_widget_id    =  REF  widget_id;
                #
                my_text         =  REF  text;
                #
                my_fonts        =  REF  fonts;
                my_font_weight  =  REF  font_weight;
                my_font_size    =  REF  font_size;
                #

                apply  do_option  options
                where
                    fun do_option (ID           i) =>   my_widget_id            :=  THE i;
                        #
                        do_option (UTF8         t) =>   my_text                 :=  t;
                        #
                        do_option (FONTS        t) =>   my_fonts                :=  t;
                        #
                        do_option (ROMAN         ) =>   my_font_weight          :=  THE wt::ROMAN_FONT;
                        do_option (ITALIC        ) =>   my_font_weight          :=  THE wt::ITALIC_FONT;
                        do_option (BOLD          ) =>   my_font_weight          :=  THE wt::BOLD_FONT;
                        #
                        do_option (FONT_SIZE    i) =>   my_font_size            :=  THE i;
                        #
                    end;
                end;

                { widget_id     =>  *my_widget_id,
                  #
                  text          =>  *my_text,
                  #
                  fonts         =>  *my_fonts,
                  font_weight   =>  *my_font_weight,
                  font_size     =>  *my_font_size
                };
            };


        fun with  ( buffername:         String,                                                                 # PUBLIC.  The point of the 'with' name is that GUI coders can write 'texteditor::with { this => that, foo => bar, ... }.'
                    options:            List(Option)
                  )     
            =
            {
                (process_options
                  (
                    options,
                    #
                    { widget_id         =>  NULL,
                      # 
                      text              =>  "",
                      #
                      fonts             =>  [],
                      font_weight       =>  (THE wt::BOLD_FONT: Null_Or(wt::Font_Weight)),
                      font_size         =>  (NULL: Null_Or(Int))
                    }
                ) )
                    ->
                    {                                                                                           # 
                      widget_id,
                      # 
                      text,
                      #
                      fonts,
                      font_weight,
                      font_size
                    };
# XXX SUCKO FIXME None of the font* stuff is getting used here, nor the widget_id.

# XXX SUCKO FIXME mode should be an option here, not hardwired.
                panemode     =  fm::fundamental_mode;
                textmill_arg =  { name => buffername, textmill_options => [ mt::UTF8 text ] };
                #
                mtp::make_textpane_and_textmill { textmill_arg, panemode };
            };                                                                                                  # PUBLIC
    };
end;




Comments and suggestions to: bugs@mythryl.org

PreviousUpNext