valepakh commented on code in PR #7420: URL: https://github.com/apache/ignite-3/pull/7420#discussion_r2707894088
########## modules/cli/src/main/java/org/apache/ignite/internal/cli/util/TableTruncator.java: ########## @@ -0,0 +1,255 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.cli.util; + +import static org.apache.ignite.internal.cli.decorators.TruncationConfig.ELLIPSIS; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.apache.ignite.internal.cli.decorators.TruncationConfig; +import org.apache.ignite.internal.cli.sql.table.Table; + +/** + * Truncates table columns to fit terminal width. + */ +public class TableTruncator { + /** Minimum column width to display at least ellipsis. */ + private static final int MIN_COLUMN_WIDTH = ELLIPSIS.length(); + + /** + * Per-column overhead in FlipTables: space before + space after + separator. + * Example: " value │" = 3 chars overhead per column. + */ + private static final int BORDER_OVERHEAD_PER_COLUMN = 3; + + /** + * Fixed table border overhead. + * Total overhead formula: 3*N where N is column count. + * Per-column overhead includes: left padding (1) + right padding (1) + border/separator (1) = 3. + * The borders at table edges are already counted in per-column overhead. Review Comment: It's unclear how left border for example is included in these calculations. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
