...
 
Commits (2)
......@@ -276,6 +276,9 @@ void txt1_doreplaceatend(txt t, int ntodelete, char *buffer, int n);
void txt1_domovevertical(txt, int by, int caretstill);
void txt1_domovehorizontal(txt, int by);
#define txt1_MIN(a,b) ((a)<(b)?(a):(b))
#define txt1_MAX(a,b) ((a)<(b)?(b):(a))
/* -------- selection and Marker Operations. -------- */
void txt1_donewmarker(txt, txt1_imarker*);
......
......@@ -263,10 +263,6 @@ void txt1__checkscreeninvariant(txt t, char *msg)
#define txt1__checkscreeninvariant(t,msg) ;
#endif
static int txt1__min(int a, int b) {return(a < b ? a : b);}
static int txt1__max(int a, int b) {return(a > b ? a : b);}
/* -------- checking and debugging. -------- */
#if TRACE
......@@ -981,7 +977,7 @@ static void txt1__dodeletebufferstuff(txt t, int n)
/* updates to the text buffer */
while ((n>0) && txt1__segsize(t, t->gapend, &segsize)) {
delsize = txt1__min(n, segsize);
delsize = txt1_MIN(n, segsize);
oldgapend = t->gapend;
txtundo_putbytes(t->undostate, &(t->buf[t->gapend]), delsize);
txtundo_putnumber(t->undostate, delsize);
......@@ -1046,8 +1042,8 @@ directly, to reduce redraw and flicker. */
t->w->caretoffsety = 0;
spaces = " "; /* 40 of them */
while (nspaces > 0) {
txt1_doreplacechars(t, 0, spaces, txt1__min(40, nspaces));
txt1_domovedot(t, txt1__min(40, nspaces));
txt1_doreplacechars(t, 0, spaces, txt1_MIN(40, nspaces));
txt1_domovedot(t, txt1_MIN(40, nspaces));
nspaces -= 40;
};
} else {
......@@ -1188,7 +1184,7 @@ void txt1_docharsatdot(
at = 0; /* index into a */
todo = *n;
while ((todo>0) && txt1__segsize(t, from, &segsize)) {
copysize = txt1__min(segsize, todo);
copysize = txt1_MIN(segsize, todo);
memmove(/*to*/ a, /*from*/ &(t->buf[from]), copysize);
todo -= copysize;
a += copysize;
......@@ -1350,7 +1346,7 @@ void txt1_domovehorizontal(txt t, int by)
) {
/* he is sticking out at the end of a line. */
tracef0("horiz movement.\n");
t->w->caretoffsetx = txt1__max(0, t->w->caretoffsetx + by*spacewidth);
t->w->caretoffsetx = txt1_MAX(0, t->w->caretoffsetx + by*spacewidth);
by = 0; /* prevent further looping. */
} else {
tracef0("no horiz movement.\n");
......@@ -2409,7 +2405,7 @@ to be so in the current window. Without this the display invariants
will not be maintained. This code is already executed by rawshowcaret
in the case where the caret is visible. */
if (t->w->carety + t->w->caretoffsety <
txt1__min(t->w->linesep, t->w->limy)) {
txt1_MIN(t->w->linesep, t->w->limy)) {
tracef0("auto-shifting, carety<=0.\n");
txt1_domovevertical(
t,
......@@ -3208,7 +3204,7 @@ a move or replace. */
direction in which you're moving. This speeds up repeated scrolling
by reducing the amount of repainting of partial lines. */
if (by < 0) {
if (t->w->firstvisy < txt1__min(t->w->linesep, t->w->limy)) {
if (t->w->firstvisy < txt1_MIN(t->w->linesep, t->w->limy)) {
/* there's a partial line at the top. */
byy -= t->w->firstvisy;
} else if (t->w->firstvis.pos == txt1__firstchbi(t)) {
......@@ -3252,7 +3248,7 @@ a move or replace. */
} else { /* retreat in the array */
caretinbounds =
t->w->carety + t->w->caretoffsety
>= txt1__min(t->w->linesep, t->w->limy);
>= txt1_MIN(t->w->linesep, t->w->limy);
copyfirst = t->w->carety + t->w->caretoffsety < t->w->limy - byy;
if (caretinbounds && (! copyfirst)) {
txt1_domovevertical(t, by, FALSE);
......
......@@ -190,10 +190,6 @@ static int txtar__screenheight(void)
return (1 + bbc_vduvar(bbc_YWindLimit)) << bbc_vduvar(bbc_YEigFactor);
}
static int txtar__max(int a, int b) {return(a > b ? a : b);}
static int txtar__min(int a, int b) {return(a < b ? a : b);}
static void txtar__setmode(txtar__sysdata *s) {
txt t = s->t;
#ifdef BIG_WINDOWS
......@@ -206,7 +202,7 @@ static void txtar__setmode(txtar__sysdata *s) {
s->sysfontheight = wimpt_dy() * bbc_vduvar(bbc_GCharSpaceY);
#ifdef BIG_WINDOWS
if (!s->o.big_windows)
s->o.big_window_size = txtar__min(screenwidth/s->sysfontwidth - 3 /*scrollbar*/, BIG_WINDOW_SIZE_LIMIT);
s->o.big_window_size = txt1_MIN(screenwidth/s->sysfontwidth - 3 /*scrollbar*/, BIG_WINDOW_SIZE_LIMIT);
#endif
}
......@@ -1326,7 +1322,7 @@ improves the display of italic characters. */
(scy < 0 ? 0 : scy));
};
bbc_plot(101,
txtar__max(0,
txt1_MAX(0,
/*
scx +
wimpt_dx() *
......@@ -1356,7 +1352,7 @@ improves the display of italic characters. */
};
#endif
txtar__grmoveto(
txtar__max(0,
txt1_MAX(0,
/*
scx + wimpt_dx() * (1 + (width * xppinch()) / 72000)),
*/
......@@ -1397,7 +1393,7 @@ improves the display of italic characters. */
scy + t->w->linesep - 1);
} else {
txtar__grmoveto(
txtar__max(
txt1_MAX(
0,
s->d->info.box.x0 - s->d->info.scx - 1 +
wimpt_dx() * (s->o.margin + ((thiscall.x + thiscall.width) * txtar__xppinch()) / 72000)),
......@@ -1566,7 +1562,7 @@ static int txtar__setarthurcaret(txt t, BOOL visible)
if (visible) {
/* position the caret on the screen */
if (t->w->carety + t->w->caretoffsety <
txtar__min(t->w->linesep, t->w->limy)) {
txt1_MIN(t->w->linesep, t->w->limy)) {
tracef0("auto-shifting, carety<=0.\n");
txt1_domovevertical(
t,
......@@ -1630,12 +1626,12 @@ allow the caret to disappear. This is the correct behaviour, I think. */
s->d->info.scx);
wimpt_noerr(wimp_get_wind_info(s->d));
/* ensure s->d up to date for forthcoming open. */
s->d->info.scx = txtar__max(0, x - viswidth / 3);
s->d->info.scx = txt1_MAX(0, x - viswidth / 3);
move = TRUE;
} else if (x > s->d->info.scx + viswidth) {
wimpt_noerr(wimp_get_wind_info(s->d));
s->d->info.scx =
txtar__min(s->d->info.ex.x1 - viswidth,
txt1_MIN(s->d->info.ex.x1 - viswidth,
x - (3 * viswidth) / 4);
move = TRUE;
};
......@@ -2319,7 +2315,7 @@ static void txtar__defaultoptions(txtar_options *opt) {
opt->wraptowindow = FALSE;
#ifdef BIG_WINDOWS
opt->big_windows = FALSE;
opt->big_window_size = txtar__min(screenwidth/sysfontwidth - 3 /*scrollbar*/, BIG_WINDOW_SIZE_LIMIT);
opt->big_window_size = txt1_MIN(screenwidth/sysfontwidth - 3 /*scrollbar*/, BIG_WINDOW_SIZE_LIMIT);
#endif
#ifdef SET_MISC_OPTIONS
opt->overwrite = FALSE;
......@@ -2380,7 +2376,7 @@ static void txtar__defaultoptions(txtar_options *opt) {
case 'a':
case 'A':
opt->big_windows = TRUE;
opt->big_window_size = txtar__min(txtar__readoptnum(buf, &i), BIG_WINDOW_SIZE_LIMIT);
opt->big_window_size = txt1_MIN(txtar__readoptnum(buf, &i), BIG_WINDOW_SIZE_LIMIT);
break;
case 'n':
case 'N':
......
......@@ -2091,9 +2091,9 @@ void txtedit_doinsertfile(txtedit_state *s, char *filename, BOOL replaceifwasnul
} else {
if (tsize == 0) {
s->ty = ty;
txt_setcharoptions(s->t, txt_UPDATED + txt_DISPLAY, txt_DISPLAY);
txtundo_purge_undo(s->t);
if (replaceifwasnull) {
txt_setcharoptions(s->t, txt_UPDATED + txt_DISPLAY, txt_DISPLAY);
strcpy(s->filename, filename);
txtedit_settexttitle(s);
};
......
......@@ -39,14 +39,16 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "txt.h"
#include "os.h"
#include "wimp.h"
#include "wimpt.h"
#include "menu.h"
#include "EditIntern/txtar.h"
#include "dbox.h"
#include "event.h"
#include "txt.h"
#include "EditIntern/txtar.h"
#include "EditIntern/txtundo.h"
#include "EditIntern/txt1.h"
#include "EditIntern/txtoptmenu.h"
#include "visdelay.h"
#include "font.h"
......@@ -88,9 +90,6 @@ static char *font_hit = 0;
static int padding3;
static int padding4;
#define txtoptmenu__max(a,b) (((a)>(b))?(a):(b))
#define txtoptmenu__min(a,b) (((a)>(b))?(b):(a))
static wimp_menustr* txtoptmenu__fontmenu(void) {
/* always rebuild the font menu */
......@@ -318,7 +317,7 @@ if (s[0] == 0) {
{ int i = getint(widthbuf, 0);
if (i <= 0) i = 1;
o.big_windows = TRUE;
o.big_window_size = txtoptmenu__min(i, BIG_WINDOW_SIZE_LIMIT);
o.big_window_size = txt1_MIN(i, BIG_WINDOW_SIZE_LIMIT);
}
#endif
} else if (s[0] == MWrap) /* invert wrap bit */
......
......@@ -180,8 +180,6 @@ void txtundo_putcode(txtundo u, char code)
};
}
static int min(int a, int b) {return a < b ? a : b;}
void txtundo_putbytes(txtundo u, char* bytes, int n)
{
int blocksize;
......@@ -194,7 +192,7 @@ void txtundo_putbytes(txtundo u, char* bytes, int n)
} else {
while (1) {
if (n == 0) break;
blocksize = min(n, u->size - u->head);
blocksize = txt1_MIN(n, u->size - u->head);
tracef1("Undo putbytes %i.\n", blocksize);
(void) memcpy(/*to*/ &u->buf[u->head], /*from*/ bytes, blocksize);
n -= blocksize;
......