*** xxgdb-1.12/defs.h Sat Jan 5 15:00:57 2002 --- xxgdb-1.12-I18N/defs.h Sat Jan 5 15:04:37 2002 *************** *** 205,210 **** --- 205,213 ---- int lastline; /* number of lines in source file */ XawTextPosition topPosition; /* top display position of buffer */ XawTextPosition *linepos; /* array of text pos for each newline */ + #ifdef I18N_MB /* update owa */ + int *wcsLinePos; /* array of wcs text pos for each newline */ + #endif } FileRec, *FileRecPtr; typedef struct { *** xxgdb-1.12/source.c Sat Jan 5 15:00:57 2002 --- xxgdb-1.12-I18N/source.c Sat Jan 5 15:20:05 2002 *************** *** 152,159 **** */ if (*num_params == 1 && strcmp(params[0], "warp") == 0) { ! XawTextSetInsertionPoint(sourceWindow, ! file->linepos[file->topline]); } UpdateLineLabel(file->topline); --- 152,163 ---- */ if (*num_params == 1 && strcmp(params[0], "warp") == 0) { ! #ifdef I18N_MB /* update owa */ ! pos = file->wcsLinePos[file->topline]; ! #else ! pos = file->linepos[file->topline]; ! #endif ! XawTextSetInsertionPoint(sourceWindow, pos); } UpdateLineLabel(file->topline); *************** *** 584,589 **** --- 588,599 ---- { char *p; int line, nlines; + #ifdef I18N_MB /* update owa */ + wchar_t* wcs = (wchar_t *)malloc(sizeof(wchar_t) * (file->filesize + 1)); + wchar_t* p1 = (wchar_t*)0; + wchar_t* p2 = (wchar_t*)0; + int len = 0; + #endif nlines = MAX(1, file->filesize/CHARS_PER_LINE); file->linepos = (XawTextPosition *) *************** *** 605,610 **** --- 615,640 ---- file->lastline = line - 2; file->linepos = (XawTextPosition *) XtRealloc /* shrink to min size */ ((void*)file->linepos, line * sizeof(XawTextPosition)); + #ifdef I18N_MB /* update owa */ + nlines = line; + file->wcsLinePos = (int *)malloc((nlines) * sizeof(int)); + len = mbstowcs(wcs, file->buf, file->filesize + 1); + /*fprintf(stderr, "BuildLinePos mb=%d, wcs=%d\n", file->filesize, len);*/ + line = 0; + file->wcsLinePos[line++] = 0; + file->wcsLinePos[line++] = 0; + p1 = wcs; + p2 = wcschr(p1, '\n'); + len = 0; + while (p2) { + len += p2 - p1 + 1; + /*fprintf(stderr, "BuildLinePos[%2d] wcs=%d\n", line, len);*/ + file->wcsLinePos[line++] = len; + p1 = p2 + 1; + p2 = wcschr(p1, '\n'); + } + free((void *)wcs); + #endif } /* *************** *** 651,656 **** --- 681,689 ---- XtFree((char *)fileTable[i]->buf); XtFree((char *)fileTable[i]->linepos); + #ifdef I18N_MB /* update owa */ + free((char *)fileTable[i]->wcsLinePos); + #endif XtFree((char *)fileTable[i]); fileTable[i] = NULL; } *************** *** 706,711 **** --- 739,747 ---- { XtFree((char *)fileTable[i]->buf); XtFree((char *)fileTable[i]->linepos); + #ifdef I18N_MB /* update owa */ + free((char *)fileTable[i]->wcsLinePos); + #endif XtFree((char *)fileTable[i]); fileTable[i] = NULL; UpdateMessageWindow("WARNING : file %s was modified", pathname); *************** *** 991,997 **** DisplayFile(file); UpdateFileLabel(pathname); XawTextUnsetSelection(sourceWindow); ! XawTextSetInsertionPoint(sourceWindow, file->linepos[file->currentline]); UpdateLineLabel(file->currentline); UpdateStops(file); UpdateArrow(file); --- 1027,1037 ---- DisplayFile(file); UpdateFileLabel(pathname); XawTextUnsetSelection(sourceWindow); ! #ifdef I18N_MB /* update owa */ ! XawTextSetInsertionPoint(sourceWindow, file->wcsLinePos[file->currentline]); ! #else ! XawTextSetInsertionPoint(sourceWindow, file->linepos[file->currentline]); ! #endif UpdateLineLabel(file->currentline); UpdateStops(file); UpdateArrow(file); *** xxgdb-1.12/utils.c Sat Nov 19 03:46:58 1994 --- xxgdb-1.12-I18N/utils.c Sat Jan 5 15:13:37 2002 *************** *** 57,62 **** --- 57,80 ---- int TextPositionToLine(pos) XawTextPosition pos; { + #ifdef I18N_MB /* update owa */ + int line = 0; + if (displayedFile) { + if (pos >= displayedFile->wcsLinePos[displayedFile->topline]) { + for (line = displayedFile->topline; + pos > displayedFile->wcsLinePos[line]; line++) + ; + line = (pos == displayedFile->wcsLinePos[line])? line : line - 1; + } + else { + for (line = 1; pos > displayedFile->wcsLinePos[line]; line++) + ; + line = (pos == displayedFile->wcsLinePos[line])? line : line - 1; + } + } + /*fprintf(stderr, "utils::TextPositionToLine line=%d\n", line);*/ + return line; + #else int line; if (displayedFile) { *************** *** 72,77 **** --- 90,96 ---- } else return 0; + #endif } /* *** xxgdb-1.12/handler.c Tue Aug 30 04:38:27 1994 --- xxgdb-1.12-I18N/handler.c Sat Jan 5 15:17:54 2002 *************** *** 133,146 **** else file->topline = line - nlines; file->bottomline = MIN(file->topline + file->lines - 1, file->lastline); ! TextSetTopPosition(sourceWindow, file->linepos[file->topline]); ! file->topPosition = file->linepos[file->topline]; } XawTextSetInsertionPoint(sourceWindow, file->linepos[line]); /* Text window might have scrolled, check topline & bottomline */ pos = XawTextTopPosition(sourceWindow); for (i=1; pos >= file->linepos[i]; i++); if (file->topline != i-1) { file->topline = i-1; file->bottomline = MIN (file->topline + file->lines - 1, --- 133,158 ---- else file->topline = line - nlines; file->bottomline = MIN(file->topline + file->lines - 1, file->lastline); ! #ifdef I18N_MB /* update owa */ ! TextSetTopPosition(sourceWindow, file->wcsLinePos[file->topline]); ! file->topPosition = file->wcsLinePos[file->topline]; ! } ! XawTextSetInsertionPoint(sourceWindow, file->wcsLinePos[line]); ! ! /* Text window might have scrolled, check topline & bottomline */ ! pos = XawTextTopPosition(sourceWindow); ! for (i = 1; pos >= file->wcsLinePos[i]; i++) ! ; ! #else ! TextSetTopPosition(sourceWindow, file->linepos[file->topline]); ! file->topPosition = file->linepos[file->topline]; } XawTextSetInsertionPoint(sourceWindow, file->linepos[line]); /* Text window might have scrolled, check topline & bottomline */ pos = XawTextTopPosition(sourceWindow); for (i=1; pos >= file->linepos[i]; i++); + #endif if (file->topline != i-1) { file->topline = i-1; file->bottomline = MIN (file->topline + file->lines - 1,