Page 1CRiSP File EditorProgrammers GuideVersion 6© 1998 Foxtrot Systems [email protected]@crisp.demon.co.uk
Page 10the usability features of CRiSP but also contain useful real-life examples of various aspects of CRiSPmacro programming.3. Where possibly, try
Page 11crtags [switches] file1 file2 ...You can use Unix style wild cards for the filenames, even on the Windows platforms.The command line switches
Page 12included on the command line. This allows you to generate a list of files and store them ina file rather than being exposed to the command line
Page 13These switches allow you to specify the output file format.-tags Output is compatible with the Unix ctags program and hence the tags database c
Page 14SQL .sqlTeX .texPerl .pl, .pmVerilog .v, .verilogVHD .vhd, .vhdlYacc grammars .yNote that crtags uses a fuzzy-parsingfuzzy parsing mechanism to
Page 15ready for loading into CRiSP. The crunch program uses its own internal preprocessor which is very ANSI-Clike. By doing this gives the user more
Page 16int(pg.21).32-bit signed integer.float(pg.21).64-bit floating point value.string(pg. 21).Variable length string.list(pg.22).Arbitrary collectio
Page 17{button See Also, ALink(crunch,,,)} ScopingAll variables created have a scope of visibility. CRiSP supports a number of scopes of visibility:
Page 18not found, CRiSP then searches the current block level - 1. At this block level, the definitions are found.When a variable is accessed, CRiSP n
Page 19int sum(){ int arg_no = 0; int sum = 0; int arg; while (get_parm(arg_no, sum) > 0) sum
Page 2Introduction 7777Disclaimer 7777Getting started with Macro programming 7777An Overview of the Programming Facilities 8888Writing your own macros
Page 20 Variable argument listsCRiSP supports a variety of mechanisms which allow for variable numbers of arguments to be passed tomacros. As descri
Page 21{d = max(a, b, c);}Note the ampersand after the type specifier for the last parameter in the list. Variables which are passed byreference are n
Page 22string length. string:definitionStorage for strings is dynamically allocated so no space needs to be preallocated for them.Strings may be combi
Page 23The following sections describe various aspects of list management in more detail:List assignment(pg. 23).Making lists(pg. 23).Manipulating lis
Page 24The make_list primitive is similar to quote_list() but each argument is evaluated in turn. For example:list qlst. mlst;qlst = quote_list(1, qls
Page 25PrimitiveDescriptionbookmark_listList of bookmarks (placeholders).command_listList of primitives built into CRiSP.dict_listList of all symbols
Page 26→ Function definitions(pg. 27).→ Expressions(pg. 27).→ Loop constructs(pg. 28).→ Conditional test - if(pg. 29).→ Selection: switch(pg. 29).{but
Page 27list l = { "Item-1", {1, 2, 3}, "Item-2", "hello mum","Item-3", 3.14159, /* Trailing c
Page 28binary | l -> rbinary && l -> rbinary
Page 29The init-expr is evaluated first. Next the while-expr is evaluated, and if it evaluates to TRUE, then statementis executed. After statement is
Page 3List assignment 23Making Lists 23Manipulating List Items 24Sorting Lists 24Searching Lists 24Informational Lists 24The declare datatype 25Struct
Page 30 case 1: case 2: do_something(); break; case 3: case 4: do_som
Page 31messages on <stdout>. This function is only really useful if you are using a GUI version ofCRiSP, since otherwise the printf() output wil
Page 32:/home/fox/bin:/usr/openwin/bin:/usr/openwin/demo:/usr/local/crisp/bin.sun4:/develop/sun4/bin:/develop/scripts:/develop/scripts:/develop/script
Page 33switch is at the end of the command Debug bufferingOutput written to the crisp.log file is normally performed using buffered I/O. Sometimes it
Page 34files which many other editors or standard utilities cannot cope with. Buffer AttributesEach buffer has a number of attributes or modes associa
Page 35these files, CRiSP breaks up binary files into lines containing only 32 characters. To avoid problems if thefile is modified and written away,
Page 36frequently annoying problem with vi(1)). The user can clear the read-only bit for a buffer by calling themake_writable macro (available from th
Page 37All undo information is undoable itself. This is termed redo. Character MapsA character map is a way of viewing data through a window. Characte
Page 38associated with it. When they are displayed in a window the character map associated with the window isused to view the buffer. (Windows always
Page 39timer(pg.45).CriSP supports callbacks based on an elapsed real-time clock.window(pg.33).A window is a character mode window with a view on to a
Page 4Current cursor position 35Modified Flag 35Permissions & Read-only Flag 35Process Buffers 36Region Markers 36Symbol Table 36System Buffers 36
Page 40Autosaving is a feature enabled by default, whereby any modified files (buffers) within the current editingsession are saved at 60 second inter
Page 41KeyDescription<Alt-L> Drops a line marker. When a cut or copy command is issued, whole lines will beaffected in the operation.<Alt-C&g
Page 42Static macros are very useful, as they are in the C language, to hide private macros in a large macro so thatname conflicts do not occur either
Page 43An arbitrary number of macros may be registered for the same event. If more than one macro is registeredfor the same event, then the macros are
Page 44new file.17 (REG_FILE_MOD) This is the modified file trigger. It is called when Crisp detects thatthe corresponding file on disk for a buffer h
Page 45undoing back to the point where the buffer no longer needs saving. You should call theinq_modified() primitive to determine which of the two st
Page 46Note that this timer mechanism is independent of the idle timer mechanism described elsewhere. The idletimer mechanism is specifically designed
Page 4715COL_BG_STRINGSBackground color for string literals.16COL_FG_KEYWORDSForeground color for language keywords.17COL_BG_KEYWORDSBackground color
Page 48<, %, ^ matches the beginning of a line.>, $ matches the end of a line.? matches any single character.* matches zero or more characters[.
Page 49For example, the following expression:cat*dogmatches any line which contains the word cat followed by somewhere else on the line, the word dog.
Page 5GUI Based Objects 55551111Terminology 52Windowing Systems Programming 52Overview of the Dialog box system 53Overview of an Object 54Creating a D
Page 50[A-Za-z]]+ matches the final word in a sentence. The '.' matches the full-stop after it. The expression [ ]@matches zero or more spac
Page 51backward matching.The search macros - search_fwd, search_back, translate, search_string and search_list have a parameter,labelled 're&apos
Page 52functionality because this can help to increase performance whilst keeping the macro interface fairly simple.One of the design goals of the mac
Page 53years, such organisations as Microsoft, IBM, and the OSF have strived to achieve the ultimate userinterface. None of these organisations has pr
Page 54creating a dialog box.1. Firstly, we sketch or conjure up a mental model of what the dialog box is going to look like. E.g. weconsider the user
Page 55it. At various times you need to refer to the individual objects within the dialog box, e.g. so that you canretrieve the current status of the
Page 56 ...object-2 attributes for object-2 ... ...object-n attributes for object-n ...You will notice i
Page 57oriented implementation.DBOX_DIRECTORY An list type object which contains semantics forimplementing a selection from a set of valid files ordir
Page 58DBOX_PANED_WINDOW A container object used to contain two child objects.The real-estate allocated to the children can bechanged by using a slide
Page 59DBOX_TREE A tree-like widget which supports outlining views ofdata. A tree widget is a bit like a DBOX_LISTwidget but you can control the visib
Page 6Case study #2: Fortran colorizer 78Interprocess Communication and CRiSP 77779999IPC Mechanisms 79IPC Primitives 80IPC Callbacks 80TCP/UDP Commun
Page 60 DBOX_CENTERED, DBOX_BUTTON, " Apply ", DBOX_NEXT_COLUMN, TRUE, DBOX_CENTERED,
Page 61When laying out a dialog box, CRiSP tries hard to avoid objects from overlapping, so it is normally safe touse the DBOX_ANCHOR attributes even
Page 62 /* The first object is an input field, */ /* and we have a label to the left of the */ /* input field. */ DBOX_FIE
Page 63as children of a DBOX_TOOL_BAR.For the DBOX_MENU_BAR case, only DBOX_MENU_BUTTON or DBOX_DROP_SITE types arereasonable children. For DBOX_TOOL_
Page 64dialog box.There is a solution to this, and it is called object-grouping. Object-grouping is a mechanism where youcreate a collection of object
Page 65group is very similar to a normal group, but was designed to solve a different problem, and first came to lifewith the implementation of the DB
Page 66every time you click that button, the number is incremented. Where do you store the current value of thelabel? (You can use the label itself, b
Page 67CRiSP takes a Microsoft Windows style approach. CRiSP is an interpreter and the macro language can bestbe considered as a very powerful languag
Page 68This is a piece of CRiSP macro code. The CRiSP macro code looks and feels a lot like C. Withoutnecessarily knowing any of the details of the ma
Page 69definition is needed to tell CRiSP how to perform colorization of keywords for files of a particular type.CRiSP comes with a variety of support
Page 7. IntroductionDocument version: 1.002, date 24 November 1997This guide discusses how to write macros in the CRiSP extension language, known as
Page 70New Clears the dialog in preparation for typing in a new definition. You are prompted to saveany changes before the dialog box is cleared out.S
Page 71colorizers available, based on the filename not the section name. The flags= DirectiveColorization:flags directiveThe flags= entry in a keywor
Page 72spell_textFor most languages, you would not spell check all the types of entities in your files. You wouldnormally restrict spell checking to t
Page 73Defines the characters which can form the 2nd and subsequent characters in a keyword or variablename. This may be different from the char_start
Page 74char_backslash=This class is used to redefined the backslash character. In many languages, backslash character isused to turn off (or escape) t
Page 75→ More than one keyword can be specified on each line; each keyword is enclosed in double quotes.Backslashes are used inside the quotes to esca
Page 76 Keyword Regular ExpressionsColorization:keyword regular expressionsKeyword regular expressions are away of allowing generic styles of strings
Page 77inside the string, or any other non-printable character, you can use a backslash to affect the followingcharacters.In many languages, string co
Page 78operator= "+=" "-=" "*=" "/=" "|=" "&=" "^=" "==" "!=&
Page 79keyword="union"keyword="while" "write" Interprocess Communication and CRiSPInterprocess communication is the mea
Page 8# include <crisp.h>voidmymacro(){message("This is my macro!");}The #include statement is something you will need sooner or later
Page 80support these pipes. Windows/32 named pipes are more like TCP connection which allowtwo tasks on different machines to communicate.PTYs(pg. 84)
Page 81The key to writing non-blocking macros is to write them based on callbacks, using the ipc_register() function.There are four conditions for whi
Page 82Client Side Programming IssuesWhen using TCP to connect to a remote site, there may be some considerable delay in the connection beingaccepted,
Page 83/* We have either successfully or unsuccessfully *//* connected to the remote host. *//* We can tell the difference by whether the ipc_write */
Page 84 Pipe CommunicationsThere are two forms of pipes which can be used: anonymous pipes and named pipes. Both types are verysimilarly - the differ
Page 85zero bytes, then the other end of the pipe has most likely terminated. Alternatively you may use theipc_register() callback to register notific
Page 86Client Side operationTo make a client request, you need to create an IPC channel and specify the name of the service and topicyou wish to conne
Page 87mechanism.SignalsSIGUSR1SIGUSR2register_macroREG_SIGNALasync.crSignal based communicationThe SIGUSR1 and SIGUSR2 IPC mechanism is probably the
Page 88keyboard. When you press a key, CRiSP looks at the current buffer and looks to see if a local keyboard hasbeen defined for this buffer. If so,
Page 89Scan CodesAs described above, CRiSP uses a set of key definitions which allow you to create macros which are notdependent on the keyboard and s
Page 9→Writing your own macros(pg. 9).→The .m language(pg. 90).→The crunch language(pg. 14). Writing your own macrosPrivate macros can be loosely cat
Page 90This populates the current keyboard with all the normal typeable characters (A..Z, a..z, 0..9, etc) sothat they are self-inserting (see self_in
Page 91files are compiled directly into loadable files with a .cm extension).CRiSP can load .m files directly without any need for compilation, but th
Page 92
Comments to this Manuals