take advantage of QMIN&QMAX instead of (conflicting) own definitions

svn path=/trunk/kdebase/konsole/; revision=20967
wilder-portage
Harri Porten 27 years ago
parent dda4392d44
commit 1c51a01cb9
  1. 45
      src/TEScreen.C
  2. 19
      src/TEWidget.C
  3. 6
      src/TEmuVt102.C
  4. 10
      src/main.C

@ -39,9 +39,6 @@
#include "TEScreen.h"
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define HERE printf("%s(%d): here\n",__FILE__,__LINE__)
//FIXME: this is emulation specific. Use FALSE for xterm, TRUE for ANSI.
@ -99,8 +96,8 @@ void TEScreen::cursorUp(int n)
{
if (n == 0) n = 1; // Default
int stop = cuY < tmargin ? 0 : tmargin;
cuX = MIN(columns-1,cuX); // nowrap!
cuY = MAX(stop,cuY-n);
cuX = QMIN(columns-1,cuX); // nowrap!
cuY = QMAX(stop,cuY-n);
}
void TEScreen::cursorDown(int n)
@ -108,23 +105,23 @@ void TEScreen::cursorDown(int n)
{
if (n == 0) n = 1; // Default
int stop = cuY > bmargin ? lines-1 : bmargin;
cuX = MIN(columns-1,cuX); // nowrap!
cuY = MIN(stop,cuY+n);
cuX = QMIN(columns-1,cuX); // nowrap!
cuY = QMIN(stop,cuY+n);
}
void TEScreen::cursorLeft(int n)
//=CUB
{
if (n == 0) n = 1; // Default
cuX = MIN(columns-1,cuX); // nowrap!
cuX = MAX(0,cuX-n);
cuX = QMIN(columns-1,cuX); // nowrap!
cuX = QMAX(0,cuX-n);
}
void TEScreen::cursorRight(int n)
//=CUF
{
if (n == 0) n = 1; // Default
cuX = MIN(columns-1,cuX+n);
cuX = QMIN(columns-1,cuX+n);
}
/*!
@ -359,7 +356,7 @@ void TEScreen::NextLine()
void TEScreen::eraseChars(int n)
{
if (n == 0) n = 1; // Default
int p = MAX(0,MIN(cuX+n-1,columns-1));
int p = QMAX(0,QMIN(cuX+n-1,columns-1));
clearImage(loc(cuX,cuY),loc(p,cuY),' ');
}
@ -371,7 +368,7 @@ void TEScreen::eraseChars(int n)
void TEScreen::deleteChars(int n)
{
if (n == 0) n = 1; // Default
int p = MAX(0,MIN(cuX+n,columns-1));
int p = QMAX(0,QMIN(cuX+n,columns-1));
moveImage(loc(cuX,cuY),loc(p,cuY),loc(columns-1,cuY));
clearImage(loc(columns-n,cuY),loc(columns-1,cuY),' ');
}
@ -384,8 +381,8 @@ void TEScreen::deleteChars(int n)
void TEScreen::insertChars(int n)
{
if (n == 0) n = 1; // Default
int p = MAX(0,MIN(columns-1-n,columns-1));
int q = MAX(0,MIN(cuX+n,columns-1));
int p = QMAX(0,QMIN(columns-1-n,columns-1));
int q = QMAX(0,QMIN(cuX+n,columns-1));
moveImage(loc(q,cuY),loc(cuX,cuY),loc(p,cuY));
clearImage(loc(cuX,cuY),loc(q-1,cuY),' ');
}
@ -463,8 +460,8 @@ void TEScreen::saveCursor()
void TEScreen::restoreCursor()
{
cuX = MIN(sa_cuX,columns-1);
cuY = MIN(sa_cuY,lines-1);
cuX = QMIN(sa_cuX,columns-1);
cuY = QMIN(sa_cuY,lines-1);
graphic = sa_graphic;
pound = sa_pound;
cu_re = sa_cu_re;
@ -502,8 +499,8 @@ void TEScreen::resizeImage(int new_lines, int new_columns)
newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR;
newimg[y*new_columns+x].r = DEFAULT_RENDITION;
}
int cpy_lines = MIN(new_lines, lines);
int cpy_columns = MIN(new_columns,columns);
int cpy_lines = QMIN(new_lines, lines);
int cpy_columns = QMIN(new_columns,columns);
// copy to new image
for (int y = 0; y < cpy_lines; y++)
for (int x = 0; x < cpy_columns; x++)
@ -517,8 +514,8 @@ void TEScreen::resizeImage(int new_lines, int new_columns)
image = newimg;
lines = new_lines;
columns = new_columns;
cuX = MIN(cuX,columns-1);
cuY = MIN(cuY,lines-1);
cuX = QMIN(cuX,columns-1);
cuY = QMIN(cuY,lines-1);
// FIXME: try to keep values, evtl.
tmargin=0;
@ -603,7 +600,7 @@ ca* TEScreen::getCookedImage()
for (y = 0; (y < lines) && (y < (histLines-histCursor)); y++)
{
int len = MIN(columns,histBuffer[y+histCursor]->len);
int len = QMIN(columns,histBuffer[y+histCursor]->len);
ca* img = histBuffer[y+histCursor]->line;
for (x = 0; x < len; x++)
@ -688,7 +685,7 @@ void TEScreen::clear()
void TEScreen::BackSpace()
{
cuX = MAX(0,cuX-1);
cuX = QMAX(0,cuX-1);
if (BS_CLEARS) image[loc(cuX,cuY)].c = ' ';
}
@ -872,14 +869,14 @@ void TEScreen::setCursorX(int x)
{
if (x == 0) x = 1; // Default
x -= 1; // Adjust
cuX = MIN(columns-1, x);
cuX = QMIN(columns-1, x);
}
void TEScreen::setCursorY(int y)
{
if (y == 0) y = 1; // Default
y -= 1; // Adjust
cuY = MIN(lines -1, y + (getMode(MODE_Origin) ? tmargin : 0) );
cuY = QMIN(lines -1, y + (getMode(MODE_Origin) ? tmargin : 0) );
}
/*! set cursor to the `left upper' corner of the screen.

@ -57,9 +57,6 @@
#include <kmsgbox.h>
#include <X11/Xlib.h>
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define HERE printf("%s(%d): here\n",__FILE__,__LINE__)
#define HCNT(Name) //{ static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); }
@ -250,8 +247,8 @@ HCNT("setImage");
int cb = -1; // undefined
int cr = -1; // undefined
int lins = MIN(this->lines, MAX(0,lines ));
int cols = MIN(this->columns,MAX(0,columns));
int lins = QMIN(this->lines, QMAX(0,lines ));
int cols = QMIN(this->columns,QMAX(0,columns));
char *disstr = new char[cols];
//{ static int cnt = 0; printf("setImage %d\n",cnt++); }
@ -327,10 +324,10 @@ HCNT("paintEvent");
int tLx = tL.x();
int tLy = tL.y();
int lux = MIN(columns-1, MAX(0,(rect.left() - tLx - blX ) / font_w));
int luy = MIN(lines-1, MAX(0,(rect.top() - tLy - bY ) / font_h));
int rlx = MIN(columns-1, MAX(0,(rect.right() - tLx - blX ) / font_w));
int rly = MIN(lines-1, MAX(0,(rect.bottom() - tLy - bY ) / font_h));
int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w));
int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h));
int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w));
int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h));
/*
printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly,
@ -397,8 +394,8 @@ void TEWidget::propagateSize()
int oldcol = columns;
makeImage();
// we copy the old image to reduce flicker
int lins = MIN(oldlin,lines);
int cols = MIN(oldcol,columns);
int lins = QMIN(oldlin,lines);
int cols = QMIN(oldcol,columns);
if (oldimg)
{
for (int lin = 0; lin < lins; lin++)

@ -43,8 +43,6 @@
#include "TEmuVt102.moc"
#define ESC 27
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define HERE printf("%s(%d): here\n",__FILE__,__LINE__)
@ -440,7 +438,7 @@ void VT102Emulation::tableInit()
#define Xte (Xpe && cc == 7 )
#define ces(C) ( (tbl[ cc ] & (C)) == (C) && !Xte)
#define Dig a[n] = 10*a[n] + cc - '0';
#define Arg argc = MIN(argc+1,MAXARGS-1); argv[argc] = 0;
#define Arg argc = QMIN(argc+1,MAXARGS-1); argv[argc] = 0;
//FIXME: introduce real states.
//
@ -455,7 +453,7 @@ void VT102Emulation::onRcvByte(int c)
if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC) reset(); //VT100: CAN or SUB
if (cc != ESC) { tau( TY_CTL___(cc ), 0, 0); return; }
}
pbuf[ppos] = cc; ppos = MIN(ppos+1,MAXPBUF-1);
pbuf[ppos] = cc; ppos = QMIN(ppos+1,MAXPBUF-1);
unsigned char* s = pbuf;
int p = ppos;
int * a = argv;

@ -76,10 +76,6 @@
#define HERE printf("%s(%d): here\n",__FILE__,__LINE__)
#ifndef MIN
inline int MIN(int A, int B) { return ((A>B) ? B : A); }
#endif
#undef PACKAGE
#undef VERSION
#define PACKAGE "konsole"
@ -439,8 +435,8 @@ void TEDemo::readProperties(KConfig* config)
b_framevis = config->readBoolEntry("has frame",TRUE);
b_bshack = config->readBoolEntry("BS hack",TRUE);
b_inspaste = config->readBoolEntry("insert paste",FALSE);
n_font = MIN(config->readUnsignedNumEntry("font",3),7);
n_scroll = MIN(config->readUnsignedNumEntry("scrollbar",SCRRIGHT),2);
n_font = QMIN(config->readUnsignedNumEntry("font",3),7);
n_scroll = QMIN(config->readUnsignedNumEntry("scrollbar",SCRRIGHT),2);
s_schema = config->readEntry("schema","");
if (menubar->menuBarPos() != KMenuBar::Floating)
{ QString entry = config->readEntry("kmenubar");
@ -733,7 +729,7 @@ void TEDemo::newSession(int i)
QString emu = co->readEntry("Term");
QString sch = co->readEntry("Schema");
QString txt = co->readEntry("Comment"); // not null
int fno = MIN(co->readUnsignedNumEntry("Font",se->fontNo()),7);
int fno = QMIN(co->readUnsignedNumEntry("Font",se->fontNo()),7);
ColorSchema* schema = sch.isEmpty()
? (ColorSchema*)NULL

Loading…
Cancel
Save