mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-07 15:37:14 +02:00
Remove FEAT_MBYTE from MacVim code as Vim is deprecating them
This commit is contained in:
+1
-56
@@ -926,13 +926,9 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
if (txtfield && [dialogReturn count] > 1) {
|
||||
NSString *retString = [dialogReturn objectAtIndex:1];
|
||||
char_u *ret = (char_u*)[retString UTF8String];
|
||||
#ifdef FEAT_MBYTE
|
||||
ret = CONVERT_FROM_UTF8(ret);
|
||||
#endif
|
||||
vim_strncpy((char_u*)txtfield, ret, IOSIZE - 1);
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_FROM_UTF8_FREE(ret);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1350,25 +1346,17 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
NSString *eval = nil;
|
||||
char_u *s = (char_u*)[expr UTF8String];
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
s = CONVERT_FROM_UTF8(s);
|
||||
#endif
|
||||
|
||||
char_u *res = eval_client_expr_to_string(s);
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_FROM_UTF8_FREE(s);
|
||||
#endif
|
||||
|
||||
if (res != NULL) {
|
||||
s = res;
|
||||
#ifdef FEAT_MBYTE
|
||||
s = CONVERT_TO_UTF8(s);
|
||||
#endif
|
||||
eval = [NSString stringWithUTF8String:(char*)s];
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_TO_UTF8_FREE(s);
|
||||
#endif
|
||||
vim_free(res);
|
||||
}
|
||||
|
||||
@@ -1400,7 +1388,6 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
|
||||
// TODO: Avoid overflow.
|
||||
int len = (int)llen;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (output_conv.vc_type != CONV_NONE) {
|
||||
char_u *conv_str = string_convert(&output_conv, str, &len);
|
||||
if (conv_str) {
|
||||
@@ -1408,7 +1395,6 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
str = conv_str;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
NSString *string = [[NSString alloc]
|
||||
initWithBytes:str length:len encoding:NSUTF8StringEncoding];
|
||||
@@ -1526,13 +1512,9 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
if (!conn) {
|
||||
if (!silent) {
|
||||
char_u *s = (char_u*)[name UTF8String];
|
||||
#ifdef FEAT_MBYTE
|
||||
s = CONVERT_FROM_UTF8(s);
|
||||
#endif
|
||||
semsg(_(e_noserver), s);
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_FROM_UTF8_FREE(s);
|
||||
#endif
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
@@ -2143,14 +2125,12 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
if ([self handleSpecialKey:key keyCode:code modifiers:mods])
|
||||
return;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u *conv_str = NULL;
|
||||
if (input_conv.vc_type != CONV_NONE) {
|
||||
conv_str = string_convert(&input_conv, str, &len);
|
||||
if (conv_str)
|
||||
str = conv_str;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mods & MOD_MASK_CMD) {
|
||||
// NOTE: For normal input (non-special, 'macmeta' off) the modifier
|
||||
@@ -2195,10 +2175,8 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (conv_str)
|
||||
vim_free(conv_str);
|
||||
#endif
|
||||
}
|
||||
|
||||
- (BOOL)handleSpecialKey:(NSString *)key
|
||||
@@ -2230,9 +2208,7 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
chars[2] = K_THIRD(ikey);
|
||||
len = 3;
|
||||
} else if (mods & MOD_MASK_ALT && special_keys[i].vim_code1 == 0
|
||||
#ifdef FEAT_MBYTE
|
||||
&& !enc_dbcs // TODO: ? (taken from gui_gtk_x11.c)
|
||||
#endif
|
||||
) {
|
||||
ASLogDebug(@"Alt special=%d", ikey);
|
||||
|
||||
@@ -2242,7 +2218,6 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
// The following code was gleaned from gui_gtk_x11.c.
|
||||
mods &= ~MOD_MASK_ALT;
|
||||
int mkey = 0x80 | ikey;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8) { // TODO: What about other encodings?
|
||||
// Convert to utf-8
|
||||
chars[0] = (mkey >> 6) + 0xc0;
|
||||
@@ -2256,7 +2231,6 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
len = 2;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
chars[0] = mkey;
|
||||
len = 1;
|
||||
@@ -2308,7 +2282,7 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
}
|
||||
|
||||
string[len++] = ch;
|
||||
#ifdef FEAT_MBYTE
|
||||
|
||||
// TODO: What if 'enc' is not "utf-8"?
|
||||
if (enc_utf8 && (ch & 0x80)) { // convert to utf-8
|
||||
string[len++] = ch & 0xbf;
|
||||
@@ -2318,7 +2292,6 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
string[len++] = (int)KE_CSI;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
add_to_input_buf(string, len);
|
||||
return YES;
|
||||
@@ -2492,12 +2465,10 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
ws = (char_u*)[wname UTF8String];
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
s = CONVERT_FROM_UTF8(s);
|
||||
if (ws) {
|
||||
ws = CONVERT_FROM_UTF8(ws);
|
||||
}
|
||||
#endif
|
||||
|
||||
set_option_value((char_u*)"guifont", 0, s, 0);
|
||||
|
||||
@@ -2508,12 +2479,10 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
set_option_value((char_u*)"guifontwide", 0, ws, 0);
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (ws) {
|
||||
CONVERT_FROM_UTF8_FREE(ws);
|
||||
}
|
||||
CONVERT_FROM_UTF8_FREE(s);
|
||||
#endif
|
||||
|
||||
[self redrawScreen];
|
||||
}
|
||||
@@ -2584,15 +2553,11 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
|
||||
len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
|
||||
char_u *s = (char_u*)[string UTF8String];
|
||||
#ifdef FEAT_MBYTE
|
||||
if (input_conv.vc_type != CONV_NONE)
|
||||
s = string_convert(&input_conv, s, &len);
|
||||
#endif
|
||||
dnd_yank_drag_data(s, len);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (input_conv.vc_type != CONV_NONE)
|
||||
vim_free(s);
|
||||
#endif
|
||||
add_to_input_buf(dropkey, sizeof(dropkey));
|
||||
#endif // FEAT_DND
|
||||
}
|
||||
@@ -3326,13 +3291,9 @@ static id vimToCocoa(typval_T * tv, int depth)
|
||||
if (!val) {
|
||||
result = [NSString string];
|
||||
} else {
|
||||
#ifdef FEAT_MBYTE
|
||||
val = CONVERT_TO_UTF8(val);
|
||||
#endif
|
||||
result = [NSString stringWithUTF8String:(char*)val];
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_TO_UTF8_FREE(val);
|
||||
#endif
|
||||
}
|
||||
} else if (tv->v_type == VAR_NUMBER) {
|
||||
// looks like sizeof(varnumber_T) is always <= sizeof(long)
|
||||
@@ -3366,13 +3327,9 @@ static id vimToCocoa(typval_T * tv, int depth)
|
||||
newObj = vimToCocoa(&di->di_tv, depth + 1);
|
||||
|
||||
char_u * keyval = hi->hi_key;
|
||||
#ifdef FEAT_MBYTE
|
||||
keyval = CONVERT_TO_UTF8(keyval);
|
||||
#endif
|
||||
NSString * key = [NSString stringWithUTF8String:(char*)keyval];
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_TO_UTF8_FREE(keyval);
|
||||
#endif
|
||||
[dict setObject:newObj forKey:key];
|
||||
}
|
||||
}
|
||||
@@ -3395,9 +3352,7 @@ static id evalExprCocoa(NSString * expr, NSString ** errstr)
|
||||
|
||||
char_u *s = (char_u*)[expr UTF8String];
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
s = CONVERT_FROM_UTF8(s);
|
||||
#endif
|
||||
|
||||
int save_dbl = debug_break_level;
|
||||
int save_ro = redir_off;
|
||||
@@ -3415,9 +3370,7 @@ static id evalExprCocoa(NSString * expr, NSString ** errstr)
|
||||
setcursor();
|
||||
out_flush();
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_FROM_UTF8_FREE(s);
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_GUI
|
||||
if (gui.in_use)
|
||||
@@ -3451,9 +3404,7 @@ static id evalExprCocoa(NSString * expr, NSString ** errstr)
|
||||
// still fails an empty NSString is returned.
|
||||
NSString *string = nil;
|
||||
if (s) {
|
||||
#ifdef FEAT_MBYTE
|
||||
s = CONVERT_TO_UTF8(s);
|
||||
#endif
|
||||
string = [NSString stringWithUTF8String:(char*)s];
|
||||
if (!string) {
|
||||
// HACK! Apparently 's' is not a valid utf-8 string, maybe it is
|
||||
@@ -3461,9 +3412,7 @@ static id evalExprCocoa(NSString * expr, NSString ** errstr)
|
||||
string = [NSString stringWithCString:(char*)s
|
||||
encoding:NSISOLatin1StringEncoding];
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_TO_UTF8_FREE(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
return string != nil ? string : [NSString string];
|
||||
@@ -3473,13 +3422,9 @@ static id evalExprCocoa(NSString * expr, NSString ** errstr)
|
||||
{
|
||||
char_u *s = (char_u*)[self UTF8String], *ret = NULL;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
s = CONVERT_FROM_UTF8(s);
|
||||
#endif
|
||||
ret = vim_strsave(s);
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_FROM_UTF8_FREE(s);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
+10
-56
@@ -490,7 +490,6 @@ gui_mch_delete_lines(int row, int num_lines)
|
||||
gui_macvim_draw_string(int row, int col, char_u *s, int len, int flags)
|
||||
{
|
||||
MMBackend *backend = [MMBackend sharedInstance];
|
||||
#ifdef FEAT_MBYTE
|
||||
int c, cw, cl, ccl;
|
||||
int start = 0;
|
||||
int endcol = col;
|
||||
@@ -553,12 +552,6 @@ gui_macvim_draw_string(int row, int col, char_u *s, int len, int flags)
|
||||
vim_free(conv_str);
|
||||
|
||||
return endcol - col;
|
||||
#else
|
||||
[backend drawString:s length:len
|
||||
row:row column:col
|
||||
cells:len flags:flags];
|
||||
return len;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1310,16 +1303,15 @@ mch_set_mouse_shape(int shape)
|
||||
|
||||
// -- Input Method ----------------------------------------------------------
|
||||
|
||||
#if defined(FEAT_MBYTE)
|
||||
# if defined(FEAT_EVAL)
|
||||
# ifdef FEAT_GUI
|
||||
# define USE_IMACTIVATEFUNC (!gui.in_use && *p_imaf != NUL)
|
||||
# define USE_IMSTATUSFUNC (!gui.in_use && *p_imsf != NUL)
|
||||
# else
|
||||
# define USE_IMACTIVATEFUNC (*p_imaf != NUL)
|
||||
# define USE_IMSTATUSFUNC (*p_imsf != NUL)
|
||||
# endif
|
||||
#if defined(FEAT_EVAL)
|
||||
# ifdef FEAT_GUI
|
||||
# define USE_IMACTIVATEFUNC (!gui.in_use && *p_imaf != NUL)
|
||||
# define USE_IMSTATUSFUNC (!gui.in_use && *p_imsf != NUL)
|
||||
# else
|
||||
# define USE_IMACTIVATEFUNC (*p_imaf != NUL)
|
||||
# define USE_IMSTATUSFUNC (*p_imsf != NUL)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
void
|
||||
im_set_position(int row, int col)
|
||||
@@ -1365,16 +1357,14 @@ im_set_active(int active)
|
||||
int
|
||||
im_get_status(void)
|
||||
{
|
||||
# ifdef FEAT_EVAL
|
||||
#ifdef FEAT_EVAL
|
||||
if (USE_IMSTATUSFUNC)
|
||||
return call_imstatusfunc();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return [[MMBackend sharedInstance] imState];
|
||||
}
|
||||
|
||||
#endif // defined(FEAT_MBYTE)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1433,9 +1423,7 @@ ex_macaction(eap)
|
||||
}
|
||||
|
||||
char_u *arg = eap->arg;
|
||||
#ifdef FEAT_MBYTE
|
||||
arg = CONVERT_TO_UTF8(arg);
|
||||
#endif
|
||||
|
||||
NSDictionary *actionDict = [[MMBackend sharedInstance] actionDict];
|
||||
NSString *name = [NSString stringWithUTF8String:(char*)arg];
|
||||
@@ -1445,9 +1433,7 @@ ex_macaction(eap)
|
||||
semsg(_("E???: Invalid action: %s"), eap->arg);
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
arg = CONVERT_TO_UTF8(arg);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1647,16 +1633,12 @@ gui_mch_get_color(char_u *name)
|
||||
if (![MMBackend sharedInstance])
|
||||
return INVALCOLOR;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
name = CONVERT_TO_UTF8(name);
|
||||
#endif
|
||||
|
||||
NSString *key = [NSString stringWithUTF8String:(char*)name];
|
||||
guicolor_T col = [[MMBackend sharedInstance] lookupColorWithKey:key];
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_TO_UTF8_FREE(name);
|
||||
#endif
|
||||
|
||||
return col;
|
||||
}
|
||||
@@ -1798,9 +1780,7 @@ gui_mch_settitle(char_u *title, char_u *icon)
|
||||
{
|
||||
ASLogDebug(@"title='%s' icon='%s'", title, icon);
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
title = CONVERT_TO_UTF8(title);
|
||||
#endif
|
||||
|
||||
MMBackend *backend = [MMBackend sharedInstance];
|
||||
[backend setWindowTitle:(char*)title];
|
||||
@@ -1809,9 +1789,7 @@ gui_mch_settitle(char_u *title, char_u *icon)
|
||||
if (curbuf)
|
||||
[backend setDocumentFilename:(char*)curbuf->b_ffname];
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_TO_UTF8_FREE(title);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1884,13 +1862,9 @@ gui_macvim_add_to_find_pboard(char_u *pat)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
pat = CONVERT_TO_UTF8(pat);
|
||||
#endif
|
||||
NSString *s = [NSString stringWithUTF8String:(char*)pat];
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_TO_UTF8_FREE(pat);
|
||||
#endif
|
||||
|
||||
if (!s) return;
|
||||
|
||||
@@ -1982,16 +1956,12 @@ gui_macvim_release_autoreleasepool(void *pool)
|
||||
void
|
||||
serverRegisterName(char_u *name)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
name = CONVERT_TO_UTF8(name);
|
||||
#endif
|
||||
|
||||
NSString *svrName = [NSString stringWithUTF8String:(char*)name];
|
||||
[[MMBackend sharedInstance] registerServerWithName:svrName];
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_TO_UTF8_FREE(name);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -2003,10 +1973,8 @@ serverRegisterName(char_u *name)
|
||||
serverSendToVim(char_u *name, char_u *cmd, char_u **result,
|
||||
int *port, int asExpr, int timeout, int silent)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
name = CONVERT_TO_UTF8(name);
|
||||
cmd = CONVERT_TO_UTF8(cmd);
|
||||
#endif
|
||||
|
||||
BOOL ok = [[MMBackend sharedInstance]
|
||||
sendToServer:[NSString stringWithUTF8String:(char*)name]
|
||||
@@ -2016,10 +1984,8 @@ serverSendToVim(char_u *name, char_u *cmd, char_u **result,
|
||||
expression:asExpr
|
||||
silent:silent];
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_TO_UTF8_FREE(name);
|
||||
CONVERT_TO_UTF8_FREE(cmd);
|
||||
#endif
|
||||
|
||||
return ok ? 0 : -1;
|
||||
}
|
||||
@@ -2072,7 +2038,6 @@ serverPeekReply(int port, char_u **str)
|
||||
if (str && len > 0) {
|
||||
*str = (char_u*)[reply UTF8String];
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (input_conv.vc_type != CONV_NONE) {
|
||||
char_u *s = string_convert(&input_conv, *str, &len);
|
||||
|
||||
@@ -2087,7 +2052,6 @@ serverPeekReply(int port, char_u **str)
|
||||
|
||||
vim_free(s);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return reply != nil;
|
||||
@@ -2122,16 +2086,12 @@ serverSendReply(char_u *serverid, char_u *reply)
|
||||
int retval = -1;
|
||||
int port = serverStrToPort(serverid);
|
||||
if (port > 0 && reply) {
|
||||
#ifdef FEAT_MBYTE
|
||||
reply = CONVERT_TO_UTF8(reply);
|
||||
#endif
|
||||
BOOL ok = [[MMBackend sharedInstance]
|
||||
sendReply:[NSString stringWithUTF8String:(char*)reply]
|
||||
toPort:port];
|
||||
retval = ok ? 0 : -1;
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_TO_UTF8_FREE(reply);
|
||||
#endif
|
||||
}
|
||||
|
||||
return retval;
|
||||
@@ -2246,7 +2206,6 @@ get_macaction_name(expand_T *xp, int idx)
|
||||
|
||||
char_u *plainStr = (char_u*)[string UTF8String];
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (str) {
|
||||
vim_free(str);
|
||||
str = NULL;
|
||||
@@ -2256,7 +2215,6 @@ get_macaction_name(expand_T *xp, int idx)
|
||||
str = string_convert(&input_conv, plainStr, &len);
|
||||
plainStr = str;
|
||||
}
|
||||
#endif
|
||||
|
||||
return plainStr;
|
||||
}
|
||||
@@ -2268,14 +2226,10 @@ is_valid_macaction(char_u *action)
|
||||
int isValid = NO;
|
||||
NSDictionary *actionDict = [[MMBackend sharedInstance] actionDict];
|
||||
if (actionDict) {
|
||||
#ifdef FEAT_MBYTE
|
||||
action = CONVERT_TO_UTF8(action);
|
||||
#endif
|
||||
NSString *string = [NSString stringWithUTF8String:(char*)action];
|
||||
isValid = (nil != [actionDict objectForKey:string]);
|
||||
#ifdef FEAT_MBYTE
|
||||
CONVERT_TO_UTF8_FREE(action);
|
||||
#endif
|
||||
}
|
||||
|
||||
return isValid;
|
||||
|
||||
Reference in New Issue
Block a user