Counts the column offset in a string, taking tabs into account. Used mostly to find indentation.
425973
function countColumn(string, end, tabSize, startIndex, startValue) {
    if (end == null) {
      end = string.search(/[^\s\u00a0]/);
      if (end == -1) end = string.length;
    }
    for (var i = startIndex || 0, n = startValue || 0; i < end; ++i) {
      if (string.charAt(i) == "\t") n += tabSize - (n % tabSize);
      else ++n;
    }
    return n;
  }
420776
def _tabulate(rows, headers, spacing=5):
    """"""
    if len(rows) == 0:
        return "None\n"
    assert len(rows[0]) == len(headers)
    count = len(rows[0])
    widths = [0 for _ in range(count)]
    rows = [headers] + rows

    for row in rows:
        for index, field in enumerate(row):
            if len(str(field)) > widths[index]:
                widths[index] = len(str(field))

    output = ""
    for row in rows:
        for index, field in enumerate(row):
            field = str(field)
            output += field + (widths[index] - len(field) + spacing) * " "
        output += "\n"
    return output
355604
def tab(self):
        
        for stop in sorted(self.tabstops):
            if self.cursor.x < stop:
                column = stop
                break
        else:
            column = self.columns - 1

        self.cursor.x = column
1047917
def clean_offsetscounts(offsets, counts):
    
    # TODO: cythonize this
    offsets = list(offsets)
    counts = list(counts)
    size = len(offsets)
    if size != len(counts):
        raise ValueError('StripOffsets and StripByteCounts mismatch')
    j = 0
    for i, (o, b) in enumerate(zip(offsets, counts)):
        if b > 0:
            if o > 0:
                if i > j:
                    offsets[j] = o
                    counts[j] = b
                j += 1
                continue
            raise ValueError('invalid offset')
        log.warning('clean_offsetscounts: empty bytecount')
    if size == len(offsets):
        return offsets, counts
    if j == 0:
        return [offsets[0]], [counts[0]]
    return offsets[:j], counts[:j]
980751
def count_indents_last_line(self, spacecount, tabs=0, back=5):
        
        if not self.has_space():
            return 0
        lines = self.get_surrounding_lines(back, 0)

        for line in reversed(lines):
            if not line.string.isspace():
                return line.count_indents(spacecount, tabs)
        return 0
11991
def _get_char_offsets(self, char_offsets):
        """"""
        if char_offsets:
            char_offsets = char_offsets
            char_offsets.append(len(self.text))
        else:
            char_offsets = np.zeros(len(self.tokens) + 1)
            for i, tok in enumerate(self.tokens):
                # Add 1 to account for the spaces between tokens
                char_offsets[i + 1] = char_offsets[i] + len(tok) + 1
            char_offsets[-1] = len(self.text)
        return np.array(char_offsets)
537877
private void append(final KeyValue column, 
                      final boolean is_count, 
                      final boolean strip_string) {
    // for now assume we properly allocated our qualifiers
    if (is_count) {
      int offset = strip_string ? 
          Internal.getOffsetFromQualifier(column.qualifier(), 
          RollupQuery.COUNT.length + 1) :
            Internal.getOffsetFromQualifier(column.qualifier(), 
                1);
      if (last_count_offset > -1 && offset <= last_count_offset) {
        // only accept equivalent offsets. If somehow we get an earlier one, HBase is broke 
        if (offset == last_count_offset && tsdb.getConfig().fix_duplicates()) {
          if (column.timestamp() < last_count_ts) {
            if (LOG.isDebugEnabled()) {
              LOG.debug("Skipping older duplicate count value for " + column 
              + " of " + offset + " which is = the last offset " + last_count_offset
              + " for " + this);
            }
            return;
          } else { // if it's equal, just use the one we got first
            // roll back the indices
            indices[2] -= 2;
            indices[3] -= Internal.getValueLengthFromQualifier(
                count_qualifiers, indices[2]);
            if (LOG.isDebugEnabled()) {
              LOG.debug("Replacing older duplicate count with " + column 
              + " of " + offset + " which is = the last offset " + last_count_offset
              + " for " + this);
            }
          }
        } else {
          throw new IllegalArgumentException("The count offset for " + column 
              + " of " + offset + " is <= the last offset " + last_count_offset
              + " for " + this);
        }
      }
      last_count_offset = offset;
      last_count_ts = column.timestamp();
      if (strip_string) {
        System.arraycopy(column.qualifier(), RollupQuery.COUNT.length + 1, 
            count_qualifiers, indices[2], 2);
      } else {
        System.arraycopy(column.qualifier(), 1, count_qualifiers, indices[2], 2);
      }
      indices[2] += 2;
      
      if (indices[3] + column.value().length > count_values.length) {
        byte[] buf = new byte[count_values.length * 2];
        System.arraycopy(count_values, 0, buf, 0, count_values.length);
        count_values = buf;
      }
      System.arraycopy(column.value(), 0, count_values, indices[3], 
          column.value().length);
      indices[3] += column.value().length;
    } else {
      int offset = strip_string ? 
          Internal.getOffsetFromQualifier(column.qualifier(), 
              rollup_query.getRollupAggPrefix().length)
          : Internal.getOffsetFromQualifier(column.qualifier(), 1);
      if (last_offset > -1 && offset <= last_offset) {
        // only accept equivalent offsets. If somehow we get an earlier one, HBase is broke
        if (offset == last_offset && tsdb.getConfig().fix_duplicates()) {
          if (column.timestamp() < last_value_ts) {
            if (LOG.isDebugEnabled()) {
              LOG.debug("Skipping older duplicate value for " + column 
              + " of " + offset + " which is = the last offset " + last_count_offset
              + " for " + this);
            }
            return;
          } else { // if it's equal, just use the one we got first
            // roll back the indices
            indices[0] -= 2;
            indices[1] -= Internal.getValueLengthFromQualifier(qualifiers, indices[0]);
            if (LOG.isDebugEnabled()) {
              LOG.debug("Replacing older duplicate value with " + column 
              + " of " + offset + " is = the last offset " + last_count_offset
              + " for " + this);
            }
          }
        } else {
          throw new IllegalDataException("The offset for " + column 
              + " of " + offset + " is <= the last offset " + last_offset
              + " for " + this);
        }
      }
      last_offset = offset;
      last_value_ts = column.timestamp();
      if (strip_string) {
        System.arraycopy(column.qualifier(), 
            rollup_query.getRollupAggPrefix().length, qualifiers, indices[0], 2);
      } else {
        System.arraycopy(column.qualifier(), 1, qualifiers, indices[0], 2);
      }
      indices[0] += 2;
      
      if (indices[1] + column.value().length > values.length) {
        byte[] buf = new byte[values.length * 2];
        System.arraycopy(values, 0, buf, 0, values.length);
        values = buf;
      }
      System.arraycopy(column.value(), 0, values, indices[1], 
          column.value().length);
      indices[1] += column.value().length;
    }
  }
681392
def _indent(string, count):
    ''''''
    indent = _INDENT * count
    ret = indent + string.replace('\n', '\n' + indent)
    return ret.rstrip()
671944
def str_blockIndent(astr_buf, a_tabs=1, a_tabLength=4, **kwargs):
    
    str_tabBoundary = " "
    for key, value in kwargs.iteritems():
      if key == 'tabBoundary':  str_tabBoundary = value
    b_trailN = False
    length = len(astr_buf)
    ch_trailN = astr_buf[length - 1]
    if ch_trailN == '\n':
      b_trailN = True
      astr_buf = astr_buf[0:length - 1]
    str_ret = astr_buf
    str_tab = ''
    str_Indent = ''
    for i in range(a_tabLength):
        str_tab = '%s ' % str_tab
    str_tab = "%s%s" % (str_tab, str_tabBoundary)
    for i in range(a_tabs):
        str_Indent = '%s%s' % (str_Indent, str_tab)
    str_ret = re.sub('\n', '\n%s' % str_Indent, astr_buf)
    str_ret = '%s%s' % (str_Indent, str_ret)
    if b_trailN: str_ret = str_ret + '\n'
    return str_ret
578510
function(offset) {

			var monthNum = this.month
			offset = offset || 0
			monthNum += offset

			if(monthNum < 0) { monthNum = 11 }
			if(monthNum > 11) { monthNum = 0 }
			var month = this.getOffsetMonth(offset)
				, year = this.getOffsetYear(offset)

			// get the first day of the month we are currently viewing
			var firstOfMonth = new Date(year, month, 1).getDay(),
	
			// get the total number of days in the month we are currently viewing
			numDays = this.offsetDaysInMonth(offset),
	
			// declare our day counter
			dayCount = 0,
	
			html = '',
	
			row = '<tr>'
			
			// print out previous month's "days"
			for(i = 1; i <= firstOfMonth; i++) {
				row += '<td>&nbsp;</td>'
				dayCount++
			}
	
			for(i = 1; i <= numDays; i++) {
				// if we have reached the end of a week, wrap to the next line
				if(dayCount == 7) {
					row += '</tr>'
					html += row
					row = '<tr>'
					dayCount = 0
				}

				// output the text that goes inside each td
				// if the day is the current day, add a class of "selected"
				// Only show a default date if the selection mode is 'single'
				row += '<td data-day="' + i + '" class=""><a href="#">' + i + '</a></td>'
				dayCount++
			}
			
			// if we haven't finished at the end of the week, start writing out the "days" for the next month
			for(i = 1; i <= (7 - dayCount); i++) {
				row += '<td>&nbsp;</td>'
			}
	
			html += row
			
			return html
		}
1056692
def count_indents_length_last_line(self, spacecount, tabs=0, back=5):
        
        if not self.has_space():
            return 0
        lines = self.get_surrounding_lines(back, 0)

        for line in reversed(lines):
            if not line.string.isspace():
                return line.count_indents_length(spacecount, tabs)
        return (0, 0)
458102
public static int latinIndexOf(String str, int offset)
    {
        for ( int j = offset; j < str.length(); j++ ) {
            if ( isEnChar(str.charAt(j)) ) {
                return j;
            }
        }
        
        return -1;
    }
558602
String getIndentation()
	{
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < count; i++)
		{
			sb.append(indent);
		}

		return sb.toString();
	}
1268035
def _makeIndentAsColumn(self, block, column, offset=0):
        
        blockText = block.text()
        textBeforeColumn = blockText[:column]
        tabCount = textBeforeColumn.count('\t')

        visibleColumn = column + (tabCount * (self._indenter.width - 1))
        return self._makeIndentFromWidth(visibleColumn + offset)
1274050
def strip_indent(s, n) 
		i = 0
		while i < s.size && n>0
			c = s[i,1]
			if c == ' '
				n-=1;
			elsif c == "\t"
				n-=TabSize;
			else
				break
			end
			i+=1
		end
		s[i, s.size]
	end
1269919
private int getLineBreakColumnIndex(int lineIndex) {
    int lineBreakIndex = lineBreakIndices.get(lineIndex);
    return (lineIndex == 0) ?
         lineBreakIndex : lineBreakIndex - lineBreakIndices.get(lineIndex - 1) - 1;
  }
838068
def calculate_indent(text):
    
    indent = 0
    for c in text:
        if c is '\t':
            raise ValueError()
        if c is not ' ':
            return indent,text[indent:]
        indent += 1
    return indent,''