-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from tvnova-ogs/development
Development
- Loading branch information
Showing
18 changed files
with
617 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { join } from "https://deno.land/[email protected]/path/mod.ts"; | ||
import { join } from "https://deno.land/[email protected]/path/mod.ts"; | ||
import { Color, Style } from "../lib/packages/deno-ascii-office/mod.ts"; | ||
|
||
|
||
const name = 'pkg.bundled.js'; | ||
|
@@ -13,8 +14,8 @@ const cmd = [ | |
]; | ||
|
||
console.log("\n"); | ||
console.log(`Bundle to %c${path}`, "font-weight: bold;"); | ||
console.log(`%c> ${cmd.join(' ')}`, "color: grey"); | ||
console.log(Style.bold(`Bundle to %c${path}`)); | ||
console.log(Color.gray(`> ${cmd.join(' ')}`)); | ||
|
||
const process = await Deno.run({ | ||
cmd: cmd, | ||
|
@@ -24,14 +25,13 @@ const process = await Deno.run({ | |
|
||
const { success } = await process.status(); | ||
|
||
|
||
if (success) { | ||
console.log(`%c> Succeed`, "color: grey"); | ||
console.log(Color.gray(`> Succeed`)); | ||
} else { | ||
const outputBytes = await process.stderrOutput() | ||
const output = (new TextDecoder()).decode(outputBytes); | ||
console.log(`%c> Failed`, "color: grey"); | ||
console.log(`%c>> ${output}`, "color: grey"); | ||
console.log(Color.gray(`> Failed`)); | ||
console.log(Color.gray(`>> ${output}`)); | ||
} | ||
|
||
console.log("\n"); | ||
console.log("\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { join } from "https://deno.land/[email protected]/path/mod.ts"; | ||
import { join } from "https://deno.land/[email protected]/path/mod.ts"; | ||
import { Color, Style } from "../lib/packages/deno-ascii-office/mod.ts"; | ||
|
||
|
||
const name = (os => { | ||
|
@@ -25,18 +26,22 @@ const cmd = [ | |
]; | ||
|
||
console.log("\n"); | ||
console.log(`Compile to %c${path}`, "font-weight: bold;"); | ||
console.log(`%c> ${cmd.join(' ')}`, "color: grey"); | ||
console.log(Style.bold(`Compile to %c${path}`)); | ||
console.log(Color.gray(`> ${cmd.join(' ')}`)); | ||
|
||
const process = await Deno.run({ | ||
cmd: cmd, | ||
stdout: 'piped', | ||
stderr: 'piped', | ||
}) | ||
|
||
|
||
const { success } = await process.status(); | ||
|
||
if (success) console.log(`%c> Succeed`, "color: grey"); | ||
else console.log(`%c> Failed`, "color: grey"); | ||
if (success) { | ||
console.log(Color.gray(`> Succeed`)); | ||
} else { | ||
console.log(Color.gray(`> Failed`)); | ||
} | ||
|
||
console.log("\n"); | ||
console.log("\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export const exists = async (path: string): Promise<boolean> => { | ||
try { | ||
await Deno.stat(path); | ||
|
||
return true; | ||
} catch (error) { | ||
if (error instanceof Deno.errors.NotFound) return false; | ||
else throw error; | ||
} | ||
}; | ||
|
||
|
||
export const existsSync = (path: string): boolean => { | ||
try { | ||
Deno.statSync(path); | ||
|
||
return true; | ||
} catch (error) { | ||
if (error instanceof Deno.errors.NotFound) return false; | ||
else throw error; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"deno.enable": true, | ||
"deno.lint": true, | ||
"deno.unstable": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Deno Run", | ||
"type": "shell", | ||
"command": "deno run ./main.ts", | ||
"group": "build", | ||
"problemMatcher": "$deno", | ||
"options": { | ||
"cwd": "${cwd}", | ||
} | ||
}, | ||
{ | ||
"label": "Deno Run (Demo)", | ||
"type": "shell", | ||
"command": "deno run ./demo.ts", | ||
"group": "build", | ||
"problemMatcher": "$deno", | ||
"options": { | ||
"cwd": "${cwd}", | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## Správné renderování | ||
|
||
Pro správné renderování nastavte ve **VS Code** nasledující hodnoty: | ||
|
||
Code → Preferences → Settings | ||
|
||
```json | ||
// Place your settings in this file to overwrite the default settings | ||
{ | ||
// ... | ||
"terminal.integrated.gpuAcceleration": "on", | ||
// ... | ||
} | ||
``` | ||
|
||
|
||
|
||
|
||
## Ukázka | ||
|
||
Pro ukázku spusťte demo: | ||
``` | ||
deno run ./demo.ts | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
Box, | ||
progress, | ||
Table, | ||
Style, | ||
Color, | ||
Formattable, | ||
} from "./mod.ts"; | ||
|
||
|
||
function h(content: string): void { | ||
console.log(`\n\n${content}:\n`); | ||
} | ||
|
||
|
||
function p(content: string): void { | ||
console.log(`${content}`); | ||
} | ||
|
||
|
||
h("Progress"); | ||
p(progress(25, 100)); | ||
p(progress(5, 100)); | ||
p(progress(100, 100)); | ||
|
||
|
||
h("Tables"); | ||
p(Table.classic([ | ||
['Jméno', 'Jan\nEvangelista'], | ||
['Příjmení', 'Purkyně'], | ||
['Věk', 81], | ||
])); | ||
|
||
p(Table.classic([ | ||
[ | ||
new Formattable('R', (s) => Style.bold(Color.red(s))), | ||
new Formattable('G', (s) => Style.bold(Color.green(s))), | ||
new Formattable('B', (s) => Style.bold(Color.blue(s))), | ||
], | ||
])); | ||
|
||
|
||
h("Boxes"); | ||
p(Box.classic('Box')); | ||
p(Box.bold('Bold')); | ||
p(Box.dashed('Dashed')); | ||
p(Box.rounded('Rounded')); | ||
p(Box.double('Double')); | ||
p(Box.pretty('Pretty')); | ||
p(Box.classic(new Formattable('Červená', (s) => Color.red(s)))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { Formattable } from "./model/Formattable.ts"; | ||
|
||
|
||
type PartsType = { | ||
left: string, | ||
right: string, | ||
top: string, | ||
bottom: string, | ||
corner1: string, | ||
corner2: string, | ||
corner3: string, | ||
corner4: string, | ||
} | ||
|
||
|
||
export function custom(text: Formattable | string, parts: PartsType): string { | ||
const regex = { | ||
lineSpliter: /\n/g | ||
} | ||
|
||
const result: string[] = []; | ||
|
||
const lines: (Formattable | string)[] = text.split(regex.lineSpliter); | ||
const length = lines.reduce((v, l) => l.length > v ? l.length : v, 0); | ||
|
||
lines.forEach((s, i, arr) => { | ||
// First | ||
if (i == 0) { | ||
result.push(`${parts.corner1}${Array(length + 1).join(parts.top)}${parts.corner2}`); | ||
} | ||
|
||
result.push(`${parts.left}${s.toString()}${Array(length - s.length + 1).join(' ')}${parts.right}`); | ||
|
||
// Last | ||
if (arr.length - 1 == i) { | ||
result.push(`${parts.corner4}${Array(length + 1).join(parts.bottom)}${parts.corner3}`); | ||
} | ||
}); | ||
|
||
return result.join('\n'); | ||
} | ||
|
||
|
||
export function classic(text: Formattable | string): string { | ||
return custom(text, { | ||
left: '│ ', | ||
right: ' │', | ||
top: '─', | ||
bottom: '─', | ||
corner1: '┌─', | ||
corner2: '─┐', | ||
corner3: '─┘', | ||
corner4: '└─', | ||
}); | ||
} | ||
|
||
|
||
export function bold(text: Formattable | string): string { | ||
return custom(text, { | ||
left: '┃ ', | ||
right: ' ┃', | ||
top: '━', | ||
bottom: '━', | ||
corner1: '┏━', | ||
corner2: '━┓', | ||
corner3: '━┛', | ||
corner4: '┗━', | ||
}); | ||
} | ||
|
||
|
||
export function dashed(text: Formattable | string): string { | ||
return custom(text, { | ||
left: '╎ ', | ||
right: ' ╎', | ||
top: '╌', | ||
bottom: '╌', | ||
corner1: '┌╌', | ||
corner2: '╌┐', | ||
corner3: '╌┘', | ||
corner4: '└╌', | ||
}); | ||
} | ||
|
||
|
||
export function rounded(text: Formattable | string): string { | ||
return custom(text, { | ||
left: '│ ', | ||
right: ' │', | ||
top: '─', | ||
bottom: '─', | ||
corner1: '╭─', | ||
corner2: '─╮', | ||
corner3: '─╯', | ||
corner4: '╰─', | ||
}); | ||
} | ||
|
||
|
||
export function double(text: Formattable | string): string { | ||
return custom(text, { | ||
left: '║ ', | ||
right: ' ║', | ||
top: '═', | ||
bottom: '═', | ||
corner1: '╔═', | ||
corner2: '═╗', | ||
corner3: '═╝', | ||
corner4: '╚═', | ||
}); | ||
} | ||
|
||
|
||
export function pretty(text: Formattable | string): string { | ||
return custom(text, { | ||
left: '│ ', | ||
right: ' ┃', | ||
top: '─', | ||
bottom: '━', | ||
corner1: '┌─', | ||
corner2: '─┒', | ||
corner3: '━┛', | ||
corner4: '┕━', | ||
}); | ||
} |
Oops, something went wrong.