# 程式設計(一) HW0205
## 5. Tmux is a Terminal Multiplexer
:::danger
BTW, you CAN’T use any type of array in this problem
:::
Our TA G36 is a DevOps specialist. While configuring a new machine cluster using the terminal, he noticed that a single command line can only handle one operation at a time unless the task is sent to the background.
G36 is enthusiastic about tmux because it allows him to SSH into the machine, perform multiple tasks simultaneously, and avoid connection timeouts.

*Figure 5.1: A tmux window with 3 panes*
Tmux is an open-source terminal multiplexer for Unix-like operating systems. It allows multiple terminal sessions to be accessed simultaneously in a single window, which is useful for running more than one command-line program at a time.
Each terminal inside tmux belongs to a pane, which is a rectangular area that displays the terminal’s contents. Multiple panes can appear within a single window, and each window is made up of one or more panes that cover its entire area.
Today, G36 wants to complete a task using tmux in a situation where multiple tasks need to be handled. Help him resize the panes into an equal layout and execute the final job on the machine:
Use `fastfetch` to print the Arch Linux logo, because he uses Arch BTW.

*Figure 5.2: A tmux window with a complex pane layout*
### Example:

*Figure 5.3: tast case 1*
```=
$ ./hw0205
please input the window size (width)x(height): 45x12
please input the total pane number: 4
please input the pane for the job (0=all,-1=none): -1
$ │$
│
│
│
│
──────────────────────┼──────────────────────
$ │$
│
│
│
│
[0] 0:bash*
```
### Explanation
Your task is to display a window with multiple panes, equally dividing the window into panes of the same size. Each pane should be separated by box-drawing characters from Unicode.
For each pane, print a single character `$` to represent the shell. At the bottom of the window, print `[0] 0:bash*` at the bottom left with black text on a green background.
You should divide the panes to fill the window, allowing only a one-character difference in height and width per pane.
The number of panes should be arranged in a near-square layout, allowing only one pane to differ in height and width when handling extra panes.
You don't need to worry about commands that fill all the space in a line; this is not a test case.
### Handling Extra Panes:
- If the number of extra panes is **less than or equal to** the number of panes in the width, display them at the bottom from left to right. These panes don’t need to be divided; the last one can be larger and take up extra space.(see testcase2)
- If the number of extra panes is **greater than** the number of panes in the width, increase the number of panes per row by 1, then resize and display them at the bottom from left to right.(see testcase3)
- Note that when increasing the number of panes per row or column, they should be resized to maintain a uniform appearance, allowing only a one-character difference.
### Task: Print the Arch Linux Logo
In the specified pane, print the Arch Linux logo using `fastfetch`. For simplicity, the logo is redesigned to contain only `/`, `\`, and `o`, forming a triangle with a smaller empty triangle with 1/3 size inside.
You should automatically resize the logo’s height and width to fit within the pane after printing `fastfetch`. The bottleneck can determine the size.
The logo should be printed in Arch Linux’s Curious Blue (Hex: #1793d1, RGB: 23, 147, 209).
```=
$ fastfetch
/\
/oo\
/oooo\
/oooooo\
/oooooooo\
/oooooooooo\
/ooooo/\ooooo\
/ooooo/ \ooooo\
/ooooo/ \ooooo\
```
### Examples:

*Figure 5.4: tast case 2*
```=
$ ./hw0205
please input the window size (width)x(height): 45x15
please input the total pane number: 5
please input the pane for the job (0=all,-1=none): 1
$ fastfetch │$
/\ │
/oo\ │
/o/\o\ │
──────────────────────┼──────────────────────
$ │$
│
│
│
──────────────────────┴──────────────────────
$
[0] 0:bash*
```

*Figure 5.3: tast case 3*
```=
$ ./hw0205
please input the window size (width)x(height): 65x15
please input the total pane number: 8
please input the pane for the job (0=all,-1=none): 7
$ │$ │$
│ │
│ │
│ │
─────────────────────┼─────────────────────┼─────────────────────
$ │$ │$
│ │
│ │
│ │
─────────────────────┼─────────────────────┴─────────────────────
$ fastfetch │$
/\ │
/oo\ │
/o/\o\ │
[0] 0:bash*
```
## Box-drawing characters
─ (U+2500) Box Drawings Light Horizontal
│ (U+2502) Box Drawings Light Vertical
┌ (U+250C) Box Drawings Light Down and Right
┐ (U+2510) Box Drawings Light Down and Left
└ (U+2514) Box Drawings Light Up and Right
┘ (U+2518) Box Drawings Light Up and Left
├ (U+251C) Box Drawings Light Vertical and Right
┤ (U+2524) Box Drawings Light Vertical and Left
┬ (U+252C) Box Drawings Light Down and Horizontal
┴ (U+2534) Box Drawings Light Up and Horizontal
┼ (U+253C) Box Drawings Light Vertical and Horizontal
## reference
[Wikipedia:tmux (EN)](https://en.wikipedia.org/wiki/Tmux)
[tmux(1)-linux manual page](https://man7.org/linux/man-pages/man1/tmux.1.html)
[Box-drawing characters (Unicode)](https://zh.wikipedia.org/zh-tw/%E8%A3%BD%E8%A1%A8%E7%AC%A6_(Unicode%E5%8D%80%E6%AE%B5))
[fastfetch](https://github.com/fastfetch-cli/fastfetch)