File: tab.c

package info (click to toggle)
sex 0.19.1-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 572 kB
  • ctags: 779
  • sloc: ansic: 6,273; sh: 179; makefile: 116
file content (33 lines) | stat: -rw-r--r-- 473 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * File:	tab.c
 * Purpose:	Compute tab positions.
 */

#include <assert.h>
#include "tab.h"

#ifndef DEFAULT_TAB_WIDTH
#define DEFAULT_TAB_WIDTH	8
#endif

static long width = DEFAULT_TAB_WIDTH;


void tab_set_width(long w) {
	assert(w > 0);
	width = w;
}

long tab_width(void) {
	return width;
}

long tab_next(long col) {
	assert(col >= 0);
	return col + tab_next_distance(col);
}

long tab_next_distance(long col) {
	assert(col >= 0);
	return width - (col % width);
}