fixed width of header column and times on issue list
This commit is contained in:
parent
d767df3088
commit
f6a1572e92
15
src/tui.ts
15
src/tui.ts
|
|
@ -966,8 +966,8 @@ export class TuiEngine {
|
|||
const createdWidth = 12;
|
||||
const commentsWidth = 6;
|
||||
const timeWidth = 7;
|
||||
// Title takes all remaining space
|
||||
const titleWidth = Math.max(20, cols - idWidth - typeWidth - stateWidth - authorWidth - createdWidth - commentsWidth - timeWidth - 9);
|
||||
// Title takes all remaining space. There are 8 columns + 9 borders + 8 spaces = 17 extra chars
|
||||
const titleWidth = Math.max(10, cols - idWidth - typeWidth - stateWidth - authorWidth - createdWidth - commentsWidth - timeWidth - 17);
|
||||
|
||||
// Render Table Header
|
||||
const padHeader = (title: string, w: number) => chalk.bold.white(title.padEnd(w));
|
||||
|
|
@ -1120,9 +1120,16 @@ export class TuiEngine {
|
|||
const labels = issue.labels.map(l => chalk.bgHex('#' + l.color).black(` ${l.name} `)).join(' ');
|
||||
const timeStr = formatTime(issue.total_tracked_time);
|
||||
|
||||
console.log(borderCh + ` State: ${stateLabel} Author: ${chalk.cyan(issue.user.login)} Created: ${formatDate(issue.created_at)} Updated: ${formatDate(issue.updated_at)} Time: ${chalk.yellow(timeStr)}`.padEnd(cols - 2 + (issue.state === 'open' ? 10 : 9) + 10 + 10) + borderCh);
|
||||
const metaLine = ` State: ${stateLabel} Author: ${chalk.cyan(issue.user.login)} Created: ${formatDate(issue.created_at)} Updated: ${formatDate(issue.updated_at)} Time: ${chalk.yellow(timeStr)}`;
|
||||
const metaPlainLen = stripAnsi(metaLine).length;
|
||||
const padding = Math.max(0, cols - 2 - metaPlainLen);
|
||||
console.log(borderCh + metaLine + ' '.repeat(padding) + borderCh);
|
||||
|
||||
if (labels) {
|
||||
console.log(borderCh + ` Labels: ${labels}`.padEnd(cols - 2 + labels.length - issue.labels.map(l=>l.name.length + 10).reduce((a,b)=>a+b, 0)) + borderCh); // offset for raw ANSI chars
|
||||
const labelsLine = ` Labels: ${labels}`;
|
||||
const labelsPlainLen = stripAnsi(labelsLine).length;
|
||||
const labelsPadding = Math.max(0, cols - 2 - labelsPlainLen);
|
||||
console.log(borderCh + labelsLine + ' '.repeat(labelsPadding) + borderCh);
|
||||
}
|
||||
console.log(chalk.bold.hex('#4A90E2')('├' + '─'.repeat(cols - 2) + '┤'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
const cols = 100;
|
||||
const idWidth = 6;
|
||||
const typeWidth = 5;
|
||||
const stateWidth = 7;
|
||||
const authorWidth = 14;
|
||||
const createdWidth = 12;
|
||||
const commentsWidth = 6;
|
||||
const timeWidth = 7;
|
||||
|
||||
// Old
|
||||
const oldTitleWidth = cols - idWidth - typeWidth - stateWidth - authorWidth - createdWidth - commentsWidth - 8;
|
||||
const oldTotal = 1 + (1+idWidth+1) + (1+typeWidth+1) + (1+stateWidth+1) + (1+oldTitleWidth+1) + (1+authorWidth+1) + (1+createdWidth+1) + (1+commentsWidth+1);
|
||||
console.log('Old total:', oldTotal, 'cols:', cols);
|
||||
|
||||
// New
|
||||
const newTitleWidth = cols - idWidth - typeWidth - stateWidth - authorWidth - createdWidth - commentsWidth - timeWidth - 9;
|
||||
const newTotal = 1 + (1+idWidth+1) + (1+typeWidth+1) + (1+stateWidth+1) + (1+newTitleWidth+1) + (1+authorWidth+1) + (1+createdWidth+1) + (1+commentsWidth+1) + (1+timeWidth+1);
|
||||
console.log('New total:', newTotal, 'cols:', cols);
|
||||
Loading…
Reference in New Issue