Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repl #68

Draft
wants to merge 15 commits into
base: develop
Choose a base branch
from
Draft

Repl #68

wants to merge 15 commits into from

Conversation

nixpulvis
Copy link
Owner

@nixpulvis nixpulvis commented Apr 22, 2023

Specifically, this does not look to implement everything in #48, though I do hope to get completion working in a somewhat basic state before I move on to making things line up for the modern language. It's worth thinking about how this influences the design though.

The primary goal of this PR is to reintegrate the REPL module and start solidifying it. Unfortunately that means we are back to dealing with #20 which this reverts the partial fix for in a PR it should never have landed in to begin with: #51.

fixes #42
reopens #20

let (width, _height) = termion::terminal_size().unwrap();
let padding = 5;
let columns = width / (max_length + padding);
let mut tw = TabWriter::new(writer).padding(padding as usize);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to ditch this albeit neat method of table generation and go for something that will produce better results in our case.

Issues at the moment:

  • Sort order is inconsistent with expectation
  • Every column is treated as if it was as wide as the widest

@nixpulvis nixpulvis added F: completion The completion default feature. M: repl Module: Our own Read Eval Print Loop, like `readline` L: design Designs, ideas and questions with tangible goals labels Apr 22, 2023
Don't forget to print a newline in the middle of a row still.
Proper error handling is always the topc of a good Rust engineer, right?
}
println!();
print!("{}{}",
termion::cursor::Left(1000), // XXX
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth fixing this now?


prompt::ps1(&mut context.stdout);
}

pub fn insert(context: &mut ActionContext, c: char) {
if let Ok((x, y)) = context.stdout.cursor_pos() {
// XXX: Why did this panic?
let i = (x - context.prompt_length) as usize;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth looking into this again for a bit.

@@ -20,7 +20,7 @@ maintenance = { status = "experimental" }
travis-ci = { repository = "https://github.com/nixpulvis/oursh" }

[features]
default = ["raw", "shebang-block"]
default = ["raw", "history", "completion", "shebang-block"]

# TODO: Justify and explain features.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As always, I think documentation will mark the end of the PR.

Generally in a collaborative environment (which this is currently not), I like this, writing a summary gives people time to review as well as giving future developers the needed information.

@@ -134,9 +136,10 @@ pub fn executable_completions(text: &str) -> Completion {
0 => Completion::None,
1 => Completion::Complete(matches.remove(0)),
_ => {
// TODO: Support POSIX style lexicographical order?
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm torn on this, as am I torn on row major vs column major order.

let columns = width / (max_length + padding);
let mut tw = TabWriter::new(writer).padding(padding as usize);
// TODO: Determine table width/height and calculate iteration better
let mut _row = 0;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave a note here about what we are planning on using row for.

@@ -20,12 +20,12 @@ impl History {
return;
}

// HACK: There's got to be a cleaner way.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@nixpulvis
Copy link
Owner Author

First pass review done.

Overall, I think the only big open question is how to decouple Runtime from the repl and if we want to block this PR on that work.

Also, as usual, error handling could be better.

@nixpulvis nixpulvis requested a review from jenrzzz April 22, 2023 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: completion The completion default feature. L: design Designs, ideas and questions with tangible goals M: repl Module: Our own Read Eval Print Loop, like `readline`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Format completion possibilities in columns
1 participant