xterm  368
About: xterm is a terminal emulator for X with ISO/ANSI color and vt220 enhancements.
  Fossies Dox: xterm-368.tgz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

util.c File Reference
#include <xterm.h>
#include <data.h>
#include <error.h>
#include <menu.h>
#include <fontutils.h>
#include <xstrings.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <graphics.h>
Include dependency graph for util.c:

Go to the source code of this file.

Classes

struct  ToSwap
 

Macros

#define ScrnUpdate2(xw, toprow, leftcol, nrows, ncols, force)    ScrnUpdate(xw, toprow, leftcol, nrows, ncols, force)
 
#define hc_param   ,Bool hilite_color
 
#define hc_value   ,screen->hilite_color
 
#define swapAnyColor(name, a, b)   swapLocally(listToSwap, &numToSwap, &(screen->name[a]), &(screen->name[b]) hc_value)
 
#define swapAColor(a, b)   swapAnyColor(Acolors, a, b)
 
#define swapTColor(a, b)   swapAnyColor(Tcolors, a, b)
 
#define xtermSetClipRectangles(dpy, gc, x, y, rp, nr, order)    XSetClipRectangles(dpy, gc, x, y, rp, (int) nr, order)
 
#define beginClipping(screen, gc, pwidth, plength)
 
#define endClipping(screen, gc)    XSetClipMask(screen->display, gc, None)
 
#define WhichVFontData(screen, name)    GetNormalFont(screen, name)
 
#define SetMissing(tag)
 
#define MaxImageString   255
 
#define AttrFlags()   recur.attr_flags
 
#define DrawFlags()   recur.draw_flags
 
#define DIM_IT(n)   work.n = (unsigned short) ((2 * (unsigned)work.n) / 3)
 
#define DATA(n, t, f)   { n, t, XtOffsetOf(XTERM_RESOURCE, f) }
 
#define FLAG(n)   *(Boolean *)(((char *)rp) + table[n].offset)
 

Functions

static int handle_translated_exposure (XtermWidget xw, int rect_x, int rect_y, int rect_width, int rect_height)
 
static void ClearLeft (XtermWidget xw)
 
static void CopyWait (XtermWidget xw)
 
static void horizontal_copy_area (XtermWidget xw, int firstchar, int nchars, int amount)
 
static void vertical_copy_area (XtermWidget xw, int firstline, int nlines, int amount, int left, int right)
 
void FlushScroll (XtermWidget xw)
 
static Bool AddToRefresh (XtermWidget xw)
 
static Bool AddToVisible (XtermWidget xw)
 
static void adjustHiliteOnFwdScroll (XtermWidget xw, int amount, Bool all_lines)
 
static void adjustHiliteOnBakScroll (XtermWidget xw, int amount)
 
static void scrollInMargins (XtermWidget xw, int amount, int top)
 
void xtermScroll (XtermWidget xw, int amount)
 
void xtermScrollLR (XtermWidget xw, int amount, Bool toLeft)
 
void xtermColIndex (XtermWidget xw, Bool toLeft)
 
void xtermColScroll (XtermWidget xw, int amount, Bool toLeft, int at_col)
 
void RevScroll (XtermWidget xw, int amount)
 
void initZIconBeep (void)
 
static char * getIconName (void)
 
static void setZIconBeep (XtermWidget xw)
 
Boolean showZIconBeep (XtermWidget xw, char *name)
 
void resetZIconBeep (XtermWidget xw)
 
void WriteText (XtermWidget xw, IChar *str, Cardinal len)
 
void InsertLine (XtermWidget xw, int n)
 
void DeleteLine (XtermWidget xw, int n)
 
void InsertChar (XtermWidget xw, unsigned n)
 
void DeleteChar (XtermWidget xw, unsigned n)
 
static void ClearAbove (XtermWidget xw)
 
static void ClearBelow (XtermWidget xw)
 
static int ClearInLine2 (XtermWidget xw, int flags, int row, int col, unsigned len)
 
int ClearInLine (XtermWidget xw, int row, int col, unsigned len)
 
void ClearRight (XtermWidget xw, int n)
 
static void ClearLine (XtermWidget xw)
 
void ClearScreen (XtermWidget xw)
 
void do_erase_char (XtermWidget xw, int param, int mode)
 
void do_erase_line (XtermWidget xw, int param, int mode)
 
void do_erase_display (XtermWidget xw, int param, int mode)
 
static Boolean screen_has_data (XtermWidget xw)
 
void do_cd_xtra_scroll (XtermWidget xw)
 
void do_ti_xtra_scroll (XtermWidget xw)
 
static void copy_area (XtermWidget xw, int src_x, int src_y, unsigned width, unsigned height, int dest_x, int dest_y)
 
void scrolling_copy_area (XtermWidget xw, int firstline, int nlines, int amount)
 
int HandleExposure (XtermWidget xw, XEvent *event)
 
static void set_background (XtermWidget xw, int color)
 
void xtermClear2 (XtermWidget xw, int x, int y, unsigned width, unsigned height)
 
void GetColors (XtermWidget xw, ScrnColors *pColors)
 
void ChangeColors (XtermWidget xw, ScrnColors *pNew)
 
void xtermClear (XtermWidget xw)
 
void xtermRepaint (XtermWidget xw)
 
Boolean isDefaultForeground (const char *name)
 
Boolean isDefaultBackground (const char *name)
 
static void swapLocally (ToSwap *list, int *count, ColorRes *fg, ColorRes *bg, Bool hilite_color)
 
static void reallySwapColors (XtermWidget xw, ToSwap *list, int count)
 
static void swapVTwinGCs (XtermWidget xw, VTwin *win)
 
void ReverseVideo (XtermWidget xw)
 
void recolor_cursor (TScreen *screen, Cursor cursor, unsigned long fg, unsigned long bg)
 
static void xtermFillCells (XTermDraw *params, GC gc, int x, int y, Cardinal len)
 
static void drawUnderline (XtermWidget xw, GC gc, unsigned attr_flags, unsigned underline_len, int font_width, int x, int y, Bool did_ul)
 
static int fixupItalics (XTermDraw *params, GC gc, XTermFonts *curFont, int y, int x, int font_width, Cardinal len)
 
static int fakeDoubleChars (XTermDraw *params, GC gc, int y, int x, const IChar *text, Cardinal len)
 
int drawXtermText (XTermDraw *params, GC gc, int start_x, int start_y, const IChar *text, Cardinal len)
 
void xtermSizeHints (XtermWidget xw, int scrollbarWidth)
 
void getXtermSizeHints (XtermWidget xw)
 
CgsEnum whichXtermCgs (XtermWidget xw, unsigned attr_flags, Bool hilite)
 
GC updatedXtermGC (XtermWidget xw, unsigned attr_flags, CellColor fg_bg, Bool hilite)
 
void resetXtermGC (XtermWidget xw, unsigned attr_flags, Bool hilite)
 
Pixel extract_fg (XtermWidget xw, CellColor color, unsigned attr_flags)
 
Pixel extract_bg (XtermWidget xw, CellColor color, unsigned attr_flags)
 
CellColor makeColorPair (XtermWidget xw)
 
void ClearCurBackground (XtermWidget xw, int top, int left, unsigned height, unsigned width, unsigned fw)
 
Pixel getXtermBackground (XtermWidget xw, unsigned attr_flags, int color)
 
Pixel getXtermForeground (XtermWidget xw, unsigned attr_flags, int color)
 
unsigned getXtermCell (TScreen *screen, int row, int col)
 
void putXtermCell (TScreen *screen, int row, int col, int ch)
 
void update_keyboard_type (void)
 
void set_keyboard_type (XtermWidget xw, xtermKeyboardType type, Bool set)
 
void toggle_keyboard_type (XtermWidget xw, xtermKeyboardType type)
 
const char * visibleKeyboardType (xtermKeyboardType type)
 
static void init_keyboard_type (XtermWidget xw, xtermKeyboardType type, Bool set)
 
void decode_keyboard_type (XtermWidget xw, XTERM_RESOURCE *rp)
 
int extendedBoolean (const char *value, const FlagList *table, Cardinal limit)
 
int dimRound (double value)
 
static void find_xinerama_screen (Display *display, int screen, struct Xinerama_geometry *ret)
 
static void parse_xinerama_screen (Display *display, const char *str, struct Xinerama_geometry *ret)
 
int XParseXineramaGeometry (Display *display, char *parsestring, struct Xinerama_geometry *ret)
 
char * xtermSetLocale (int category, String after)
 
void xtermResetLocale (int category, char *before)
 

Macro Definition Documentation

◆ AttrFlags

#define AttrFlags ( )    recur.attr_flags

◆ beginClipping

#define beginClipping (   screen,
  gc,
  pwidth,
  plength 
)
Value:
if (pwidth > 2) { \
if (screen->use_clipping) { \
XRectangle clip; \
int clip_x = x; \
int clip_y = y - FontHeight(screen) + FontDescent(screen); \
clip.x = 0; \
clip.y = 0; \
clip.height = (unsigned short) FontHeight(screen); \
clip.width = (unsigned short) ((pwidth) * (plength)); \
xtermSetClipRectangles(screen->display, gc, \
clip_x, clip_y, \
&clip, 1, Unsorted); \
} else if (screen->use_border_clipping) { \
XRectangle clip; \
clip.x = 0; \
clip.y = 0; \
clip.height = (unsigned short) Height(screen); \
clip.width = (unsigned short) Width(screen); \
xtermSetClipRectangles(screen->display, gc, \
0, 0, \
&clip, 1, Unsorted); \
} \
}
double x
Definition: graphics.c:1088
#define Width(screen)
Definition: ptyx.h:3556
#define FontHeight(screen)
Definition: ptyx.h:3561
#define FontDescent(screen)
Definition: ptyx.h:3531
#define Height(screen)
Definition: ptyx.h:3557

Definition at line 3409 of file util.c.

◆ DATA

#define DATA (   n,
  t,
 
)    { n, t, XtOffsetOf(XTERM_RESOURCE, f) }

◆ DIM_IT

#define DIM_IT (   n)    work.n = (unsigned short) ((2 * (unsigned)work.n) / 3)

◆ DrawFlags

#define DrawFlags ( )    recur.draw_flags

◆ endClipping

#define endClipping (   screen,
  gc 
)     XSetClipMask(screen->display, gc, None)

Definition at line 3433 of file util.c.

◆ FLAG

#define FLAG (   n)    *(Boolean *)(((char *)rp) + table[n].offset)

◆ hc_param

#define hc_param   ,Bool hilite_color

Definition at line 2694 of file util.c.

◆ hc_value

#define hc_value   ,screen->hilite_color

Definition at line 2695 of file util.c.

◆ MaxImageString

#define MaxImageString   255

Definition at line 3705 of file util.c.

◆ ScrnUpdate2

#define ScrnUpdate2 (   xw,
  toprow,
  leftcol,
  nrows,
  ncols,
  force 
)     ScrnUpdate(xw, toprow, leftcol, nrows, ncols, force)

Definition at line 589 of file util.c.

◆ SetMissing

#define SetMissing (   tag)
Value:
TRACE(("%s %s: missing %d %04X\n", __FILE__, tag, missing, ch)); \
missing = 1
#define TRACE(p)
Definition: trace.h:168

Definition at line 3701 of file util.c.

◆ swapAColor

#define swapAColor (   a,
  b 
)    swapAnyColor(Acolors, a, b)

◆ swapAnyColor

#define swapAnyColor (   name,
  a,
  b 
)    swapLocally(listToSwap, &numToSwap, &(screen->name[a]), &(screen->name[b]) hc_value)

◆ swapTColor

#define swapTColor (   a,
  b 
)    swapAnyColor(Tcolors, a, b)

◆ WhichVFontData

#define WhichVFontData (   screen,
  name 
)     GetNormalFont(screen, name)

Definition at line 3575 of file util.c.

◆ xtermSetClipRectangles

#define xtermSetClipRectangles (   dpy,
  gc,
  x,
  y,
  rp,
  nr,
  order 
)     XSetClipRectangles(dpy, gc, x, y, rp, (int) nr, order)

Definition at line 3400 of file util.c.

Function Documentation

◆ AddToRefresh()

static Bool AddToRefresh ( XtermWidget  xw)
static

◆ AddToVisible()

static Bool AddToVisible ( XtermWidget  xw)
static

◆ adjustHiliteOnBakScroll()

static void adjustHiliteOnBakScroll ( XtermWidget  xw,
int  amount 
)
static

◆ adjustHiliteOnFwdScroll()

static void adjustHiliteOnFwdScroll ( XtermWidget  xw,
int  amount,
Bool  all_lines 
)
static

◆ ChangeColors()

◆ ClearAbove()

◆ ClearBelow()

◆ ClearCurBackground()

◆ ClearInLine()

int ClearInLine ( XtermWidget  xw,
int  row,
int  col,
unsigned  len 
)

◆ ClearInLine2()

◆ ClearLeft()

◆ ClearLine()

static void ClearLine ( XtermWidget  xw)
static

Definition at line 1859 of file util.c.

References assert(), ClearInLine(), TScreen::cur_row, len, TScreen::max_col, MaxCols, TScreenOf, unsigned, and void.

Referenced by do_erase_line().

◆ ClearRight()

◆ ClearScreen()

◆ copy_area()

◆ CopyWait()

static void CopyWait ( XtermWidget  xw)
static

◆ decode_keyboard_type()

◆ DeleteChar()

◆ DeleteLine()

◆ dimRound()

int dimRound ( double  value)

Definition at line 5397 of file util.c.

References int, result, and value.

◆ do_cd_xtra_scroll()

◆ do_erase_char()

void do_erase_char ( XtermWidget  xw,
int  param,
int  mode 
)

Definition at line 1905 of file util.c.

References ClearRight(), DEC_PROTECT, OFF_PROTECT, TScreen::protected_mode, and TScreenOf.

Referenced by doparsing().

◆ do_erase_display()

◆ do_erase_line()

void do_erase_line ( XtermWidget  xw,
int  param,
int  mode 
)

Definition at line 1920 of file util.c.

References ClearLeft(), ClearLine(), ClearRight(), DEC_PROTECT, OFF_PROTECT, TScreen::protected_mode, and TScreenOf.

Referenced by doparsing().

◆ do_ti_xtra_scroll()

void do_ti_xtra_scroll ( XtermWidget  xw)

Definition at line 2065 of file util.c.

References TScreen::max_row, _XtermWidgetRec::misc, _Misc::tiXtraScroll, TScreenOf, and xtermScroll().

Referenced by dpmodes(), and restoremodes().

◆ drawUnderline()

static void drawUnderline ( XtermWidget  xw,
GC  gc,
unsigned  attr_flags,
unsigned  underline_len,
int  font_width,
int  x,
int  y,
Bool  did_ul 
)
static

◆ drawXtermText()

◆ extendedBoolean()

int extendedBoolean ( const char *  value,
const FlagList table,
Cardinal  limit 
)

Definition at line 5353 of file util.c.

References TCAPINFO::code, FullS2L, int, name, result, table, TRACE, value, x_strcasecmp(), and xtermWarning().

Referenced by main(), and VTInitialize().

◆ extract_bg()

Pixel extract_bg ( XtermWidget  xw,
CellColor  color,
unsigned  attr_flags 
)

◆ extract_fg()

Pixel extract_fg ( XtermWidget  xw,
CellColor  color,
unsigned  attr_flags 
)

◆ fakeDoubleChars()

static int fakeDoubleChars ( XTermDraw params,
GC  gc,
int  y,
int  x,
const IChar text,
Cardinal  len 
)
static

Definition at line 3670 of file util.c.

References CSET_SWL, drawXtermText(), free(), len, XTermDraw::this_chrset, TypeMallocN, and x.

Referenced by drawXtermText().

◆ find_xinerama_screen()

static void find_xinerama_screen ( Display *  display,
int  screen,
struct Xinerama_geometry ret 
)
static

◆ fixupItalics()

static int fixupItalics ( XTermDraw params,
GC  gc,
XTermFonts curFont,
int  y,
int  x,
int  font_width,
Cardinal  len 
)
static

◆ FlushScroll()

◆ GetColors()

void GetColors ( XtermWidget  xw,
ScrnColors pColors 
)

Definition at line 2487 of file util.c.

References NCOLORS, SET_COLOR_VALUE, T_COLOR, TScreenOf, and ScrnColors::which.

Referenced by GetOldColors(), and xtermPushColors().

◆ getIconName()

static char* getIconName ( void  )
static

Definition at line 978 of file util.c.

References toplevel.

Referenced by resetZIconBeep(), and setZIconBeep().

◆ getXtermBackground()

Pixel getXtermBackground ( XtermWidget  xw,
unsigned  attr_flags,
int  color 
)

◆ getXtermCell()

unsigned getXtermCell ( TScreen screen,
int  row,
int  col 
)

Definition at line 5023 of file util.c.

References LineData::charData, col, getLineData(), LineData::lineSize, and row.

Referenced by doparsing().

◆ getXtermForeground()

Pixel getXtermForeground ( XtermWidget  xw,
unsigned  attr_flags,
int  color 
)

◆ getXtermSizeHints()

void getXtermSizeHints ( XtermWidget  xw)

◆ handle_translated_exposure()

static int handle_translated_exposure ( XtermWidget  xw,
int  rect_x,
int  rect_y,
int  rect_width,
int  rect_height 
)
static

◆ HandleExposure()

◆ horizontal_copy_area()

static void horizontal_copy_area ( XtermWidget  xw,
int  firstchar,
int  nchars,
int  amount 
)
static

Definition at line 2183 of file util.c.

References copy_area(), TScreen::cur_row, CursorY, FontHeight, getLineData(), LineCursorX, LineFontWidth, and TScreenOf.

Referenced by DeleteChar(), and InsertChar().

◆ init_keyboard_type()

static void init_keyboard_type ( XtermWidget  xw,
xtermKeyboardType  type,
Bool  set 
)
static

◆ initZIconBeep()

void initZIconBeep ( void  )

Definition at line 969 of file util.c.

References resource, xtermWarning(), and XTERM_RESOURCE::zIconBeep.

Referenced by main().

◆ InsertChar()

◆ InsertLine()

◆ isDefaultBackground()

Boolean isDefaultBackground ( const char *  name)

Definition at line 2653 of file util.c.

References name, and x_strcasecmp().

Referenced by fill_Tres(), and main().

◆ isDefaultForeground()

Boolean isDefaultForeground ( const char *  name)

Definition at line 2647 of file util.c.

References name, and x_strcasecmp().

Referenced by fill_Tres(), and main().

◆ makeColorPair()

CellColor makeColorPair ( XtermWidget  xw)

◆ parse_xinerama_screen()

static void parse_xinerama_screen ( Display *  display,
const char *  str,
struct Xinerama_geometry ret 
)
static

Definition at line 5461 of file util.c.

References find_xinerama_screen(), FullS2L, int, and xtermWarning().

Referenced by XParseXineramaGeometry().

◆ putXtermCell()

void putXtermCell ( TScreen screen,
int  row,
int  col,
int  ch 
)

◆ reallySwapColors()

static void reallySwapColors ( XtermWidget  xw,
ToSwap list,
int  count 
)
static

Definition at line 2745 of file util.c.

References for_each_text_gc, FreeMarkGCs(), redoCgs(), and TRACE.

Referenced by ReverseVideo().

◆ recolor_cursor()

void recolor_cursor ( TScreen screen,
Cursor  cursor,
unsigned long  fg,
unsigned long  bg 
)

◆ resetXtermGC()

◆ resetZIconBeep()

void resetZIconBeep ( XtermWidget  xw)

◆ ReverseVideo()

◆ RevScroll()

◆ screen_has_data()

static Boolean screen_has_data ( XtermWidget  xw)
static

◆ scrolling_copy_area()

void scrolling_copy_area ( XtermWidget  xw,
int  firstline,
int  nlines,
int  amount 
)

Definition at line 2249 of file util.c.

References TScreenOf, and vertical_copy_area().

Referenced by WindowScroll().

◆ scrollInMargins()

static void scrollInMargins ( XtermWidget  xw,
int  amount,
int  top 
)
static

◆ set_background()

◆ set_keyboard_type()

void set_keyboard_type ( XtermWidget  xw,
xtermKeyboardType  type,
Bool  set 
)

◆ setZIconBeep()

static void setZIconBeep ( XtermWidget  xw)
static

◆ showZIconBeep()

Boolean showZIconBeep ( XtermWidget  xw,
char *  name 
)

◆ swapLocally()

static void swapLocally ( ToSwap list,
int count,
ColorRes fg,
ColorRes bg,
Bool  hilite_color 
)
static

Definition at line 2707 of file util.c.

References ToSwap::bg, EXCHANGE, ToSwap::fg, tmp, TRACE, and ColorRes::value.

◆ swapVTwinGCs()

static void swapVTwinGCs ( XtermWidget  xw,
VTwin win 
)
static

Definition at line 2759 of file util.c.

References gcBold, gcBoldReverse, gcNorm, gcNormReverse, and swapCgs().

Referenced by ReverseVideo().

◆ toggle_keyboard_type()

◆ update_keyboard_type()

◆ updatedXtermGC()

◆ vertical_copy_area()

static void vertical_copy_area ( XtermWidget  xw,
int  firstline,
int  nlines,
int  amount,
int  left,
int  right 
)
static

◆ visibleKeyboardType()

◆ whichXtermCgs()

CgsEnum whichXtermCgs ( XtermWidget  xw,
unsigned  attr_flags,
Bool  hilite 
)

Definition at line 4673 of file util.c.

References BOLDATTR, gcBold, gcBoldReverse, gcMAX, gcNorm, gcNormReverse, ReverseOrHilite, and TScreenOf.

Referenced by resetXtermGC(), and updatedXtermGC().

◆ WriteText()

◆ XParseXineramaGeometry()

int XParseXineramaGeometry ( Display *  display,
char *  parsestring,
struct Xinerama_geometry ret 
)

◆ xtermClear()

void xtermClear ( XtermWidget  xw)

Definition at line 2626 of file util.c.

References FullHeight, FullWidth, TRACE, TScreenOf, and xtermClear2().

Referenced by ScrollBarOff(), ScrollBarOn(), xtermRepaint(), and xtermUpdateFontInfo().

◆ xtermClear2()

◆ xtermColIndex()

void xtermColIndex ( XtermWidget  xw,
Bool  toLeft 
)

◆ xtermColScroll()

◆ xtermFillCells()

◆ xtermRepaint()

◆ xtermResetLocale()

void xtermResetLocale ( int  category,
char *  before 
)

Definition at line 5551 of file util.c.

References free(), NonNull, TRACE, and void.

Referenced by create_menu(), VTInitialize(), xtermDumpHtml(), and xtermDumpSvg().

◆ xtermScroll()

◆ xtermScrollLR()

void xtermScrollLR ( XtermWidget  xw,
int  amount,
Bool  toLeft 
)

Definition at line 780 of file util.c.

References ScrnLeftMargin, and xtermColScroll().

Referenced by doparsing().

◆ xtermSetLocale()

char* xtermSetLocale ( int  category,
String  after 
)

Definition at line 5540 of file util.c.

References NonNull, TRACE, void, and x_strdup().

Referenced by create_menu(), VTInitialize(), xtermDumpHtml(), and xtermDumpSvg().

◆ xtermSizeHints()