PreviousUpNext

15.4.1409  src/lib/x-kit/widget/edit/keystroke-macro-junk.pkg

## keystroke-macro-junk.pkg
#
# Support fns for
#     kmacro_start_macro
#     kmacro_end_macro
#     kmacro_end_and_call_macro
# fns in
#     src/lib/x-kit/widget/edit/fundamental-mode.pkg
#
# See also:
#     src/lib/x-kit/widget/edit/textpane.pkg
#     src/lib/x-kit/widget/edit/millboss-imp.pkg
#     src/lib/x-kit/widget/edit/textmill.pkg
#     src/lib/x-kit/widget/edit/textmill-crypts.pkg
#     src/lib/x-kit/widget/edit/textpane-hint.pkg

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


stipulate
    include package   threadkit;                                # threadkit                     is from   src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg
    #
#   package ap  =  client_to_atom;                              # client_to_atom                is from   src/lib/x-kit/xclient/src/iccc/client-to-atom.pkg
#   package au  =  authentication;                              # authentication                is from   src/lib/x-kit/xclient/src/stuff/authentication.pkg
#   package cpm =  cs_pixmap;                                   # cs_pixmap                     is from   src/lib/x-kit/xclient/src/window/cs-pixmap.pkg
#   package cpt =  cs_pixmat;                                   # cs_pixmat                     is from   src/lib/x-kit/xclient/src/window/cs-pixmat.pkg
#   package dy  =  display;                                     # display                       is from   src/lib/x-kit/xclient/src/wire/display.pkg
#   package fil =  file__premicrothread;                        # file__premicrothread          is from   src/lib/std/src/posix/file--premicrothread.pkg
#   package fti =  font_index;                                  # font_index                    is from   src/lib/x-kit/xclient/src/window/font-index.pkg
#   package r2k =  xevent_router_to_keymap;                     # xevent_router_to_keymap       is from   src/lib/x-kit/xclient/src/window/xevent-router-to-keymap.pkg
#   package mtx =  rw_matrix;                                   # rw_matrix                     is from   src/lib/std/src/rw-matrix.pkg
#   package rop =  ro_pixmap;                                   # ro_pixmap                     is from   src/lib/x-kit/xclient/src/window/ro-pixmap.pkg
#   package rw  =  root_window;                                 # root_window                   is from   src/lib/x-kit/widget/lib/root-window.pkg
#   package rwv =  rw_vector;                                   # rw_vector                     is from   src/lib/std/src/rw-vector.pkg
#   package sep =  client_to_selection;                         # client_to_selection           is from   src/lib/x-kit/xclient/src/window/client-to-selection.pkg
#   package shp =  shade;                                       # shade                         is from   src/lib/x-kit/widget/lib/shade.pkg
#   package sj  =  socket_junk;                                 # socket_junk                   is from   src/lib/internet/socket-junk.pkg
#   package x2s =  xclient_to_sequencer;                        # xclient_to_sequencer          is from   src/lib/x-kit/xclient/src/wire/xclient-to-sequencer.pkg
#   package tr  =  logger;                                      # logger                        is from   src/lib/src/lib/thread-kit/src/lib/logger.pkg
#   package tsr =  thread_scheduler_is_running;                 # thread_scheduler_is_running   is from   src/lib/src/lib/thread-kit/src/core-thread-kit/thread-scheduler-is-running.pkg
#   package u1  =  one_byte_unt;                                # one_byte_unt                  is from   src/lib/std/one-byte-unt.pkg
#   package v1u =  vector_of_one_byte_unts;                     # vector_of_one_byte_unts       is from   src/lib/std/src/vector-of-one-byte-unts.pkg
#   package v2w =  value_to_wire;                               # value_to_wire                 is from   src/lib/x-kit/xclient/src/wire/value-to-wire.pkg
#   package wg  =  widget;                                      # widget                        is from   src/lib/x-kit/widget/old/basic/widget.pkg
#   package wi  =  window;                                      # window                        is from   src/lib/x-kit/xclient/src/window/window.pkg
#   package wme =  window_map_event_sink;                       # window_map_event_sink         is from   src/lib/x-kit/xclient/src/window/window-map-event-sink.pkg
#   package wpp =  client_to_window_watcher;                    # client_to_window_watcher      is from   src/lib/x-kit/xclient/src/window/client-to-window-watcher.pkg
#   package wy  =  widget_style;                                # widget_style                  is from   src/lib/x-kit/widget/lib/widget-style.pkg
#   package xc  =  xclient;                                     # xclient                       is from   src/lib/x-kit/xclient/xclient.pkg
#   package xj  =  xsession_junk;                               # xsession_junk                 is from   src/lib/x-kit/xclient/src/window/xsession-junk.pkg
#   package xtr =  xlogger;                                     # xlogger                       is from   src/lib/x-kit/xclient/src/stuff/xlogger.pkg
    #

    #
    package evt =  gui_event_types;                             # gui_event_types               is from   src/lib/x-kit/widget/gui/gui-event-types.pkg
    package gts =  gui_event_to_string;                         # gui_event_to_string           is from   src/lib/x-kit/widget/gui/gui-event-to-string.pkg
    package gt  =  guiboss_types;                               # guiboss_types                 is from   src/lib/x-kit/widget/gui/guiboss-types.pkg
    package mt  =  millboss_types;                              # millboss_types                is from   src/lib/x-kit/widget/edit/millboss-types.pkg

    package a2r =  windowsystem_to_xevent_router;               # windowsystem_to_xevent_router is from   src/lib/x-kit/xclient/src/window/windowsystem-to-xevent-router.pkg

    package gd  =  gui_displaylist;                             # gui_displaylist               is from   src/lib/x-kit/widget/theme/gui-displaylist.pkg

    package pp  =  standard_prettyprinter;                      # standard_prettyprinter        is from   src/lib/prettyprint/big/src/standard-prettyprinter.pkg

    package err =  compiler::error_message;                     # compiler                      is from   src/lib/core/compiler/compiler.pkg
                                                                # error_message                 is from   src/lib/compiler/front/basics/errormsg/error-message.pkg

    package bt  =  gui_to_sprite_theme;                         # gui_to_sprite_theme           is from   src/lib/x-kit/widget/theme/sprite/gui-to-sprite-theme.pkg
    package ct  =  gui_to_object_theme;                         # gui_to_object_theme           is from   src/lib/x-kit/widget/theme/object/gui-to-object-theme.pkg
    package wt  =  widget_theme;                                # widget_theme                  is from   src/lib/x-kit/widget/theme/widget/widget-theme.pkg


    package boi =  spritespace_imp;                             # spritespace_imp               is from   src/lib/x-kit/widget/space/sprite/spritespace-imp.pkg
    package cai =  objectspace_imp;                             # objectspace_imp               is from   src/lib/x-kit/widget/space/object/objectspace-imp.pkg
    package pai =  widgetspace_imp;                             # widgetspace_imp               is from   src/lib/x-kit/widget/space/widget/widgetspace-imp.pkg

    #    
    package gtg =  guiboss_to_guishim;                          # guiboss_to_guishim            is from   src/lib/x-kit/widget/theme/guiboss-to-guishim.pkg

    package b2s =  spritespace_to_sprite;                       # spritespace_to_sprite         is from   src/lib/x-kit/widget/space/sprite/spritespace-to-sprite.pkg
    package c2o =  objectspace_to_object;                       # objectspace_to_object         is from   src/lib/x-kit/widget/space/object/objectspace-to-object.pkg

    package s2b =  sprite_to_spritespace;                       # sprite_to_spritespace         is from   src/lib/x-kit/widget/space/sprite/sprite-to-spritespace.pkg
    package o2c =  object_to_objectspace;                       # object_to_objectspace         is from   src/lib/x-kit/widget/space/object/object-to-objectspace.pkg

    package g2p =  gadget_to_pixmap;                            # gadget_to_pixmap              is from   src/lib/x-kit/widget/theme/gadget-to-pixmap.pkg

    package im  =  int_red_black_map;                           # int_red_black_map             is from   src/lib/src/int-red-black-map.pkg
#   package is  =  int_red_black_set;                           # int_red_black_set             is from   src/lib/src/int-red-black-set.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 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 e2g =  millboss_to_guiboss;                         # millboss_to_guiboss           is from   src/lib/x-kit/widget/edit/millboss-to-guiboss.pkg

#   package que =  queue;                                       # queue                         is from   src/lib/src/queue.pkg
    package nl  =  red_black_numbered_list;                     # red_black_numbered_list       is from   src/lib/src/red-black-numbered-list.pkg

    tracefile   =  "widget-unit-test.trace.log";

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

herein

    package keystroke_macro_junk                                # 
    {
        Global_Keystroke_Macro_State
          =
          { default_macro:              Null_Or( List( gt::Keystroke_Info ) ),          # The macro defined by   C-x ( ... C-x )  and invoked by   C-x e
            definition_in_progress:     Null_Or( List( gt::Keystroke_Info ) ),          #
            execution_in_progress:      Null_Or( List( gt::Keystroke_Info ) )           #
          };                                                                            # NB: Emacs supports named keystroke macros these days, possibly we should too.


        exception  GLOBAL_KEYSTROKE_MACRO_STATE  Global_Keystroke_Macro_State;          # We'll never 'raise' this exception, it is just for Crypt use.
        #
        #
        fun decrypt__global_keystroke_macro_state  (crypt:  Crypt):  Fail_Or( Global_Keystroke_Macro_State )
            =
            case crypt.data
                #
                GLOBAL_KEYSTROKE_MACRO_STATE
                global_keystroke_macro_state
                    =>
                    WORK global_keystroke_macro_state;

                _   =>  FAIL (sprintf "decrypt__global_keystroke_macro_state:  Unknown Crypt value, type='%s' info='%s'  --keystroke-macro-types.pkg"
                                        crypt.type
                                        crypt.info
                             );
            esac;       


        global_key = "keystroke_macro_junk::Global_Keystroke_Macro_State";

        fun encrypt__global_keystroke_macro_state  (global_keystroke_macro_state:  Global_Keystroke_Macro_State):  Crypt
            =
            { id   =>  issue_unique_id (),
              type =>  global_key,
              info =>  "Wrapped by keystroke_macro_junk::encrypt__global_keystroke_macro_state.",
              data =>  GLOBAL_KEYSTROKE_MACRO_STATE  global_keystroke_macro_state
            };           


        fun update__global_keystroke_macro_state
              (
                gadget_to_guiboss:              gt::Gadget_To_Guiboss,
                global_keystroke_macro_state:   Global_Keystroke_Macro_State
              )
            =
            gadget_to_guiboss.note_global
              (
                encrypt__global_keystroke_macro_state  global_keystroke_macro_state
              );

        fun initialize__global_keystroke_macro_state
              (
                gadget_to_guiboss:              gt::Gadget_To_Guiboss
              )
            =
            {   global_keystroke_macro_state
                  =
                  { default_macro           =>  NULL,
                    definition_in_progress  =>  NULL,
                    execution_in_progress   =>  NULL
                  };

                update__global_keystroke_macro_state
                  (
                    gadget_to_guiboss,
                    global_keystroke_macro_state
                  );

                global_keystroke_macro_state;
            };

        fun get_or_make__global_keystroke_macro_state
              (
                gadget_to_guiboss:      gt::Gadget_To_Guiboss
              )
            =
            case (gadget_to_guiboss.find_global  global_key)
                #
                THE crypt =>    case (decrypt__global_keystroke_macro_state crypt)
                                    #
                                    WORK global_keystroke_macro_state =>    global_keystroke_macro_state;
                                    FAIL _                            =>    initialize__global_keystroke_macro_state  gadget_to_guiboss;
                                esac;

                NULL      =>    initialize__global_keystroke_macro_state  gadget_to_guiboss;
            esac;
    };

end;





Comments and suggestions to: bugs@mythryl.org

PreviousUpNext