Skip to content

Commit 30630d1

Browse files
committed
Update naming conventions
1 parent dd22b38 commit 30630d1

8 files changed

+36
-36
lines changed

buffer.nim

+4-4
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ proc guess_newline_style(text: seq[Rune]): NewlineStyle =
638638
result = style
639639
max_score = score
640640

641-
proc make_buffer*(): Buffer =
641+
proc new_buffer*(): Buffer =
642642
return Buffer(
643643
file_path: "",
644644
text: @[],
@@ -653,7 +653,7 @@ proc make_buffer*(): Buffer =
653653
newline_style: NewlineLf
654654
)
655655

656-
proc make_buffer*(path: string, lang: Language = nil): Buffer =
656+
proc new_buffer*(path: string, lang: Language = nil): Buffer =
657657
let
658658
text = to_runes(path.read_file())
659659
indent_style = text.guess_indent_style()
@@ -677,6 +677,6 @@ proc make_buffer*(path: string, lang: Language = nil): Buffer =
677677
newline_style: newline_style
678678
)
679679

680-
proc make_buffer*(path: string, langs: seq[Language]): Buffer =
680+
proc new_buffer*(path: string, langs: seq[Language]): Buffer =
681681
let lang = langs.detect_language(path)
682-
return make_buffer(path, lang = lang)
682+
return new_buffer(path, lang = lang)

calc.nim

+5-5
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ type
296296
selected: int
297297
scroll: Index2d
298298

299-
proc make_input(app: App): Input =
299+
proc init_input(app: App): Input =
300300
return Input(entry: make_entry(app.copy_buffer), output: nil)
301301

302-
proc make_input(calc: Calc): Input = calc.app.make_input()
302+
proc init_input(calc: Calc): Input = calc.app.init_input()
303303

304304
proc max_input_number_width(calc: Calc): int =
305305
($calc.inputs.len).len + 2
@@ -320,7 +320,7 @@ method process_mouse*(calc: Calc, mouse: Mouse): bool =
320320
method process_key*(calc: Calc, key: Key) =
321321
case key.kind:
322322
of KeyReturn:
323-
calc.inputs.insert(calc.make_input(), calc.selected + 1)
323+
calc.inputs.insert(calc.init_input(), calc.selected + 1)
324324
calc.selected += 1
325325
of KeyArrowDown:
326326
calc.selected += 1
@@ -373,5 +373,5 @@ method render*(calc: Calc, box: Box, ren: var TermRenderer) =
373373
ren.move_to(box.min.x + calc.max_input_number_width + 1, box.min.y + it * 3 + 2)
374374
ren.put($input.output)
375375

376-
proc make_calc*(app: App): Window =
377-
return Calc(app: app, inputs: @[app.make_input()])
376+
proc new_calc*(app: App): Window =
377+
return Calc(app: app, inputs: @[app.init_input()])

editor.nim

+7-7
Original file line numberDiff line numberDiff line change
@@ -588,15 +588,15 @@ proc insert(editor: Editor, str: seq[Rune]) =
588588

589589
proc load_file(editor: Editor, path: string) =
590590
editor.buffer.unregister_hook(editor.cursor_hook_id)
591-
editor.buffer = editor.app.make_buffer(path)
591+
editor.buffer = editor.app.new_buffer(path)
592592
editor.cursor_hook_id = editor.buffer.register_hook(editor.make_cursor_hook())
593593
editor.hide_prompt()
594594
editor.cursors = @[Cursor(kind: CursorInsert, pos: 0)]
595595
editor.autocompleter = editor.app.get_autocompleter(editor.buffer.language)
596596

597597
proc new_buffer(editor: Editor) =
598598
editor.buffer.unregister_hook(editor.cursor_hook_id)
599-
editor.buffer = make_buffer()
599+
editor.buffer = new_buffer()
600600
editor.cursor_hook_id = editor.buffer.register_hook(editor.make_cursor_hook())
601601
editor.hide_prompt()
602602
editor.cursors = @[Cursor(kind: CursorInsert, pos: 0)]
@@ -1489,7 +1489,7 @@ method render(editor: Editor, box: Box, ren: var TermRenderer) =
14891489
method close*(editor: Editor) =
14901490
editor.buffer.unregister_hook(editor.cursor_hook_id)
14911491

1492-
proc make_editor*(app: App, buffer: Buffer): Editor =
1492+
proc new_editor*(app: App, buffer: Buffer): Editor =
14931493
result = Editor(
14941494
buffer: buffer,
14951495
scroll: Index2d(x: 0, y: 0),
@@ -1499,8 +1499,8 @@ proc make_editor*(app: App, buffer: Buffer): Editor =
14991499
result.cursor_hook_id = result.buffer.register_hook(result.make_cursor_hook())
15001500
result.autocompleter = app.get_autocompleter(result.buffer.language)
15011501

1502-
proc make_editor*(app: App): Window =
1503-
make_editor(app, make_buffer())
1502+
proc new_editor*(app: App): Window =
1503+
new_editor(app, new_buffer())
15041504

1505-
proc make_editor*(app: App, path: string): Window =
1506-
make_editor(app, app.make_buffer(path))
1505+
proc new_editor*(app: App, path: string): Window =
1506+
new_editor(app, app.new_buffer(path))

file_manager.nim

+3-3
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ method process_mouse(file_manager: FileManager, mouse: Mouse): bool =
120120
case item.kind:
121121
of ItemDir: file_manager.open(item.path)
122122
of ItemFile:
123-
let editor = file_manager.app.make_editor(item.path)
123+
let editor = file_manager.app.new_editor(item.path)
124124
file_manager.app.root_pane.open_window(editor)
125125
else: discard
126126

@@ -142,7 +142,7 @@ method process_key(file_manager: FileManager, key: Key) =
142142
file_manager.mode = Mode(kind: ModeNone)
143143
file_manager.open(item.path)
144144
of ItemFile:
145-
file_manager.app.root_pane.open_window(file_manager.app.make_editor(item.path))
145+
file_manager.app.root_pane.open_window(file_manager.app.new_editor(item.path))
146146
else: discard
147147
of KeyArrowUp, KeyArrowDown:
148148
file_manager.list.process_key(key)
@@ -209,7 +209,7 @@ method render(file_manager: FileManager, box: Box, ren: var TermRenderer) =
209209
ren.move_to(box.min + Index2d(x: sidebar_text.len + 1, y: 1))
210210
file_manager.mode.search_entry.render(ren)
211211

212-
proc make_file_manager*(app: App): Window =
212+
proc new_file_manager*(app: App): Window =
213213
let file_manager = FileManager(app: app)
214214
file_manager.open(get_current_dir())
215215
return file_manager

keyinfo.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@ method list_commands(key_info: KeyInfo): seq[Command] =
7676
)
7777
]
7878

79-
proc make_key_info*(app: App): Window =
79+
proc new_key_info*(app: App): Window =
8080
return KeyInfo(app: app, events: @[])

log_viewer.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,5 @@ method render(viewer: Viewer, box: Box, ren: var TermRenderer) =
130130
y += 1
131131
it += 1
132132

133-
proc make_log_viewer*(app: App): Window =
133+
proc new_log_viewer*(app: App): Window =
134134
Viewer(app: app, attach_end: true)

main.nim

+8-8
Original file line numberDiff line numberDiff line change
@@ -102,24 +102,24 @@ var
102102
)
103103
]
104104
window_constructors = @[
105-
make_window_constructor("Editor", make_editor),
106-
make_window_constructor("File Manager", make_file_manager),
107-
make_window_constructor("Calc", make_calc),
108-
make_window_constructor("Keyinfo", make_keyinfo),
109-
make_window_constructor("Log Viewer", make_log_viewer)
105+
init_window_constructor("Editor", new_editor),
106+
init_window_constructor("File Manager", new_file_manager),
107+
init_window_constructor("Calc", new_calc),
108+
init_window_constructor("Keyinfo", new_keyinfo),
109+
init_window_constructor("Log Viewer", new_log_viewer)
110110
]
111111

112112
var
113113
app = make_app(languages, window_constructors)
114-
root_pane = Pane(kind: PaneWindow, window: app.make_editor())
114+
root_pane = Pane(kind: PaneWindow, window: app.new_editor())
115115

116116
if param_count() > 0:
117117
root_pane = Pane(kind: PaneWindow,
118-
window: app.make_editor(param_str(1).absolute_path(get_current_dir()))
118+
window: app.new_editor(param_str(1).absolute_path(get_current_dir()))
119119
)
120120
for it in 2..param_count():
121121
var pane = Pane(kind: PaneWindow,
122-
window: app.make_editor(param_str(it).absolute_path(get_current_dir()))
122+
window: app.new_editor(param_str(it).absolute_path(get_current_dir()))
123123
)
124124
root_pane = Pane(kind: PaneSplitH, factor: (it - 1) / it, pane_a: root_pane, pane_b: pane)
125125

window_manager.nim

+7-7
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ method close*(window: Window) {.base.} = discard
7272
method list_commands*(window: Window): seq[Command] {.base.} = discard
7373

7474
# Launcher
75-
proc make_launcher(app: App): Window =
75+
proc new_launcher(app: App): Window =
7676
return Launcher(app: app, list: make_list(app.window_constructors.map(c => c.name)))
7777

7878
proc open_window*(pane: Pane, window: Window)
@@ -113,7 +113,7 @@ method render(launcher: Launcher, box: Box, ren: var TermRenderer) =
113113
proc make_window*(app: App): Window =
114114
return app.window_constructors[0].make(app)
115115

116-
proc make_window_constructor*(name: string, make: proc (app: App): Window): WindowConstructor =
116+
proc init_window_constructor*(name: string, make: proc (app: App): Window): WindowConstructor =
117117
WindowConstructor(name: name, make: make)
118118

119119
# Command Search
@@ -144,7 +144,7 @@ proc update_list(cmd_search: CommandSearch) =
144144
if cmd_search.list.selected < 0:
145145
cmd_search.list.selected = 0
146146

147-
proc make_command_search(app: App, prev_window: Window): Window =
147+
proc new_command_search(app: App, prev_window: Window): Window =
148148
let cmd_search = CommandSearch(
149149
app: app,
150150
prev_window: prev_window,
@@ -436,10 +436,10 @@ proc render*(pane: Pane, ren: var TermRenderer) =
436436

437437
# App
438438
proc open_launcher(app: App) =
439-
app.root_pane.open_window(app.make_launcher())
439+
app.root_pane.open_window(app.new_launcher())
440440

441441
proc open_command_search(app: App) =
442-
app.root_pane.open_window(app.make_command_search(app.root_pane.active_window()))
442+
app.root_pane.open_window(app.new_command_search(app.root_pane.active_window()))
443443

444444
proc make_app*(languages: seq[Language], window_constructors: seq[WindowConstructor]): owned App =
445445
for it, lang in languages.pairs:
@@ -465,10 +465,10 @@ proc get_autocompleter*(app: App, language: Language): Autocompleter =
465465
app.autocompleters[language.id] = autocompleter
466466
return app.autocompleters[language.id]
467467

468-
proc make_buffer*(app: App, path: string): Buffer =
468+
proc new_buffer*(app: App, path: string): Buffer =
469469
if app.buffers.has_key(path):
470470
return app.buffers[path]
471-
result = make_buffer(path, app.languages)
471+
result = new_buffer(path, app.languages)
472472
app.buffers[path] = result
473473

474474
let comp = app.get_autocompleter(result.language)

0 commit comments

Comments
 (0)