ok
This commit is contained in:
14
src/app.rs
14
src/app.rs
@@ -20,6 +20,8 @@ use crate::state::{
|
||||
};
|
||||
use crate::views::doc_view;
|
||||
|
||||
const STEPS_PER_PAGE: usize = 32;
|
||||
|
||||
pub struct App {
|
||||
pub project_state: ProjectState,
|
||||
pub ui: UiState,
|
||||
@@ -148,8 +150,10 @@ impl App {
|
||||
|
||||
pub fn step_up(&mut self) {
|
||||
let len = self.current_edit_pattern().length;
|
||||
let num_rows = len.div_ceil(8);
|
||||
let steps_per_row = len.div_ceil(num_rows);
|
||||
let page_start = (self.editor_ctx.step / STEPS_PER_PAGE) * STEPS_PER_PAGE;
|
||||
let steps_on_page = (page_start + STEPS_PER_PAGE).min(len) - page_start;
|
||||
let num_rows = steps_on_page.div_ceil(8);
|
||||
let steps_per_row = steps_on_page.div_ceil(num_rows);
|
||||
|
||||
if self.editor_ctx.step >= steps_per_row {
|
||||
self.editor_ctx.step -= steps_per_row;
|
||||
@@ -161,8 +165,10 @@ impl App {
|
||||
|
||||
pub fn step_down(&mut self) {
|
||||
let len = self.current_edit_pattern().length;
|
||||
let num_rows = len.div_ceil(8);
|
||||
let steps_per_row = len.div_ceil(num_rows);
|
||||
let page_start = (self.editor_ctx.step / STEPS_PER_PAGE) * STEPS_PER_PAGE;
|
||||
let steps_on_page = (page_start + STEPS_PER_PAGE).min(len) - page_start;
|
||||
let num_rows = steps_on_page.div_ceil(8);
|
||||
let steps_per_row = steps_on_page.div_ceil(num_rows);
|
||||
|
||||
self.editor_ctx.step = (self.editor_ctx.step + steps_per_row) % len;
|
||||
self.load_step_to_editor();
|
||||
|
||||
Reference in New Issue
Block a user