summaryrefslogtreecommitdiff
path: root/src/Text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text.c')
-rw-r--r--src/Text.c73
1 files changed, 42 insertions, 31 deletions
diff --git a/src/Text.c b/src/Text.c
index da15a37..521bafe 100644
--- a/src/Text.c
+++ b/src/Text.c
@@ -1124,18 +1124,15 @@ _XawTextGetText(TextWidget ctx, XawTextPosition left, XawTextPosition right)
char *
_XawTextGetSTRING(TextWidget ctx, XawTextPosition left, XawTextPosition right)
{
- unsigned char *s;
- unsigned char c;
- long i, j, n;
- wchar_t *ws, wc;
-
/* allow ESC in accordance with ICCCM */
if (XawTextFormat(ctx, XawFmtWide)) {
MultiSinkObject sink = (MultiSinkObject)ctx->text.sink;
- ws = (wchar_t *)_XawTextGetText(ctx, left, right);
- n = (long)wcslen(ws);
+ wchar_t *ws = (wchar_t *)_XawTextGetText(ctx, left, right);
+ long n = (long)wcslen(ws);
+ long i, j;
+
for (j = 0, i = 0; j < n; j++) {
- wc = ws[j];
+ wchar_t wc = ws[j];
if (XwcTextEscapement (sink->multi_sink.fontset, &wc, 1)
|| (wc == _Xaw_atowc(XawTAB)) || (wc == _Xaw_atowc(XawLF))
|| (wc == _Xaw_atowc(XawESC)))
@@ -1145,12 +1142,13 @@ _XawTextGetSTRING(TextWidget ctx, XawTextPosition left, XawTextPosition right)
return ((char *)ws);
}
else {
- s = (unsigned char *)_XawTextGetText(ctx, left, right);
+ unsigned char *s = (unsigned char *)_XawTextGetText(ctx, left, right);
/* only HT and NL control chars are allowed, strip out others */
- n = (long)strlen((char *)s);
- i = 0;
+ long n = (long)strlen((char *)s);
+ long i = 0, j;
+
for (j = 0; j < n; j++) {
- c = s[j];
+ unsigned char c = s[j];
if (((c >= 0x20) && c <= 0x7f)
||(c >= 0xa0) || (c == XawTAB) || (c == XawLF)
|| (c == XawESC)) {
@@ -1222,14 +1220,15 @@ static Bool
LineAndXYForPosition(TextWidget ctx, XawTextPosition pos,
int *line, int *x, int *y)
{
- XawTextPosition linePos, endPos;
Boolean visible;
- int realW, realH;
*line = 0;
*x = ctx->text.left_margin;
*y = ctx->text.margin.top + 1;
if ((visible = IsPositionVisible(ctx, pos)) != False) {
+ XawTextPosition linePos, endPos;
+ int realW, realH;
+
*line = LineForPosition(ctx, pos);
*y = ctx->text.lt.info[*line].y;
linePos = ctx->text.lt.info[*line].position;
@@ -1252,12 +1251,11 @@ void
_XawTextBuildLineTable(TextWidget ctx, XawTextPosition position,
_XtBoolean force_rebuild)
{
- Dimension height = 0;
int lines = 0;
Cardinal size;
if ((int)XtHeight(ctx) > VMargins(ctx)) {
- height = (Dimension)(XtHeight(ctx) - VMargins(ctx));
+ Dimension height = (Dimension)(XtHeight(ctx) - VMargins(ctx));
lines = XawTextSinkMaxLines(ctx->text.sink, height);
}
size = (Cardinal)(sizeof(XawTextLineTableEntry) * (size_t)(lines + 1));
@@ -1486,9 +1484,11 @@ GetWidestLine(TextWidget ctx)
void
_XawTextSetScrollBars(TextWidget ctx)
{
- float first, last, denom, widest;
+ float first;
if (ctx->text.scroll_vert == XawtextScrollAlways) {
+ float last;
+
if (ctx->text.lastPos == 0)
first = 0.0;
else
@@ -1504,7 +1504,9 @@ _XawTextSetScrollBars(TextWidget ctx)
}
if (ctx->text.scroll_horiz == XawtextScrollAlways) {
- denom = (float)GetWidestLine(ctx);
+ float denom = (float)GetWidestLine(ctx);
+ float widest;
+
if (denom <= 0)
denom = (float)((int)XtWidth(ctx) - RHMargins(ctx));
if (denom <= 0)
@@ -1956,7 +1958,6 @@ TextConvertSelection(Widget w, Atom *selection, Atom *target, Atom *type,
TextWidget ctx = (TextWidget)w;
Widget src = ctx->text.source;
XawTextEditType edit_mode;
- Arg args[1];
XawTextSelectionSalt *salt = NULL;
XawTextSelection *s;
@@ -1966,9 +1967,12 @@ TextConvertSelection(Widget w, Atom *selection, Atom *target, Atom *type,
if (SrcCvtSel(src, selection, target, type, value, length, format))
return (True);
+ else {
+ Arg args[1];
- XtSetArg(args[0], XtNeditType, &edit_mode);
- XtGetValues(src, args, ONE);
+ XtSetArg(args[0], XtNeditType, &edit_mode);
+ XtGetValues(src, args, ONE);
+ }
XmuConvertStandardSelection(w, ctx->text.time, selection,
target, type, (XPointer*)&std_targets,
@@ -2352,10 +2356,10 @@ _SetSelection(TextWidget ctx, XawTextPosition left, XawTextPosition right,
if (left < right) {
Widget w = (Widget)ctx;
- int buffer;
while (count) {
Atom selection = selections[--count];
+ int buffer;
/*
* If this is a cut buffer
@@ -2679,7 +2683,7 @@ OldDisplayText(Widget w, XawTextPosition left, XawTextPosition right)
TextWidget ctx = (TextWidget)w;
int x, y, line;
- XawTextPosition start, end, last, final;
+ XawTextPosition last;
XmuScanline *scan;
XmuSegment *seg;
XmuArea *clip = NULL;
@@ -2697,7 +2701,10 @@ OldDisplayText(Widget w, XawTextPosition left, XawTextPosition right)
if (cleol)
clip = XmuCreateArea();
- for (start = left; start < right && line < ctx->text.lt.lines; line++) {
+ for (XawTextPosition start = left;
+ start < right && line < ctx->text.lt.lines; line++) {
+ XawTextPosition end, final;
+
if ((end = ctx->text.lt.info[line + 1].position) > right)
end = right;
@@ -2756,7 +2763,7 @@ DisplayText(Widget w, XawTextPosition left, XawTextPosition right)
TextWidget ctx = (TextWidget)w;
int y, line;
- XawTextPosition from, to, lastPos;
+ XawTextPosition lastPos;
Bool cleol = ctx->text.clear_to_eol;
Bool has_selection = ctx->text.s.right > ctx->text.s.left;
XawTextPaintList *paint_list;
@@ -2773,8 +2780,11 @@ DisplayText(Widget w, XawTextPosition left, XawTextPosition right)
paint_list = ((TextSinkObject)ctx->text.sink)->text_sink.paint;
- for (from = left; from < right && line < ctx->text.lt.lines; line++) {
- if ((to = ctx->text.lt.info[line + 1].position) > right)
+ for (XawTextPosition from = left;
+ from < right && line < ctx->text.lt.lines; line++) {
+ XawTextPosition to = ctx->text.lt.info[line + 1].position;
+
+ if (to > right)
to = right;
if (to > lastPos)
@@ -2834,7 +2844,7 @@ static void
DoSelection(TextWidget ctx, XawTextPosition pos, Time time, Bool motion)
{
XawTextPosition newLeft, newRight;
- XawTextSelectType newType, *sarray;
+ XawTextSelectType newType;
Widget src = ctx->text.source;
if (motion)
@@ -2842,7 +2852,8 @@ DoSelection(TextWidget ctx, XawTextPosition pos, Time time, Bool motion)
else {
if ((labs((long) time - (long) ctx->text.lasttime) < MULTI_CLICK_TIME)
&& (pos >= ctx->text.s.left && pos <= ctx->text.s.right)) {
- sarray = ctx->text.sarray;
+ XawTextSelectType *sarray = ctx->text.sarray;
+
for (; *sarray != XawselectNull && *sarray != ctx->text.s.type;
sarray++)
;
@@ -3348,11 +3359,11 @@ CountLines(TextWidget ctx, XawTextPosition left, XawTextPosition right)
if (ctx->text.wrap == XawtextWrapNever || left >= right)
return (1);
else {
- XawTextPosition tmp;
int dim, lines = 0, wwidth = GetMaxTextWidth(ctx);
while (left < right) {
- tmp = left;
+ XawTextPosition tmp = left;
+
XawTextSinkFindPosition(ctx->text.sink, left,
ctx->text.left_margin,
wwidth, ctx->text.wrap == XawtextWrapWord,