X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=src%2Findent.c;h=9ecf75ba5918feffda416ee4fe84eed337812890;hp=7ace51f27063161758b599ef809f3ec4a1bc8bd6;hb=566b3d194e2d5c783808ac39437bd7e1a28b1c5c;hpb=0d13da69401238f67cf3b2ffddfc575446da1b59 diff --git a/src/indent.c b/src/indent.c index 7ace51f..9ecf75b 100644 --- a/src/indent.c +++ b/src/indent.c @@ -169,7 +169,7 @@ column_at_point (struct buffer *buf, Bufpos init_pos, int cur_col) + displayed_glyphs->end_columns)); #else /* XEmacs */ #ifdef MULE - col += XCHARSET_COLUMNS (CHAR_CHARSET (c)); + col += CHAR_COLUMNS (c); #else col ++; #endif /* MULE */ @@ -195,6 +195,53 @@ column_at_point (struct buffer *buf, Bufpos init_pos, int cur_col) } int +string_column_at_point (Lisp_String* s, Bufpos init_pos, int tab_width) +{ + int col; + int tab_seen; + int post_tab; + Bufpos pos = init_pos; + Emchar c; + + if (tab_width <= 0 || tab_width > 1000) tab_width = 8; + col = tab_seen = post_tab = 0; + + while (1) + { + if (pos <= 0) + break; + + pos--; + c = string_char (s, pos); + if (c == '\t') + { + if (tab_seen) + col = ((col + tab_width) / tab_width) * tab_width; + + post_tab += col; + col = 0; + tab_seen = 1; + } + else if (c == '\n') + break; + else +#ifdef MULE + col += CHAR_COLUMNS (c); +#else + col ++; +#endif /* MULE */ + } + + if (tab_seen) + { + col = ((col + tab_width) / tab_width) * tab_width; + col += post_tab; + } + + return col; +} + +int current_column (struct buffer *buf) { if (buf == last_known_column_buffer @@ -225,11 +272,11 @@ If BUFFER is nil, the current buffer is assumed. DEFUN ("indent-to", Findent_to, 1, 3, "NIndent to column: ", /* Indent from point with tabs and spaces until COLUMN is reached. -Optional second argument MIN says always do at least MIN spaces - even if that goes past COLUMN; by default, MIN is zero. +Optional second argument MINIMUM says always do at least MINIMUM spaces + even if that goes past COLUMN; by default, MINIMUM is zero. If BUFFER is nil, the current buffer is assumed. */ - (col, minimum, buffer)) + (column, minimum, buffer)) { /* This function can GC */ int mincol; @@ -238,7 +285,7 @@ If BUFFER is nil, the current buffer is assumed. int tab_width = XINT (buf->tab_width); Bufpos opoint = 0; - CHECK_INT (col); + CHECK_INT (column); if (NILP (minimum)) minimum = Qzero; else @@ -248,7 +295,7 @@ If BUFFER is nil, the current buffer is assumed. fromcol = current_column (buf); mincol = fromcol + XINT (minimum); - if (mincol < XINT (col)) mincol = XINT (col); + if (mincol < XINT (column)) mincol = XINT (column); if (fromcol == mincol) return make_int (mincol); @@ -409,7 +456,7 @@ Returns the actual column that it moved to. + displayed_glyphs->end_columns)); #else /* XEmacs */ #ifdef MULE - col += XCHARSET_COLUMNS (CHAR_CHARSET (c)); + col += CHAR_COLUMNS (c); #else col ++; #endif /* MULE */