/*
* tkTextMark.c --
*
* This file contains the procedure that implement marks for
* text widgets.
*
* Copyright (c) 1994 The Regents of the University of California.
* Copyright (c) 1994-1995 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* SCCS: @(#) tkTextMark.c 1.15 96/02/15 18:52:59
*/
#include "tkInt.h"
#include "tkText.h"
/*
* Macro that determines the size of a mark segment:
*/
+ sizeof(TkTextMark)))
/*
* Forward references for procedures defined in this file:
*/
TkTextLine *linePtr));
TkTextLine *linePtr));
/*
* The following structures declare the "mark" segment types.
* There are actually two types for marks, one with left gravity
* and one with right gravity. They are identical except for
* their gravity property.
*/
"mark", /* name */
0, /* leftGravity */
MarkDeleteProc, /* deleteProc */
MarkCleanupProc, /* cleanupProc */
MarkLayoutProc, /* layoutProc */
MarkCheckProc /* checkProc */
};
"mark", /* name */
1, /* leftGravity */
MarkDeleteProc, /* deleteProc */
MarkCleanupProc, /* cleanupProc */
MarkLayoutProc, /* layoutProc */
MarkCheckProc /* checkProc */
};
/*
*--------------------------------------------------------------
*
* TkTextMarkCmd --
*
* This procedure is invoked to process the "mark" options of
* the widget command for text widgets. See the user documentation
* for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*--------------------------------------------------------------
*/
int
int argc; /* Number of arguments. */
char **argv; /* Argument strings. Someone else has already
* parsed this command enough to know that
* argv[1] is "mark". */
{
int c, i;
if (argc < 3) {
return TCL_ERROR;
}
c = argv[2][0];
if (argc > 5) {
argv[0], " mark gravity markName ?gravity?",
(char *) NULL);
return TCL_ERROR;
}
return TCL_ERROR;
}
if (argc == 4) {
} else {
}
return TCL_OK;
}
c = argv[4][0];
} else {
return TCL_ERROR;
}
if (argc != 3) {
return TCL_ERROR;
}
}
if (argc != 4) {
return TCL_ERROR;
}
if (argc != 4) {
return TCL_ERROR;
}
if (argc != 5) {
return TCL_ERROR;
}
return TCL_ERROR;
}
for (i = 3; i < argc; i++) {
continue;
}
}
}
} else {
"\": must be gravity, names, next, previous, set, or unset",
(char *) NULL);
return TCL_ERROR;
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* TkTextSetMark --
*
* Set a mark to a particular position, creating a new mark if
* one doesn't already exist.
*
* Results:
* The return value is a pointer to the mark that was just set.
*
* Side effects:
* A new mark is created, or an existing mark is moved.
*
*----------------------------------------------------------------------
*/
char *name; /* Name of mark to set. */
{
int new;
if (!new) {
/*
* If this is the insertion point that's being moved, be sure
* to force a display update at the old position. Also, don't
* let the insertion cursor be after the final newline of the
* file.
*/
indexPtr = &insertIndex;
}
}
} else {
}
/*
* If the mark is the insertion cursor, then update the screen at the
* mark's new location.
*/
}
return markPtr;
}
/*
*--------------------------------------------------------------
*
* TkTextMarkSegToIndex --
*
* Given a segment that is a mark, create an index that
* refers to the next text character (or other text segment
* with non-zero size) after the mark.
*
* Results:
* *IndexPtr is filled in with index information.
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
void
{
}
}
/*
*--------------------------------------------------------------
*
* TkTextMarkNameToIndex --
*
* Given the name of a mark, return an index corresponding
* to the mark name.
*
* Results:
* The return value is TCL_OK if "name" exists as a mark in
* the text widget. In this case *indexPtr is filled in with
* the next segment whose after the mark whose size is
* non-zero. TCL_ERROR is returned if the mark doesn't exist
* in the text widget.
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
int
char *name; /* Name of mark. */
{
return TCL_ERROR;
}
indexPtr);
return TCL_OK;
}
/*
*--------------------------------------------------------------
*
* MarkDeleteProc --
*
* This procedure is invoked by the text B-tree code whenever
* a mark lies in a range of characters being deleted.
*
* Results:
* Returns 1 to indicate that deletion has been rejected.
*
* Side effects:
* None (even if the whole tree is being deleted we don't
* free up the mark; it will be done elsewhere).
*
*--------------------------------------------------------------
*/
/* ARGSUSED */
static int
int treeGone; /* Non-zero means the entire tree is
* being deleted, so everything must
* get cleaned up. */
{
return 1;
}
/*
*--------------------------------------------------------------
*
* MarkCleanupProc --
*
* This procedure is invoked by the B-tree code whenever a
* mark segment is moved from one line to another.
*
* Results:
* None.
*
* Side effects:
* The linePtr field of the segment gets updated.
*
*--------------------------------------------------------------
*/
static TkTextSegment *
{
return markPtr;
}
/*
*--------------------------------------------------------------
*
* MarkLayoutProc --
*
* This procedure is the "layoutProc" for mark segments.
*
* Results:
* If the mark isn't the insertion cursor then the return
* value is -1 to indicate that this segment shouldn't be
* displayed. If the mark is the insertion character then
* 1 is returned and the chunkPtr structure is filled in.
*
* Side effects:
* None, except for filling in chunkPtr.
*
*--------------------------------------------------------------
*/
/*ARGSUSED*/
static int
int offset; /* Offset within segPtr corresponding to
* indexPtr (always 0). */
int maxX; /* Chunk must not occupy pixels at this
* position or higher. */
int maxChars; /* Chunk must not include more than this
* many characters. */
int noCharsYet; /* Non-zero means no characters have been
* assigned to this line yet. */
register TkTextDispChunk *chunkPtr;
/* Structure to fill in with information
* about this chunk. The x field has already
* been set by the caller. */
{
return -1;
}
chunkPtr->minDescent = 0;
/*
* Note: can't break a line after the insertion cursor: this
* prevents the insertion cursor from being stranded at the end
* of a line.
*/
return 1;
}
/*
*--------------------------------------------------------------
*
* TkTextInsertDisplayProc --
*
* This procedure is called to display the insertion
* cursor.
*
* Results:
* None.
*
* Side effects:
* Graphics are drawn.
*
*--------------------------------------------------------------
*/
/* ARGSUSED */
void
int x; /* X-position in dst at which to
* draw this chunk (may differ from
* the x-position in the chunk because
* of scrolling). */
int y; /* Y-position at which to draw this
* chunk in dst (x-position is in
* the chunk itself). */
int height; /* Total height of line. */
int baseline; /* Offset of baseline from y. */
* chunk. */
int screenY; /* Y-coordinate in text window that
* corresponds to y. */
{
if ((x + halfWidth) <= 0) {
/*
* The insertion cursor is off-screen. Just return.
*/
return;
}
/*
* As a special hack to keep the cursor visible on mono displays
* (or anywhere else that the selection and insertion cursors
* have the same color) write the default background in the cursor
* area (instead of nothing) when the cursor isn't on. Otherwise
* the selection might hide the cursor.
*/
height, 0, TK_RELIEF_FLAT);
}
}
/*
*--------------------------------------------------------------
*
* InsertUndisplayProc --
*
* This procedure is called when the insertion cursor is no
* longer at a visible point on the display. It does nothing
* right now.
*
* Results:
* None.
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
/* ARGSUSED */
static void
* widget. */
{
return;
}
/*
*--------------------------------------------------------------
*
* MarkCheckProc --
*
* This procedure is invoked by the B-tree code to perform
* consistency checks on mark segments.
*
* Results:
* None.
*
* Side effects:
* The procedure panics if it detects anything wrong with
* the mark.
*
*--------------------------------------------------------------
*/
static void
{
panic("MarkCheckProc: markPtr->body.mark.linePtr bogus");
}
/*
* Make sure that the mark is still present in the text's mark
* hash table.
*/
panic("MarkCheckProc couldn't find hash table entry for mark");
}
}
}
/*
*--------------------------------------------------------------
*
* MarkFindNext --
*
* This procedure searches forward for the next mark.
*
* Results:
* A standard Tcl result, which is a mark name or an empty string.
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
static int
char *string; /* The starting index or mark name */
{
int offset;
/*
* If given a mark name, return the next mark in the list of
* segments, even if it happens to be at the same character position.
*/
} else {
/*
* For non-mark name indices we want to return any marks that
* are right at the index.
*/
return TCL_ERROR;
}
/* Empty loop body */ ;
}
}
while (1) {
/*
* segPtr points at the first possible candidate,
* or NULL if we ran off the end of the line.
*/
return TCL_OK;
}
}
return TCL_OK;
}
}
}
/*
*--------------------------------------------------------------
*
* MarkFindPrev --
*
* This procedure searches backwards for the previous mark.
*
* Results:
* A standard Tcl result, which is a mark name or an empty string.
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
static int
char *string; /* The starting index or mark name */
{
int offset;
/*
* If given a mark name, return the previous mark in the list of
* segments, even if it happens to be at the same character position.
*/
} else {
/*
* For non-mark name indices we do not return any marks that
* are right at the index.
*/
return TCL_ERROR;
}
/* Empty loop body */ ;
}
}
while (1) {
/*
* segPtr points just past the first possible candidate,
* or at the begining of the line.
*/
}
}
return TCL_OK;
}
return TCL_OK;
}
}
}