add export config script
This commit is contained in:
Executable
+68
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/swift
|
||||
|
||||
import Foundation
|
||||
|
||||
func camelCaseToSnakeCase(_ string: Substring) -> String {
|
||||
var output = string.first?.lowercased() ?? ""
|
||||
|
||||
var previousCharacterWasUppercase = false
|
||||
|
||||
for character in string.dropFirst() {
|
||||
if character.isUppercase {
|
||||
if previousCharacterWasUppercase {
|
||||
output.append(character.lowercased())
|
||||
} else {
|
||||
output += "_\(character.lowercased())"
|
||||
previousCharacterWasUppercase = true
|
||||
}
|
||||
} else if character.isNumber {
|
||||
output += "_\(character)"
|
||||
|
||||
previousCharacterWasUppercase = false
|
||||
} else {
|
||||
output.append(character)
|
||||
|
||||
previousCharacterWasUppercase = false
|
||||
}
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
let defaultConfigPath = URL(filePath: "src/config/default.rs")
|
||||
|
||||
let lines = try String(contentsOf: defaultConfigPath, encoding: .utf8)
|
||||
.split(separator: "\n", omittingEmptySubsequences: false)
|
||||
.dropFirst(14)
|
||||
.dropLast(6)
|
||||
|
||||
precondition(lines.first!.contains("Mode::Normal"))
|
||||
|
||||
var mode: String?
|
||||
|
||||
for line in lines {
|
||||
if let match = line.wholeMatch(of: #/.*Mode::(?'mode'\w*),.*/#) {
|
||||
mode = match.output.mode.lowercased()
|
||||
} else if line.contains("None") {
|
||||
print("[\(mode!)]")
|
||||
} else if let match = line.wholeMatch(of: #/.*PartialAction::(?'partialAction'\w*).*/#) {
|
||||
let partialAction = match.output.partialAction.lowercased()
|
||||
print("[\(mode!).\(partialAction)]")
|
||||
} else if let match = line.wholeMatch(of: #/.*\(keypress\("(?'keypress'.*?)"\), (?'action'.*?)\.into\(\)\).*/#) {
|
||||
if match.output.keypress.contains(where: { !($0.isLetter || $0.isNumber) }) {
|
||||
print(
|
||||
"\"\(match.output.keypress)\"",
|
||||
"=",
|
||||
"\"\(camelCaseToSnakeCase(match.output.action))\""
|
||||
)
|
||||
} else {
|
||||
print(
|
||||
match.output.keypress,
|
||||
"=",
|
||||
"\"\(camelCaseToSnakeCase(match.output.action))\""
|
||||
)
|
||||
}
|
||||
} else {
|
||||
print()
|
||||
}
|
||||
}
|
||||
+18
-18
@@ -310,15 +310,15 @@ impl From<BufferAction> for &str {
|
||||
KeepPrimarySelection => "keep_primary_selection",
|
||||
RemovePrimarySelection => "remove_primary_selection",
|
||||
|
||||
SplitSelectionsInto1s => "split_selections_into_1_s",
|
||||
SplitSelectionsInto2s => "split_selections_into_2_s",
|
||||
SplitSelectionsInto3s => "split_selections_into_3_s",
|
||||
SplitSelectionsInto4s => "split_selections_into_4_s",
|
||||
SplitSelectionsInto5s => "split_selections_into_5_s",
|
||||
SplitSelectionsInto6s => "split_selections_into_6_s",
|
||||
SplitSelectionsInto7s => "split_selections_into_7_s",
|
||||
SplitSelectionsInto8s => "split_selections_into_8_s",
|
||||
SplitSelectionsInto9s => "split_selections_into_9_s",
|
||||
SplitSelectionsInto1s => "split_selections_into_1s",
|
||||
SplitSelectionsInto2s => "split_selections_into_2s",
|
||||
SplitSelectionsInto3s => "split_selections_into_3s",
|
||||
SplitSelectionsInto4s => "split_selections_into_4s",
|
||||
SplitSelectionsInto5s => "split_selections_into_5s",
|
||||
SplitSelectionsInto6s => "split_selections_into_6s",
|
||||
SplitSelectionsInto7s => "split_selections_into_7s",
|
||||
SplitSelectionsInto8s => "split_selections_into_8s",
|
||||
SplitSelectionsInto9s => "split_selections_into_9s",
|
||||
|
||||
JumpToSelectedOffset => "jump_to_selected_offset",
|
||||
JumpToSelectedOffsetRelativeToMark => "jump_to_selected_offset_relative_to_mark",
|
||||
@@ -393,15 +393,15 @@ impl TryFrom<&str> for BufferAction {
|
||||
"keep_primary_selection" => Ok(KeepPrimarySelection),
|
||||
"remove_primary_selection" => Ok(RemovePrimarySelection),
|
||||
|
||||
"split_selections_into_1_s" => Ok(SplitSelectionsInto1s),
|
||||
"split_selections_into_2_s" => Ok(SplitSelectionsInto2s),
|
||||
"split_selections_into_3_s" => Ok(SplitSelectionsInto3s),
|
||||
"split_selections_into_4_s" => Ok(SplitSelectionsInto4s),
|
||||
"split_selections_into_5_s" => Ok(SplitSelectionsInto5s),
|
||||
"split_selections_into_6_s" => Ok(SplitSelectionsInto6s),
|
||||
"split_selections_into_7_s" => Ok(SplitSelectionsInto7s),
|
||||
"split_selections_into_8_s" => Ok(SplitSelectionsInto8s),
|
||||
"split_selections_into_9_s" => Ok(SplitSelectionsInto9s),
|
||||
"split_selections_into_1s" => Ok(SplitSelectionsInto1s),
|
||||
"split_selections_into_2s" => Ok(SplitSelectionsInto2s),
|
||||
"split_selections_into_3s" => Ok(SplitSelectionsInto3s),
|
||||
"split_selections_into_4s" => Ok(SplitSelectionsInto4s),
|
||||
"split_selections_into_5s" => Ok(SplitSelectionsInto5s),
|
||||
"split_selections_into_6s" => Ok(SplitSelectionsInto6s),
|
||||
"split_selections_into_7s" => Ok(SplitSelectionsInto7s),
|
||||
"split_selections_into_8s" => Ok(SplitSelectionsInto8s),
|
||||
"split_selections_into_9s" => Ok(SplitSelectionsInto9s),
|
||||
|
||||
"jump_to_selected_offset" => Ok(JumpToSelectedOffset),
|
||||
"jump_to_selected_offset_relative_to_mark" => Ok(JumpToSelectedOffsetRelativeToMark),
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ pub struct Buffer {
|
||||
#[derive(Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum Mode {
|
||||
Normal, Select, Insert
|
||||
Normal, Select, // Insert
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -69,7 +69,7 @@ impl TryFrom<&str> for PartialAction {
|
||||
"replace" => Ok(Replace),
|
||||
"space" => Ok(Space),
|
||||
"repeat" => Ok(Repeat),
|
||||
"to" => Ok(Till),
|
||||
"till" => Ok(Till),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ impl Mode {
|
||||
match self {
|
||||
Self::Normal => " NORMAL ",
|
||||
Self::Select => " SELECT ",
|
||||
Self::Insert => " INSERT ",
|
||||
// Self::Insert => " INSERT ",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ impl Mode {
|
||||
match self {
|
||||
Self::Normal => Color::Blue,
|
||||
Self::Select => Color::Yellow,
|
||||
Self::Insert => Color::Green,
|
||||
// Self::Insert => Color::Green,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,9 @@ impl Default for Config {
|
||||
].into()),
|
||||
(Some(PartialAction::Space), [
|
||||
(keypress("w"), Save.into()),
|
||||
|
||||
(keypress("q"), QuitIfSaved.into()),
|
||||
(keypress("Q"), Quit.into()),
|
||||
].into()),
|
||||
(Some(PartialAction::Repeat), [
|
||||
(keypress("i"), MoveByteUp.into()),
|
||||
@@ -235,6 +238,9 @@ impl Default for Config {
|
||||
].into()),
|
||||
(Some(PartialAction::Space), [
|
||||
(keypress("w"), Save.into()),
|
||||
|
||||
(keypress("q"), QuitIfSaved.into()),
|
||||
(keypress("Q"), Quit.into()),
|
||||
].into()),
|
||||
(Some(PartialAction::Repeat), [
|
||||
(keypress("i"), ExtendByteUp.into()),
|
||||
|
||||
+6
-5
@@ -45,17 +45,18 @@ const BYTES_OF_PADDING: usize = LINES_OF_PADDING * BYTES_PER_LINE;
|
||||
// - inspector translations for varint
|
||||
// - repeated actions may only be cursor actions
|
||||
// - shouldn't crash
|
||||
// - gg/G in select mode
|
||||
// - gl/gj in select mode
|
||||
// - scrolling in select mode
|
||||
// - +/- to edit selected bytes by amount
|
||||
// - M mark at selected offset (like Jm)
|
||||
// - search
|
||||
// - ascii and bytes (`/` and `A-/`?)
|
||||
// - diffing
|
||||
// - doesn't have to be anything fancy, just compare each byte 1:1
|
||||
// - s/A-k/A-K
|
||||
// - sm select marks
|
||||
// - (not) sm select marks
|
||||
// - C-a/C-x
|
||||
// - +/- to edit selected bytes by amount ?
|
||||
// - operate on entire selection (u16/u32/etc)
|
||||
// - hex or decimal ?
|
||||
// - modifications
|
||||
// - insert/append
|
||||
// - mode
|
||||
@@ -65,8 +66,8 @@ const BYTES_OF_PADDING: usize = LINES_OF_PADDING * BYTES_PER_LINE;
|
||||
// - change
|
||||
// - edit character panel
|
||||
// - modifier on existing keys like teehee? or jump to panel?
|
||||
// - A-r replaces with ASCII ?
|
||||
// - if jump to panel, space?
|
||||
// - visual gg/G
|
||||
// - jumplist
|
||||
// - p
|
||||
// - [/] to cycle view offset?
|
||||
|
||||
Reference in New Issue
Block a user