-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
308 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ pub mod esc; | |
pub mod delete; | ||
pub mod undo; | ||
pub mod append; | ||
pub mod print; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use std::any::Any; | ||
|
||
use crate::command::base::Command; | ||
use crate::data::LineRange; | ||
use crate::editor::Editor; | ||
use crate::generic_error::GenericResult; | ||
|
||
pub struct PrintCommand { | ||
pub line_range: LineRange | ||
} | ||
|
||
impl Command for PrintCommand { | ||
fn execute(&mut self, editor: &mut Editor) -> GenericResult<()> { | ||
// TODO: Implement PrintCommand | ||
log::info!("PrintCommand execute"); | ||
Ok(()) | ||
} | ||
|
||
fn as_any(&self) -> &dyn Any { | ||
self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#[derive(Debug, PartialEq, Clone)] | ||
pub enum TokenType { | ||
Colon, | ||
Command, | ||
Option, | ||
Number, | ||
Symbol, | ||
Pattern, | ||
AddressPattern, | ||
Replacement, | ||
Filename, | ||
Separator, | ||
EndOfInput, | ||
Illegal, | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct Token { | ||
pub token_type: TokenType, | ||
pub lexeme: String, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Clone)] | ||
pub struct Pattern { | ||
pub pattern: String, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Clone)] | ||
pub enum SimpleLineAddressType { | ||
LineNumber(usize), | ||
CurrentLine, | ||
FirstLine, | ||
LastLine, | ||
AllLines, | ||
Pattern(Pattern) | ||
} | ||
|
||
#[derive(Debug, PartialEq, Clone)] | ||
pub enum LineAddressType { | ||
Absolute(SimpleLineAddressType), | ||
Relative(SimpleLineAddressType, isize), | ||
} | ||
|
||
#[derive(Debug, PartialEq, Clone)] | ||
pub struct LineRange { | ||
pub start: LineAddressType, | ||
pub end: LineAddressType, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.