mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-24 11:37:32 +03:00
GH-428 Adapt to new
This commit is contained in:
parent
927f7718c6
commit
2dd3659329
@ -219,7 +219,7 @@ static void server_ui_mouse_off(UI *ui __unused) {
|
||||
[_neovim_server sendMessageWithId:NeoVimServerMsgIdMouseOff];
|
||||
}
|
||||
|
||||
static void server_ui_cursor_style_set(UI *ui __unused, Dictionary cursor_shapes __unused) {
|
||||
static void server_ui_mode_info_set(UI *ui __unused, bool enabled __unused, Array cursor_styles __unused) {
|
||||
// yet noop
|
||||
}
|
||||
|
||||
@ -413,7 +413,7 @@ void custom_ui_start(void) {
|
||||
ui->busy_stop = server_ui_busy_stop;
|
||||
ui->mouse_on = server_ui_mouse_on;
|
||||
ui->mouse_off = server_ui_mouse_off;
|
||||
ui->cursor_style_set = server_ui_cursor_style_set;
|
||||
ui->mode_info_set = server_ui_mode_info_set;
|
||||
ui->mode_change = server_ui_mode_change;
|
||||
ui->set_scroll_region = server_ui_set_scroll_region;
|
||||
ui->scroll = server_ui_scroll;
|
||||
@ -542,7 +542,7 @@ static void work_and_write_data_sync(void **argv, work_block block) {
|
||||
static NSString *escaped_filename(NSString *filename) {
|
||||
const char *file_system_rep = filename.fileSystemRepresentation;
|
||||
|
||||
char_u *escaped_filename = vim_strsave_fnameescape((char_u *) file_system_rep, 0);
|
||||
char *escaped_filename = vim_strsave_fnameescape(file_system_rep, 0);
|
||||
NSString *result = [NSString stringWithCString:(const char *) escaped_filename encoding:NSUTF8StringEncoding];
|
||||
xfree(escaped_filename);
|
||||
|
||||
|
@ -486,7 +486,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
|
||||
case NeoVimServerMsgIdModeChange: {
|
||||
int *values = data_to_int_array(data, 1);
|
||||
[_bridge modeChange:(Mode) values[0]];
|
||||
[_bridge modeChange:(CursorModeShape) values[0]];
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -8,14 +8,27 @@
|
||||
#import "NeoVimAutoCommandEvent.generated.h"
|
||||
|
||||
|
||||
// Keep in sync with the constants in vim.h
|
||||
typedef NS_ENUM(NSUInteger, Mode) {
|
||||
Normal = 0x01,
|
||||
Visual = 0x02,
|
||||
Cmdline = 0x08,
|
||||
Insert = 0x10,
|
||||
Replace = 0x50,
|
||||
Term = 0x2000,
|
||||
// Keep in sync with ModeShape enum in cursor_shape.h.
|
||||
typedef NS_ENUM(NSUInteger, CursorModeShape) {
|
||||
CursorModeShapeNormal = 0,
|
||||
CursorModeShapeVisual = 1,
|
||||
CursorModeShapeInsert = 2,
|
||||
CursorModeShapeReplace = 3,
|
||||
CursorModeShapeCmdline = 4,
|
||||
CursorModeShapeCmdlineInsert = 5,
|
||||
CursorModeShapeCmdlineReplace = 6,
|
||||
CursorModeShapeOperatorPending = 7,
|
||||
CursorModeShapeVisualExclusive = 8,
|
||||
CursorModeShapeOnCmdline = 9,
|
||||
CursorModeShapeOnStatusLine = 10,
|
||||
CursorModeShapeDraggingStatusLine = 11,
|
||||
CursorModeShapeOnVerticalSepLine = 12,
|
||||
CursorModeShapeDraggingVerticalSepLine = 13,
|
||||
CursorModeShapeMore = 14,
|
||||
CursorModeShapeMoreLastLine = 15,
|
||||
CursorModeShapeShowingMatchingParen = 16,
|
||||
CursorModeShapeTermFocus = 17,
|
||||
CursorModeShapeCount = 18,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, FontTrait) {
|
||||
@ -80,7 +93,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/**
|
||||
* Mode changed to mode, cf vim.h.
|
||||
*/
|
||||
- (void)modeChange:(Mode)mode;
|
||||
- (void)modeChange:(CursorModeShape)mode;
|
||||
|
||||
- (void)setScrollRegionToTop:(int)top bottom:(int)bottom left:(int)left right:(int)right;
|
||||
- (void)scroll:(int)count;
|
||||
|
@ -38,7 +38,7 @@ public class NeoVimView: NSView, NeoVimUiBridgeProtocol, NSUserInterfaceValidati
|
||||
public let uuid = UUID().uuidString
|
||||
public weak var delegate: NeoVimViewDelegate?
|
||||
|
||||
public fileprivate(set) var mode = Mode.Normal
|
||||
public fileprivate(set) var mode = CursorModeShape.normal
|
||||
|
||||
public var usesLigatures = false {
|
||||
didSet {
|
||||
@ -360,7 +360,7 @@ extension NeoVimView {
|
||||
|
||||
/**
|
||||
Does the following
|
||||
- `Mode.Normal`: `:command<CR>`
|
||||
- normal mode: `:command<CR>`
|
||||
- else: `:<Esc>:command<CR>`
|
||||
|
||||
We don't use NeoVimAgent.vimCommand because if we do for example "e /some/file" and its swap file already exists,
|
||||
@ -368,7 +368,7 @@ extension NeoVimView {
|
||||
*/
|
||||
fileprivate func exec(command cmd: String) {
|
||||
switch self.mode {
|
||||
case .Normal:
|
||||
case .normal:
|
||||
self.agent.vimInput(":\(cmd)<CR>")
|
||||
default:
|
||||
self.agent.vimInput("<Esc>:\(cmd)<CR>")
|
||||
@ -537,7 +537,7 @@ extension NeoVimView {
|
||||
}
|
||||
|
||||
fileprivate func cursorRegion() -> Region {
|
||||
let cursorPosition = self.mode == .Cmdline ? self.grid.putPosition : self.grid.screenCursor
|
||||
let cursorPosition = self.mode == .cmdline ? self.grid.putPosition : self.grid.screenCursor
|
||||
// NSLog("\(#function): \(cursorPosition)")
|
||||
|
||||
let saneRow = max(0, min(cursorPosition.row, self.grid.size.height - 1))
|
||||
@ -560,7 +560,7 @@ extension NeoVimView {
|
||||
let cursorRow = cursorRegion.top
|
||||
let cursorColumnStart = cursorRegion.left
|
||||
|
||||
if self.mode == .Insert {
|
||||
if self.mode == .insert {
|
||||
ColorUtils.colorIgnoringAlpha(self.grid.foreground).withAlphaComponent(0.75).set()
|
||||
var cursorRect = self.cellRectFor(row: cursorRow, column: cursorColumnStart)
|
||||
cursorRect.size.width = 2
|
||||
@ -691,11 +691,11 @@ extension NeoVimView {
|
||||
extension NeoVimView {
|
||||
|
||||
public func validateUserInterfaceItem(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
||||
let canUndoOrRedo = self.mode == .Insert || self.mode == .Replace || self.mode == .Normal || self.mode == .Visual
|
||||
let canCopyOrCut = self.mode == .Normal || self.mode == .Visual
|
||||
let canUndoOrRedo = self.mode == .insert || self.mode == .replace || self.mode == .normal || self.mode == .visual
|
||||
let canCopyOrCut = self.mode == .normal || self.mode == .visual
|
||||
let canPaste = self.pasteboard.string(forType: NSPasteboardTypeString) != nil
|
||||
let canDelete = self.mode == .Visual || self.mode == .Normal
|
||||
let canSelectAll = self.mode == .Insert || self.mode == .Replace || self.mode == .Normal || self.mode == .Visual
|
||||
let canDelete = self.mode == .visual || self.mode == .normal
|
||||
let canSelectAll = self.mode == .insert || self.mode == .replace || self.mode == .normal || self.mode == .visual
|
||||
|
||||
guard let action = item.action else {
|
||||
return true
|
||||
@ -723,9 +723,9 @@ extension NeoVimView {
|
||||
|
||||
@IBAction func undo(_ sender: AnyObject?) {
|
||||
switch self.mode {
|
||||
case .Insert, .Replace:
|
||||
case .insert, .replace:
|
||||
self.agent.vimInput("<Esc>ui")
|
||||
case .Normal, .Visual:
|
||||
case .normal, .visual:
|
||||
self.agent.vimInput("u")
|
||||
default:
|
||||
return
|
||||
@ -734,9 +734,9 @@ extension NeoVimView {
|
||||
|
||||
@IBAction func redo(_ sender: AnyObject?) {
|
||||
switch self.mode {
|
||||
case .Insert, .Replace:
|
||||
case .insert, .replace:
|
||||
self.agent.vimInput("<Esc><C-r>i")
|
||||
case .Normal, .Visual:
|
||||
case .normal, .visual:
|
||||
self.agent.vimInput("<C-r>")
|
||||
default:
|
||||
return
|
||||
@ -745,7 +745,7 @@ extension NeoVimView {
|
||||
|
||||
@IBAction func cut(_ sender: AnyObject?) {
|
||||
switch self.mode {
|
||||
case .Visual, .Normal:
|
||||
case .visual, .normal:
|
||||
self.agent.vimInput("\"+d")
|
||||
default:
|
||||
return
|
||||
@ -754,7 +754,7 @@ extension NeoVimView {
|
||||
|
||||
@IBAction func copy(_ sender: AnyObject?) {
|
||||
switch self.mode {
|
||||
case .Visual, .Normal:
|
||||
case .visual, .normal:
|
||||
self.agent.vimInput("\"+y")
|
||||
default:
|
||||
return
|
||||
@ -766,7 +766,7 @@ extension NeoVimView {
|
||||
return
|
||||
}
|
||||
|
||||
if self.mode == .Cmdline || self.mode == .Replace || self.mode == .Term {
|
||||
if self.mode == .cmdline || self.mode == .replace || self.mode == .termFocus {
|
||||
self.agent.vimInput(self.vimPlainString(content))
|
||||
return
|
||||
}
|
||||
@ -788,9 +788,9 @@ extension NeoVimView {
|
||||
let resetPasteModeCmd = pasteModeSet ? ":set nopaste<CR>" : ""
|
||||
|
||||
switch self.mode {
|
||||
case .Insert:
|
||||
case .insert:
|
||||
self.agent.vimInput("<ESC>\"+p\(resetPasteModeCmd)a")
|
||||
case .Normal, .Visual:
|
||||
case .normal, .visual:
|
||||
self.agent.vimInput("\"+p\(resetPasteModeCmd)")
|
||||
default:
|
||||
return
|
||||
@ -799,7 +799,7 @@ extension NeoVimView {
|
||||
|
||||
@IBAction func delete(_ sender: AnyObject?) {
|
||||
switch self.mode {
|
||||
case .Normal, .Visual:
|
||||
case .normal, .visual:
|
||||
self.agent.vimInput("x")
|
||||
default:
|
||||
return
|
||||
@ -808,7 +808,7 @@ extension NeoVimView {
|
||||
|
||||
@IBAction public override func selectAll(_ sender: Any?) {
|
||||
switch self.mode {
|
||||
case .Insert, .Visual:
|
||||
case .insert, .visual:
|
||||
self.agent.vimInput("<Esc>ggVG")
|
||||
default:
|
||||
self.agent.vimInput("ggVG")
|
||||
@ -1332,7 +1332,7 @@ extension NeoVimView {
|
||||
public func mouseOff() {
|
||||
}
|
||||
|
||||
public func modeChange(_ mode: Mode) {
|
||||
public func modeChange(_ mode: CursorModeShape) {
|
||||
// NSLog("mode changed to: %02x", mode.rawValue)
|
||||
self.mode = mode
|
||||
}
|
||||
@ -1533,7 +1533,7 @@ extension NeoVimView {
|
||||
}
|
||||
|
||||
fileprivate func updateCursorWhenPutting(currentPosition curPos: Position, screenCursor: Position) {
|
||||
if self.mode == .Cmdline {
|
||||
if self.mode == .cmdline {
|
||||
// When the cursor is in the command line, then we need this...
|
||||
self.markForRender(cellPosition: self.grid.previousCellPosition(curPos))
|
||||
self.markForRender(cellPosition: self.grid.nextCellPosition(curPos))
|
||||
|
2
neovim
2
neovim
@ -1 +1 @@
|
||||
Subproject commit 0f551e4b2403572142c80ec891c8fb281fbdb226
|
||||
Subproject commit 72e878400d8d21e03246d28da359b142d3404918
|
Loading…
Reference in New Issue
Block a user