// Copyright 2016 Viacheslav Chimishuk <vchimishuk@yandex.ru>//// This file is part of Chub.//// Chub is free software: you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation, either version 3 of the License, or// (at your option) any later version.//// Chub is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with Chub. If not, see <http://www.gnu.org/licenses/>.package cue// stringTruncateMaybe truncates string up to newLen characters if string truncation// is enabled.// If given string is shorter than newLen if will be returned without any changes.func (sheet *Sheet) stringTruncateMaybe(str string, newLen int) string { if len(str) > newLen && (sheet.flags&FlagTruncateStrings) != 0 { return str[:newLen] } return str}
// Copyright 2016 Viacheslav Chimishuk <vchimishuk@yandex.ru>
//
// This file is part of Chub.
//
// Chub is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Chub is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Chub. If not, see <http://www.gnu.org/licenses/>.
package cue
// stringTruncateMaybe truncates string up to newLen characters if string truncation
// is enabled.
// If given string is shorter than newLen if will be returned without any changes.
func (sheet *Sheet) stringTruncateMaybe(str string, newLen int) string {
if len(str) > newLen && (sheet.flags&FlagTruncateStrings) != 0 {
return str[:newLen]
}
return str
}