mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
working multiline selection, added unit test recording to editor-ideas
This commit is contained in:
parent
7a70c95bb4
commit
81412786db
2 changed files with 88 additions and 17 deletions
|
@ -78,7 +78,20 @@ These are potentially inspirational resources for the editor's design.
|
||||||
* Add latest datetime package to dependencies.
|
* Add latest datetime package to dependencies.
|
||||||
* Generate unit test for this function.
|
* Generate unit test for this function.
|
||||||
* Show edit history for this function.
|
* Show edit history for this function.
|
||||||
|
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
* From Google Docs' comments, adding tests in a similar manner, where they exists in the same "document" but parallel to the code being written
|
||||||
|
* Makes sense for unit tests, keeps the test close to the source
|
||||||
|
* Doesn't necessarily make sense for integration or e2e testing
|
||||||
|
* Maybe easier to manually trigger a test related to exactly what code you're writing
|
||||||
|
* Ability to generate unit tests for a selected function in context menu
|
||||||
|
* A table should appear to enter input and expected output pairs quickly
|
||||||
|
* Ability to "record" unit tests
|
||||||
|
* Select a function to record.
|
||||||
|
* Do a normal run, and save the input and output of the selected function.
|
||||||
|
* Generate a unit test with that input-output pair
|
||||||
|
|
||||||
|
|
||||||
## General Thoughts/Ideas
|
## General Thoughts/Ideas
|
||||||
|
@ -86,12 +99,6 @@ These are potentially inspirational resources for the editor's design.
|
||||||
Thoughts and ideas possibly taken from above inspirations or separate.
|
Thoughts and ideas possibly taken from above inspirations or separate.
|
||||||
|
|
||||||
* ACCESSIBILITY!!!
|
* ACCESSIBILITY!!!
|
||||||
* From Google Docs' comments, adding tests in a similar manner, where they exists in the same "document" but parallel to the code being written
|
|
||||||
* Makes sense for unit tests, keeps the test close to the source
|
|
||||||
* Doesn't necessarily make sense for integration or e2e testing
|
|
||||||
* Maybe easier to manually trigger a test related to exactly what code you're writing
|
|
||||||
* Ability to generate unit tests for a selected function in context menu
|
|
||||||
* A table should appear to enter input and expected output pairs quickly
|
|
||||||
* Ability to show import connection within project visually
|
* Ability to show import connection within project visually
|
||||||
* This could be done by drawing connections between files or functions in the tree view. This would make it easier for people to get their bearings in new big projects.
|
* This could be done by drawing connections between files or functions in the tree view. This would make it easier for people to get their bearings in new big projects.
|
||||||
* Connections could also be drawn between functions that call each other in the tree view. The connections could be animated to show the execution flow of the program.
|
* Connections could also be drawn between functions that call each other in the tree view. The connections could be animated to show the execution flow of the program.
|
||||||
|
|
|
@ -112,7 +112,7 @@ fn run_event_loop() -> Result<(), Box<dyn Error>> {
|
||||||
let mut glyph_brush = build_glyph_brush(&gpu_device, render_format)?;
|
let mut glyph_brush = build_glyph_brush(&gpu_device, render_format)?;
|
||||||
|
|
||||||
let is_animating = true;
|
let is_animating = true;
|
||||||
let mut text_state = "".to_owned();//String::new();
|
let mut text_state = "aaaaaaaaa\nbbbbbbbbbb\ncccccccccc\ndddddddddd\neeeeeee\nffffffff\ngggggggg".to_owned();//String::new();
|
||||||
let mut keyboard_modifiers = ModifiersState::empty();
|
let mut keyboard_modifiers = ModifiersState::empty();
|
||||||
|
|
||||||
// Render loop
|
// Render loop
|
||||||
|
@ -206,7 +206,7 @@ fn run_event_loop() -> Result<(), Box<dyn Error>> {
|
||||||
&mut glyph_brush,
|
&mut glyph_brush,
|
||||||
);
|
);
|
||||||
|
|
||||||
let selection_rects_res = create_selection_rects(1, 10, 2, 10, &glyph_bounds_rects);
|
let selection_rects_res = create_selection_rects(1, 5, 4, 2, &glyph_bounds_rects);
|
||||||
|
|
||||||
match selection_rects_res {
|
match selection_rects_res {
|
||||||
Ok(selection_rects) =>
|
Ok(selection_rects) =>
|
||||||
|
@ -270,9 +270,9 @@ fn run_event_loop() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
|
|
||||||
fn create_selection_rects(
|
fn create_selection_rects(
|
||||||
start_line: usize,
|
start_line_indx: usize,
|
||||||
pos_in_start_line: usize,
|
pos_in_start_line: usize,
|
||||||
stop_line: usize,
|
stop_line_indx: usize,
|
||||||
pos_in_stop_line: usize,
|
pos_in_stop_line: usize,
|
||||||
glyph_bound_rects: &Vec<Vec<Rect>>
|
glyph_bound_rects: &Vec<Vec<Rect>>
|
||||||
) -> Result<Vec<Rect>, OutOfBounds> {
|
) -> Result<Vec<Rect>, OutOfBounds> {
|
||||||
|
@ -280,17 +280,17 @@ fn create_selection_rects(
|
||||||
|
|
||||||
let mut all_rects = Vec::new();
|
let mut all_rects = Vec::new();
|
||||||
|
|
||||||
if start_line == stop_line {
|
if start_line_indx == stop_line_indx {
|
||||||
let start_glyph_rect =
|
let start_glyph_rect =
|
||||||
get_res(
|
get_res(
|
||||||
pos_in_start_line,
|
pos_in_start_line,
|
||||||
get_res(start_line, glyph_bound_rects)?
|
get_res(start_line_indx, glyph_bound_rects)?
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let stop_glyph_rect =
|
let stop_glyph_rect =
|
||||||
get_res(
|
get_res(
|
||||||
pos_in_stop_line,
|
pos_in_stop_line,
|
||||||
get_res(stop_line, glyph_bound_rects)?
|
get_res(stop_line_indx, glyph_bound_rects)?
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let top_left_coords =
|
let top_left_coords =
|
||||||
|
@ -310,7 +310,8 @@ fn create_selection_rects(
|
||||||
|
|
||||||
Ok(all_rects)
|
Ok(all_rects)
|
||||||
} else {
|
} else {
|
||||||
let start_line = get_res(start_line, glyph_bound_rects)?;
|
// first line
|
||||||
|
let start_line = get_res(start_line_indx, glyph_bound_rects)?;
|
||||||
|
|
||||||
let start_glyph_rect =
|
let start_glyph_rect =
|
||||||
get_res(
|
get_res(
|
||||||
|
@ -318,7 +319,7 @@ fn create_selection_rects(
|
||||||
start_line
|
start_line
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let stop_glyph_rect =
|
let start_line_last_glyph_rect =
|
||||||
get_res(
|
get_res(
|
||||||
start_line.len() - 1,
|
start_line.len() - 1,
|
||||||
start_line
|
start_line
|
||||||
|
@ -328,7 +329,7 @@ fn create_selection_rects(
|
||||||
start_glyph_rect.top_left_coords;
|
start_glyph_rect.top_left_coords;
|
||||||
|
|
||||||
let height = start_glyph_rect.height;
|
let height = start_glyph_rect.height;
|
||||||
let width = (stop_glyph_rect.top_left_coords.x - start_glyph_rect.top_left_coords.x) + stop_glyph_rect.width;
|
let width = (start_line_last_glyph_rect.top_left_coords.x - start_glyph_rect.top_left_coords.x) + start_line_last_glyph_rect.width;
|
||||||
|
|
||||||
all_rects.push(
|
all_rects.push(
|
||||||
Rect {
|
Rect {
|
||||||
|
@ -339,7 +340,70 @@ fn create_selection_rects(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
//TODO loop rects if necessary and stop line rect
|
//middle lines
|
||||||
|
let nr_mid_lines = (stop_line_indx - start_line_indx) - 1;
|
||||||
|
let first_mid_line = start_line_indx + 1;
|
||||||
|
|
||||||
|
for i in first_mid_line..(first_mid_line + nr_mid_lines) {
|
||||||
|
let mid_line = get_res(i, glyph_bound_rects)?;
|
||||||
|
|
||||||
|
let mid_line_first_glyph_rect =
|
||||||
|
get_res(
|
||||||
|
0,
|
||||||
|
mid_line
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let mid_line_last_glyph_rect =
|
||||||
|
get_res(
|
||||||
|
mid_line.len() - 1,
|
||||||
|
mid_line
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let top_left_coords =
|
||||||
|
mid_line_first_glyph_rect.top_left_coords;
|
||||||
|
|
||||||
|
let height = mid_line_first_glyph_rect.height;
|
||||||
|
let width = (mid_line_last_glyph_rect.top_left_coords.x - mid_line_first_glyph_rect.top_left_coords.x) + mid_line_last_glyph_rect.width;
|
||||||
|
|
||||||
|
all_rects.push(
|
||||||
|
Rect {
|
||||||
|
top_left_coords,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
color: colors::WHITE
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//last line
|
||||||
|
let stop_line = get_res(stop_line_indx, glyph_bound_rects)?;
|
||||||
|
|
||||||
|
let stop_line_first_glyph_rect =
|
||||||
|
get_res(
|
||||||
|
0,
|
||||||
|
stop_line
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let stop_glyph_rect =
|
||||||
|
get_res(
|
||||||
|
pos_in_stop_line,
|
||||||
|
stop_line
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let top_left_coords =
|
||||||
|
stop_line_first_glyph_rect.top_left_coords;
|
||||||
|
|
||||||
|
let height = stop_glyph_rect.height;
|
||||||
|
let width = (stop_glyph_rect.top_left_coords.x - stop_line_first_glyph_rect.top_left_coords.x) + stop_glyph_rect.width;
|
||||||
|
|
||||||
|
all_rects.push(
|
||||||
|
Rect {
|
||||||
|
top_left_coords,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
color: colors::WHITE
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
Ok(all_rects)
|
Ok(all_rects)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue