summaryrefslogtreecommitdiffstats
path: root/generic/tkText.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-12-20 10:41:43 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-12-20 10:41:43 (GMT)
commit2f89fa96c29e874b87523d628df15c62984dd9b7 (patch)
tree512c62f76a0e9be490f422d8aa6f866cd1c0c5c3 /generic/tkText.c
parent22f8312f1177e98133c31e059d6f1ae948178f37 (diff)
downloadtk-2f89fa96c29e874b87523d628df15c62984dd9b7.zip
tk-2f89fa96c29e874b87523d628df15c62984dd9b7.tar.gz
tk-2f89fa96c29e874b87523d628df15c62984dd9b7.tar.bz2
Much more WIP: Appears to be working on UNIX, and for a bit part on Windows too.
Diffstat (limited to 'generic/tkText.c')
-rw-r--r--generic/tkText.c93
1 files changed, 50 insertions, 43 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index f810010..0d7dcb1 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -461,7 +461,7 @@ Tk_TextObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -502,7 +502,7 @@ CreateWidget(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register TkText *textPtr;
+ TkText *textPtr;
Tk_OptionTable optionTable;
TkTextIndex startIndex;
Tk_Window newWin;
@@ -523,7 +523,7 @@ CreateWidget(
* and 'insert', 'current' mark pointers are all NULL to start.
*/
- textPtr = ckalloc(sizeof(TkText));
+ textPtr = (TkText *)ckalloc(sizeof(TkText));
memset(textPtr, 0, sizeof(TkText));
textPtr->tkwin = newWin;
@@ -534,7 +534,7 @@ CreateWidget(
textPtr, TextCmdDeletedProc);
if (sharedPtr == NULL) {
- sharedPtr = ckalloc(sizeof(TkSharedText));
+ sharedPtr = (TkSharedText *)ckalloc(sizeof(TkSharedText));
memset(sharedPtr, 0, sizeof(TkSharedText));
sharedPtr->refCount = 0;
@@ -632,7 +632,7 @@ CreateWidget(
*/
textPtr->selTagPtr = TkTextCreateTag(textPtr, "sel", NULL);
- textPtr->selTagPtr->reliefString =
+ textPtr->selTagPtr->reliefString = (char *)
ckalloc(sizeof(DEF_TEXT_SELECT_RELIEF));
strcpy(textPtr->selTagPtr->reliefString, DEF_TEXT_SELECT_RELIEF);
Tk_GetRelief(interp, DEF_TEXT_SELECT_RELIEF, &textPtr->selTagPtr->relief);
@@ -699,7 +699,7 @@ TextWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
int result = TCL_OK;
int index;
@@ -1125,7 +1125,7 @@ TextWidgetObjCmd(
objc -= 2;
objv += 2;
- indices = ckalloc((objc + 1) * sizeof(TkTextIndex));
+ indices = (TkTextIndex *)ckalloc((objc + 1) * sizeof(TkTextIndex));
/*
* First pass verifies that all indices are valid.
@@ -1153,7 +1153,7 @@ TextWidgetObjCmd(
COUNT_INDICES);
objc++;
}
- useIdx = ckalloc(objc);
+ useIdx = (char *)ckalloc(objc);
memset(useIdx, 0, objc);
/*
@@ -1607,7 +1607,7 @@ SharedTextObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register TkSharedText *sharedPtr = clientData;
+ TkSharedText *sharedPtr = (TkSharedText *)clientData;
int result = TCL_OK;
int index;
@@ -1977,7 +1977,7 @@ DestroyText(
for (hPtr = Tcl_FirstHashEntry(&sharedTextPtr->windowTable, &search);
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
TkTextEmbWindowClient *loop;
- TkTextSegment *ewPtr = Tcl_GetHashValue(hPtr);
+ TkTextSegment *ewPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
loop = ewPtr->body.ew.clients;
if (loop->textPtr == textPtr) {
@@ -2009,7 +2009,7 @@ DestroyText(
for (hPtr = Tcl_FirstHashEntry(&sharedTextPtr->tagTable, &search);
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- tagPtr = Tcl_GetHashValue(hPtr);
+ tagPtr = (TkTextTag *)Tcl_GetHashValue(hPtr);
/*
* No need to use 'TkTextDeleteTag' since we've already removed
@@ -2075,7 +2075,7 @@ DestroyText(
static int
ConfigureText(
Tcl_Interp *interp, /* Used for error reporting. */
- register TkText *textPtr, /* Information about widget; may or may not
+ TkText *textPtr, /* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -2378,7 +2378,7 @@ static void
TextWorldChangedCallback(
ClientData instanceData) /* Information about widget. */
{
- TkText *textPtr = instanceData;
+ TkText *textPtr = (TkText *)instanceData;
TextWorldChanged(textPtr, TK_TEXT_LINE_GEOMETRY);
}
@@ -2467,9 +2467,9 @@ TextWorldChanged(
static void
TextEventProc(
ClientData clientData, /* Information about window. */
- register XEvent *eventPtr) /* Information about event. */
+ XEvent *eventPtr) /* Information about event. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
TkTextIndex index, index2;
if (eventPtr->type == Expose) {
@@ -2578,7 +2578,7 @@ static void
TextCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
Tk_Window tkwin = textPtr->tkwin;
/*
@@ -2663,7 +2663,7 @@ InsertChars(
resetViewCount = 0;
if (sharedTextPtr->refCount > PIXEL_CLIENTS) {
- lineAndByteIndex = ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount);
+ lineAndByteIndex = (int *)ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount);
} else {
lineAndByteIndex = pixels;
}
@@ -2961,7 +2961,7 @@ TextUndoRedoCallback(
Tcl_Obj *objPtr) /* Arguments of a command to be handled by the
* shared text data structure. */
{
- TkSharedText *sharedPtr = clientData;
+ TkSharedText *sharedPtr = (TkSharedText *)clientData;
int res, objc;
Tcl_Obj **objv;
TkText *textPtr;
@@ -3200,9 +3200,7 @@ DeleteIndexRange(
for (i=0, hPtr=Tcl_FirstHashEntry(&sharedTextPtr->tagTable, &search);
hPtr != NULL; i++, hPtr = Tcl_NextHashEntry(&search)) {
- TkTextTag *tagPtr = Tcl_GetHashValue(hPtr);
-
- TkBTreeTag(&index1, &index2, tagPtr, 0);
+ TkBTreeTag(&index1, &index2, (TkTextTag *)Tcl_GetHashValue(hPtr), 0);
}
/*
@@ -3236,7 +3234,7 @@ DeleteIndexRange(
resetViewCount = 0;
if (sharedTextPtr->refCount > PIXEL_CLIENTS) {
- lineAndByteIndex = ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount);
+ lineAndByteIndex = (int *)ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount);
} else {
lineAndByteIndex = pixels;
}
@@ -3425,7 +3423,7 @@ TextFetchSelection(
* not including terminating NULL
* character. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
TkTextIndex eof;
int count, chunkSize, offsetInSeg;
TkTextSearch search;
@@ -3556,7 +3554,7 @@ void
TkTextLostSelection(
ClientData clientData) /* Information about text widget. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
if (TkpAlwaysShowSelection(textPtr->tkwin)) {
TkTextIndex start, end;
@@ -3641,7 +3639,7 @@ static void
TextBlinkProc(
ClientData clientData) /* Pointer to record describing text. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
TkTextIndex index;
int x, y, w, h, charWidth;
@@ -4021,7 +4019,7 @@ TextSearchGetLineIndex(
{
const TkTextIndex *indexPtr;
int line;
- TkText *textPtr = searchSpecPtr->clientData;
+ TkText *textPtr = (TkText *)searchSpecPtr->clientData;
indexPtr = TkTextGetIndexFromObj(interp, textPtr, objPtr);
if (indexPtr == NULL) {
@@ -4086,7 +4084,7 @@ TextSearchIndexInLine(
TkTextSegment *segPtr;
TkTextIndex curIndex;
int index, leftToScan;
- TkText *textPtr = searchSpecPtr->clientData;
+ TkText *textPtr = (TkText *)searchSpecPtr->clientData;
index = 0;
curIndex.tree = textPtr->sharedTextPtr->tree;
@@ -4156,7 +4154,7 @@ TextSearchAddNextLine(
TkTextLine *linePtr, *thisLinePtr;
TkTextIndex curIndex;
TkTextSegment *segPtr;
- TkText *textPtr = searchSpecPtr->clientData;
+ TkText *textPtr = (TkText *)searchSpecPtr->clientData;
int nothingYet = 1;
/*
@@ -4278,7 +4276,7 @@ TextSearchFoundMatch(
TkTextIndex curIndex, foundIndex;
TkTextSegment *segPtr;
TkTextLine *linePtr;
- TkText *textPtr = searchSpecPtr->clientData;
+ TkText *textPtr = (TkText *)searchSpecPtr->clientData;
if (lineNum == searchSpecPtr->stopLine) {
/*
@@ -4329,7 +4327,7 @@ TextSearchFoundMatch(
* reached the end of the match or we have reached the end of the line.
*/
- linePtr = clientData;
+ linePtr = (TkTextLine *)clientData;
if (linePtr == NULL) {
linePtr = TkBTreeFindLine(textPtr->sharedTextPtr->tree, textPtr,
lineNum);
@@ -4539,7 +4537,7 @@ TkTextGetTabs(
* Parse the elements of the list one at a time to fill in the array.
*/
- tabArrayPtr = ckalloc(sizeof(TkTextTabArray)
+ tabArrayPtr = (TkTextTabArray *)ckalloc(sizeof(TkTextTabArray)
+ (count - 1) * sizeof(TkTextTab));
tabArrayPtr->numTabs = 0;
prevStop = 0.0;
@@ -4666,7 +4664,7 @@ TkTextGetTabs(
static int
TextDumpCmd(
- register TkText *textPtr, /* Information about text widget. */
+ TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
@@ -4903,7 +4901,7 @@ DumpLine(
*/
int length = last - first;
- char *range = ckalloc(length + 1);
+ char *range = (char *)ckalloc(length + 1);
memcpy(range, segPtr->body.chars + first, length);
range[length] = '\0';
@@ -4934,7 +4932,7 @@ DumpLine(
name = NULL;
lineChanged = 0;
} else {
- name = Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable,
+ name = (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable,
markPtr->hPtr);
}
if (name != NULL) {
@@ -5064,6 +5062,7 @@ DumpSegment(
{
char buffer[TK_POS_CHARS];
Tcl_Obj *values[3], *tuple;
+ (void)what;
TkTextPrintIndex(textPtr, index, buffer);
values[0] = Tcl_NewStringObj(key, -1);
@@ -5604,7 +5603,7 @@ void
TkTextRunAfterSyncCmd(
ClientData clientData) /* Information about text widget. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
int code;
if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) {
@@ -5678,7 +5677,7 @@ SearchPerform(
if (toPtr != NULL) {
const TkTextIndex *indexToPtr, *indexFromPtr;
- TkText *textPtr = searchSpecPtr->clientData;
+ TkText *textPtr = (TkText *)searchSpecPtr->clientData;
indexToPtr = TkTextGetIndexFromObj(interp, textPtr, toPtr);
if (indexToPtr == NULL) {
@@ -6520,7 +6519,7 @@ SearchCore(
* matches on the heap.
*/
- TkSizeT *newArray =
+ TkSizeT *newArray = (TkSizeT *)
ckalloc(4 * matchNum * sizeof(TkSizeT));
memcpy(newArray, storeMatch, matchNum*sizeof(TkSizeT));
memcpy(newArray + 2*matchNum, storeLength,
@@ -6781,13 +6780,15 @@ SearchCore(
static Tcl_Obj *
GetLineStartEnd(
- ClientData clientData,
+ ClientData dummy,
Tk_Window tkwin,
char *recordPtr, /* Pointer to widget record. */
int internalOffset) /* Offset within *recordPtr containing the
* line value. */
{
TkTextLine *linePtr = *(TkTextLine **)(recordPtr + internalOffset);
+ (void)dummy;
+ (void)tkwin;
if (linePtr == NULL) {
return Tcl_NewObj();
@@ -6816,7 +6817,7 @@ GetLineStartEnd(
static int
SetLineStartEnd(
- ClientData clientData,
+ ClientData dummy,
Tcl_Interp *interp, /* Current interp; may be used for errors. */
Tk_Window tkwin, /* Window for which option is being set. */
Tcl_Obj **value, /* Pointer to the pointer to the value object.
@@ -6831,6 +6832,8 @@ SetLineStartEnd(
TkTextLine *linePtr = NULL;
char *internalPtr;
TkText *textPtr = (TkText *) recordPtr;
+ (void)dummy;
+ (void)tkwin;
if (internalOffset >= 0) {
internalPtr = (char *)recordPtr + internalOffset;
@@ -6875,11 +6878,14 @@ SetLineStartEnd(
static void
RestoreLineStartEnd(
- ClientData clientData,
+ ClientData dummy,
Tk_Window tkwin,
char *internalPtr, /* Pointer to storage for value. */
char *oldInternalPtr) /* Pointer to old value. */
{
+ (void)dummy;
+ (void)tkwin;
+
*(TkTextLine **)internalPtr = *(TkTextLine **)oldInternalPtr;
}
@@ -6934,17 +6940,18 @@ ObjectIsEmpty(
int
TkpTesttextCmd(
- ClientData clientData, /* Main window for application. */
+ ClientData dummy, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
TkText *textPtr;
- TkSizeT len;
+ size_t len;
int lineIndex, byteIndex, byteOffset;
TkTextIndex index;
char buf[64];
Tcl_CmdInfo info;
+ (void)dummy;
if (objc < 3) {
return TCL_ERROR;
@@ -6953,7 +6960,7 @@ TkpTesttextCmd(
if (Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &info) == 0) {
return TCL_ERROR;
}
- textPtr = info.objClientData;
+ textPtr = (TkText *)info.objClientData;
len = strlen(Tcl_GetString(objv[2]));
if (strncmp(Tcl_GetString(objv[2]), "byteindex", len) == 0) {
if (objc != 5) {