From e70a2a5817586e4e7df0ee1446f609bbd859164a Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 19 Mar 2015 01:59:14 +0900 Subject: Add support for ANSI color codes --- src/util/util.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/util/util.go') diff --git a/src/util/util.go b/src/util/util.go index 14833c04..1f53cc76 100644 --- a/src/util/util.go +++ b/src/util/util.go @@ -27,6 +27,17 @@ func Max32(first int32, second int32) int32 { return second } +// Constrain32 limits the given 32-bit integer with the upper and lower bounds +func Constrain32(val int32, min int32, max int32) int32 { + if val < min { + return min + } + if val > max { + return max + } + return val +} + // Constrain limits the given integer with the upper and lower bounds func Constrain(val int, min int, max int) int { if val < min { -- cgit v1.2.3