Skip to content

Commit

Permalink
Fix fn setRaw not found err on Deno v1.35.1
Browse files Browse the repository at this point in the history
function `Deno.setRaw(rid, mod)` is not implemented on Deno v1.35.1,
rewrite insted of `Deno.stdin.setRaw(boolean b)`
c.f. denoland/deno#3958
  • Loading branch information
sheepla committed Jul 16, 2023
1 parent 7b7464d commit 4378ed7
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/run.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
get_config,
make_config,
config_example,
CONFIG_PATH,
get_config,
make_config,
} from "./config.ts";
import {
generate_string_array,
call_rain,
concat_nums,
generate_string_array,
make_time,
make_UTCtime,
concat_nums,
} from "./time.ts";

export enum Kind {
Expand Down Expand Up @@ -51,7 +51,7 @@ export const run = async (kind: Kind) => {
return { start_x, start_y };
};

let { columns, rows } = Deno.consoleSize(Deno.stdout.rid);
let { columns, rows } = Deno.consoleSize();
let { start_x, start_y } = timer_point(rows, columns);

let rain: string[] = [];
Expand Down Expand Up @@ -95,7 +95,8 @@ export const run = async (kind: Kind) => {
}
};

Deno.setRaw(Deno.stdin.rid, true); //Enter raw mode
//Deno.setRaw(Deno.stdin.rid, true); //Enter raw mode
Deno.stdin.setRaw(true);
Deno.stdout.writeSync(NEW_SCREEN); //Enter new screen
Deno.stdout.writeSync(HIDE_CURSOR); //Hide cursor

Expand All @@ -108,7 +109,7 @@ export const run = async (kind: Kind) => {
Deno.addSignalListener("SIGWINCH", () => {
const old_rows = rows;

({ columns, rows } = Deno.consoleSize(Deno.stdout.rid));
({ columns, rows } = Deno.consoleSize());
({ start_x, start_y } = timer_point(rows, columns));

// Fall new rain to keep previous raindrops surrounded the timer text.
Expand All @@ -129,6 +130,7 @@ export const run = async (kind: Kind) => {
clearInterval(interval_rainID);
Deno.stdout.writeSync(SHOW_CURSOR); //Show cursor
Deno.stdout.writeSync(RESTORE_SCREEN); //Restore main screen
Deno.setRaw(Deno.stdin.rid, false); //Exit raw mode
Deno.stdin.setRaw(false);

return;
};

0 comments on commit 4378ed7

Please sign in to comment.