New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

akf-code

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

akf-code - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

a.py

47

index.js
#!/usr/bin/env node
const { resolve, extname } = require("path"),
{ exec } = require("child_process"),
fs = require("fs"),
brackets = require("./brackets.json"),
langs = require("./config.json"),
table = str => `╔${"═".repeat(str.length + 2)}╗\n║ ${str} ║\n╚${"═".repeat(str.length + 2)}╝`
const readline = require("readline");
const fs = require("fs");
const path = require("path");
const table = str => `╔${"═".repeat(str.length + 2)}╗\n║ ${str} ║\n╚${"═".repeat(str.length + 2)}╝`;
const fileName = process.argv[2] || "untitled.txt",
dirName = resolve(process.cwd(), fileName),
lang = langs[extname(fileName)] || null;
const fileName = process.argv[2] || "untitled.txt";
const dirName = path.resolve(process.cwd(), fileName);
let file = fs.existsSync(dirName) ? fs.readFileSync(dirName, "utf8").replace(/\r/i).split(/\n/) : [""];
readline.emitKeypressEvents(process.stdin);
require("readline").emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);

@@ -27,2 +29,15 @@

else if (key.name === "r" && lang.run)
return exec(lang.run + " " + fileName, (e, std, err) => {
if (e) console.error("Error!");
if (err) console.error("stderr:\n", err);
if (std) console.log("stdout:\n", std);
});
else if (key.name === "c")

@@ -75,5 +90,7 @@ return process.exit(0);

default:
console.log(ch)
if (!ch) break;
file[curY] = file[curY].substring(0, curX) + ch + file[curY].substring(curX);
file[curY] = file[curY].substring(0, curX) + ch + (lang.bracket && brackets[ch] ? brackets[ch] : "") + file[curY].substring(curX);
curX++; render(); break;

@@ -87,9 +104,9 @@

const lines = file.map((l, i) => i + " │ " + l)
const lines = file.map((l, i) => i + " ".repeat(Math.abs(String(i).length - 4)) + "│ " + l)
console.log(`${table(`akf-code - ${fileName} | ${curY}:${curX}`)}\n${[
...lines.slice(0, curY + 1),
"──┤ " + " ".repeat(curX) + "^",
...lines.slice(curY + 1)
].join("\n")}\nExit: CTRL + C | Save: CTRL + S`);
console.log(`${table(`akf-code - ${dirName} | ${curY}:${curX}`)}\n${[
...lines.slice(0, curY + 1),
"────┤ " + " ".repeat(curX) + "^",
...lines.slice(curY + 1)
].join("\n")}\nExit: CTRL + C | Save: CTRL + S | Run if supported: CTRL + R`);

@@ -96,0 +113,0 @@ }

{
"name": "akf-code",
"version": "0.0.6",
"version": "0.0.7",
"description": "A CLI code editor",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,2 +10,3 @@ # akf-code

- `Ctrl+S`: To save!
- `Ctrl+R`: To run!

@@ -19,2 +20,3 @@ ## Features

- Cursorline
- For some languages bracket, run support!

@@ -27,4 +29,5 @@ ## TO-DOS

- [x] Cursorline
- [x] Colorize
## GIF:
![WindowsTerminal_NcdhYil3Gi](https://user-images.githubusercontent.com/70021050/168694809-8066f14d-5b46-48a1-b971-b0db5e7a7437.gif)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc