PreviousUpNext

15.4.1410  src/lib/x-kit/widget/edit/make-textpane.pkg

# make-textpane.pkg
#
# This package manages one view onto a textmill,
# consisting of a number of 
#
#     src/lib/x-kit/widget/edit/screenline.pkg
#
# instances displaying (part of) the contents of
# the textmill, plus one displaying the dirtyflag,
# filename etc associated with the textmill.
#
# In "Model/View/Controller" terms, textmill.pkg
# is the Model and textpane.pkg is the View+Controller.
#
# (textpane.pkg also draws the visible frame around
# the textpane contents, but that is largely incidental
# to its main function.)
#
# Per emacs tradition, we allow multiple textpanes
# to be simultaneously open onto a single textmill;
# this heavily influences the design and implementation.
#
# See also:
#     src/lib/x-kit/widget/edit/millboss-imp.pkg
#     src/lib/x-kit/widget/edit/textmill.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 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 gtj =  guiboss_types_junk;                                          # guiboss_types_junk            is from   src/lib/x-kit/widget/gui/guiboss-types-junk.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 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 txm =  textmill;                                                    # textmill                      is from   src/lib/x-kit/widget/edit/textmill.pkg
    package psx =  posixlib;                                                    # posixlib                      is from   src/lib/std/src/psx/posixlib.pkg

    package frm =  frame;                                                       # frame                         is from   src/lib/x-kit/widget/leaf/frame.pkg

    package nl  =  red_black_numbered_list;                                     # red_black_numbered_list       is from   src/lib/src/red-black-numbered-list.pkg
    package im  =  int_red_black_map;                                           # int_red_black_map             is from   src/lib/src/int-red-black-map.pkg
    package sj  =  string_junk;                                                 # string_junk                   is from   src/lib/std/src/string-junk.pkg
    package sm  =  string_map;                                                  # string_map                    is from   src/lib/src/string-map.pkg

    package l2p =  screenline_to_textpane;                                      # screenline_to_textpane        is from   src/lib/x-kit/widget/edit/screenline-to-textpane.pkg
    package p2l =  textpane_to_screenline;                                      # textpane_to_screenline        is from   src/lib/x-kit/widget/edit/textpane-to-screenline.pkg

    package b2p =  millboss_to_pane;                                            # millboss_to_pane              is from   src/lib/x-kit/widget/edit/millboss-to-pane.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 tph =  textpane_hint;                                               # textpane_hint                 is from   src/lib/x-kit/widget/edit/textpane-hint.pkg
    package mt  =  millboss_types;                                              # millboss_types                is from   src/lib/x-kit/widget/edit/millboss-types.pkg

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

herein

    package make_textpane
    {
        stipulate
            fun make_pane_guiplan'
                  {
                    screenlines_mark:           Id,
                    textpane_id:                Id,
                    textmill_spec:              mt::Textmill_Spec,
                    mainpanemode:               mt::Panemode,
                    minipanemode:               mt::Panemode
                  }
                =
                {   mainpanemode -> mt::PANEMODE  { drawpane_startup_fn,
                                                    drawpane_shutdown_fn,
                                                    drawpane_initialize_gadget_fn,
                                                    drawpane_redraw_request_fn,
                                                    drawpane_mouse_click_fn,
                                                    drawpane_mouse_drag_fn,
                                                    drawpane_mouse_transit_fn,
                                                    ...
                                                  };
                    want_drawpane                                               # We should add a drawpane if mainpainmode shows any sign of using one.
                        =
                        case  ( drawpane_startup_fn,
                                drawpane_shutdown_fn,
                                drawpane_initialize_gadget_fn,
                                drawpane_redraw_request_fn,
                                drawpane_mouse_click_fn,
                                drawpane_mouse_drag_fn,
                                drawpane_mouse_transit_fn
                              )
                            #
                            (NULL, NULL, NULL, NULL, NULL, NULL, NULL)  =>  FALSE;
                            _                                           =>  TRUE;
                        esac;

                    result =    gt::FRAME
                                  ( [ gt::FRAME_WIDGET (textpane::with  { textpane_id,
                                                                          screenlines_mark,
                                                                          textmill_spec,
                                                                          minipanemode,
                                                                          mainpanemode,
                                                                          options       =>  [ ]
                                                                        }
                                                       )
                                    ],
                                    gt::COL
                                      [
                                        gt::MARK'
                                          ( screenlines_mark,
                                            "Screenlines",
                                            gt::COL
                                              [
                                                screenline::with
                                                  {
                                                    paneline  =>  0,
                                                    textpane_id,
                                                    options     =>  [ sl::DOC               "Screenline 1",
                                                                      sl::PIXELS_HIGH_MIN   0,
                                                                      sl::STATE         { cursor_at   =>  p2l::NO_CURSOR,
                                                                                          selected    =>  NULL,
                                                                                          text        =>  "I am a screenline",
                                                                                          prompt      =>  "",
                                                                                          screencol0  =>  0,
                                                                                          background  =>  rgb::white
                                                                                        }
                                                                    ]
                                                  }
                                              ]
                                          ),
                                        gt::FRAME
                                          ( [ gt::FRAME_WIDGET (frame::with [ frm::FRAME_RELIEF wt::RAISED ]) ],
                                            #
                                            screenline::with
                                              {
                                                paneline  =>  -1,
                                                textpane_id,
                                                options =>  [ sl::DOC               "Modeline (Screenline -1)",
                                                              sl::PIXELS_HIGH_MIN   16,
                                                              sl::PIXELS_HIGH_CUT   0.0,
                                                              #
                                                              sl::STATE { cursor_at  =>  p2l::NO_CURSOR,
                                                                          selected   =>  NULL,
                                                                          text       =>  "Modeline (Screenline -1)",
                                                                          prompt     =>  "",
                                                                          screencol0 =>  0,
                                                                          background =>  rgb::white
                                                                        }
                                                            ]
                                              }
                                          )     
                                      ]
                                  );

                    result =    if (not want_drawpane)
                                    #
                                    result;
                                else
#                                   gt::FRAME
#                                     ( [ gt::FRAME_WIDGET (frame::with [ frm::FRAME_RELIEF wt::RAISED ]) ],
#                                       #
                                        gt::COL
                                          [
                                            result,
                                            #
                                            drawpane::with { textpane_id, options => [] }
                                          ];
#                                     );
                                fi;
                    result;
                };
        herein
            fun make_textpane_and_textmill                                                                                              # PUBLIC. Called by with() in src/lib/x-kit/widget/edit/texteditor.pkg
                  {
                    textmill_arg:               mt::Textmill_Arg,
                    panemode:                   mt::Panemode
                  }
                :                               gt::Gp_Widget_Type
                =
                make_pane_guiplan'
                  { screenlines_mark =>  issue_unique_id (),
                    textpane_id      =>  issue_unique_id (),
                    textmill_spec    =>  mt::NEW_TEXTMILL textmill_arg,
                    mainpanemode     =>  panemode,
                    minipanemode     =>  mm::minimill_mode
                  };

            fun make_pane_guiplan                                                                                                       # Synthesize a pane to display textmill's state.  We get invoked by (e.g.)  switch_to_mill  in  src/lib/x-kit/widget/edit/fundamental-mode.pkg
                  {
                    textpane_to_textmill:       mt::Textpane_To_Textmill,                                                               # 
                    filepath:                   Null_Or( String ),                                                                      # make_pane_guiplan should select the pane mode to use based on the filename, but we do not yet do this. XXX SUCKO FIXME.
                    textpane_hint:              Crypt
                  }
                :                               gt::Gp_Widget_Type
                =
                {
                    minipanemode = mm::minimill_mode;
                    mainpanemode
                        =
                        case (tph::decrypt__textpane_hint  textpane_hint)
                            #
                            WORK textpane_hint
                                =>
                                {   textpane_hint
                                      ->
                                      { point:      g2d::Point,                                                                         # (0,0)-origin 'point' (==cursor) screen coordinates, in rows and cols (we assume a fixed-width font).  (Remember to display these as (1,1)-origin when printing them out as numbers!)
                                        mark:       Null_Or(g2d::Point),                                                                # (0,0)-origin 'mark' if set, else NULL.  Same coordinate system as 'point'.
                                        lastmark:   Null_Or(g2d::Point),                                                                # (0,0)-origin last-valid-value-of-mark if set, else NULL.  We use this in exchange_point_and_mark() when 'mark' is not set -- see   src/lib/x-kit/widget/edit/fundamental-mode.pkg
                                        panemode:   mt::Panemode
                                      };

# XXX SUCKO FIXME We should be using 'point', 'mark' and 'lastmark' here too, to initialize new pane to most-reasonable values.
                                    panemode;
                                };
# XXX SUCKO FIXME should get this from textpane_to_textmill.
                            FAIL _ => fm::fundamental_mode;
                        esac;

                    screenlines_mark =  issue_unique_id ();
                    textpane_id      =  issue_unique_id ();

                    textmill_spec    =  mt::OLD_TEXTMILL_BY_PORT textpane_to_textmill;

                    make_pane_guiplan'
                      { screenlines_mark,
                        textpane_id,
                        textmill_spec,
                        mainpanemode,
                        minipanemode
                      };
                };
        end;
                                                                my _ =
        txm::make_pane_guiplan__hack :=  make_pane_guiplan;
    };
end;




Comments and suggestions to: bugs@mythryl.org

PreviousUpNext