コード例 #1
0
ファイル: thai.c プロジェクト: razvanm/mrxvt
/* EXTPROTO */
int
ThaiPixel2Col (rxvt_t* r, int page, int x, int y)
{
	int row;             /* row storing data */
	int i;               /* byte offset index */
	int xpixel;          /* dummy x pixel */
	char *str;           /* drawn_text pointer */
	XFontStruct *wf;     /* font */

	/* locate buffer storing data */
	row = Pixel2Row(y);
	MAX_IT(row, 0);
	MIN_IT(row, r->TermWin.nrow - 1);
	str = PVTS(r, page)->drawn_text[row];

	/* access to font structure */
	wf = r->TermWin.font;

	/* increase byte offset until we get to target x */
	i = 0;
	xpixel = FONT_WIDTH(wf, str[0]);
	x -= r->TermWin.int_bwidth;
	while (xpixel <= x && i < r->TermWin.ncol){
		i++;
		xpixel += FONT_WIDTH(wf, str[i]); /* wf->per_char[char_num].width;  */
	}

	MAX_IT(i, 0);
	MIN_IT(i, r->TermWin.ncol);
	return i;
}
コード例 #2
0
ファイル: thai.c プロジェクト: tlwg/xiterm-thai
int ThaiPixel2Col2(int x, int y)
{
  int doffset = Pixel2Row(y) * (TermWin.ncol + 1);
  unsigned char *start = &drawn_text[doffset];
  int col=0, cx=0;
  x -= TermWin_internalBorder;
  if(thai_spcount) {
    thai_colinc1(0);
    while(cx<=x) {
      cx += TermWin.fwidth * thai_colinc1(start[col]);
      col++;
    }
  }
  else {
    while(cx<=x) {
      if(!movetab[start[col]])
	cx += TermWin.fwidth;
      col++;
    }
  }

  while(movetab[start[col]] && col < TermWin.ncol)
    col++;
  return col-1;
}