summaryrefslogtreecommitdiffstats
path: root/tapset/indent.stp
blob: dface78195e6ff69b9f4b925c557bd756279d6e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
global _indent_counters, _indent_timestamps

function _generic_indent (idx, delta) 
{
  ts = __indent_timestamp ()
  if (! _indent_counters[idx]) _indent_timestamps[idx] = ts

  # pre-increment for positive delta and post-decrement for negative delta
  x = _indent_counters[idx] + (delta > 0 ? delta : 0)
  _indent_counters[idx] += delta

  r = sprintf("%6d %s(%d):", (ts - _indent_timestamps[idx]),
                             execname(), tid())
  for (i=1; i<x; i++) r .= " "

  return r
}

function thread_indent (delta) 
{
  return _generic_indent (tid(), delta)  
}