早在去年,落格输入法的用户就有报告说落格输入法 macOS 在 有道云笔记 的 MarkDown 模式下无法正常键入中文,经过测试证明确实如此,体现为打中文字的时候,buffer的刷新会奇怪的删除掉光标前的一个字符——对,不多不少,就删一个。
捣鼓了很久未果,最后我没招了打印出了所有内容,发现[……]
mountain lion
在 iOS 上,如果我们要一个 View 显示阴影,那么基本上是这么做的:
|
1 2 3 4 5 |
self.view.layer?.shadowColor = NSColor.black.cgColor self.view.layer?.shadowOpacity = 0.1 self.view.layer?.shadowOffset = CGSize(width: 0, height: 0) self.view.layer?.shadowRadius = 3 self.view.layer?.masksToBounds = false |
不过,到了 macOS 上,这样就不灵了——没有任何效果。
答案在于 macOS 上如果你想要给一个 View 使用 [crayon-690b7ad[……]
之前我写过一篇Poker 2 机械键盘 Mac 键位修改的文章,现在由于我买了一个升降桌,然后poker是有线的,于是很不方便,就寻思买一款蓝牙键盘,没想到当年梦想的蓝牙机械键盘已经有了现成的,正好,寻思着就定制一个。
我对poker的wasd方向键情有独钟,尤其是改 capslock 为 f[……]
一般情况下,你不需要了解这些内容。
在极少数情况下,你的app可能需要去获取用户按下的按键信息,比如盗号木马 开发一款输入法。只有这样你才能给用户提供候选。
怎么在 macOS 下创建一个输入法,我在Swift 使用 InputMethodKit 写输入法这篇文章中有详细的说明,这里略过[……]
在开发落格输入法 macOS 版本的时候,我遇到了这么一个难题,那就是窗口优先级的问题。在之前 如何让 NSWindow 显示在不同的 Space 或者 Screen 中 这篇文章中我提到了自己实现了落格输入法的候选栏,其实是用一个 NSWindow
前段时间我说过我攒了一台高配的黑苹果,当时用的是一台普通的 1080p 显示器,我的 21:9 给同事用去了。
现在,我还是受不了这个16:9,于是我和他换了下,我又用回了我的 21:9,结果没想到……尼玛竟然不支持!
听说是 hd530 核显驱动不太行导致识别不了……
总之,咱还[……]
在开发落格输入法的时候,我遇到了这么一件事情,就是作为候选栏的窗口会在屏幕边缘的时候超出屏幕去!所以,在显示窗口的时候我根据坐标做了额外的检查:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
if visiableCandidateCells.isEmpty { if let screenframe = NSScreen.main?.visibleFrame { if screenframe.width < location.x + size.width { location.x -= location.x + size.width - screenframe.width } } } else { if let screenframe = NSScreen.main?.visibleFrame { if screenframe.width < location.x + self.window!.frame.size.width { location.x -= location.x + self.window!.frame.size.width - screenframe.width } } } if location.y < 50 { location.y += 35 + 35 } |
总之,就是说如果坐标算上自己的宽度超过了屏幕的宽度,就把它挪回来。
但是,这样[……]
在写落格输入法 Mac 版的过程当中,我遇到了这么一个问题,系统的候选条 API 年久失修,很多功能 API 存在但根本无效,比如:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
/*! @method @abstract Sets the "style" attributes for the candidates window. The keys for the attributes dictionary and the values are: NSFontAttributeName (value = NSFont) Setting the font attribute sets the font that is used to draw Candidates. It does not effect the selection keys which are always drawn in the same font. Note that to set the font size you should use this key/value pair. IMKCandidatesOpacityAttributeName (value = NSNumber with a float value between 0 and 1). Sets the opacity level to transparent (0.0) to completely opaque (1.0). The default opacity is 1.0. This constant is declared above. NSForegroundColorAttributeName (value = NSColor) Sets the text color used for the candidate text. By default it is black. NSBackgroundColorDocumentAttribute (value = NSColor). Set the background color that is drawn behind the candidate text. IMKCandidatesSendServerKeyEventFirst (value = NSNumber). NO (default) gives the candidate window first chance at key events. YES causes events to first be routed to the current IMKInputController. In that case, if the event is not handled, it will then be sent to the candidate window. */ open func setAttributes(_ attributes: [AnyHashable : Any]!) |
这个方法是用来设置候选条风格的,里边除了默认的[crayon-690b7ada2cc9c5199[……]
做开发者肯定有过这样的烦恼:版本号提交错了!
编译和测试的版本多了,难免提交的时候才发现版本号搞错了。要不就是后台版本号正确,前台的版本号忘记更改。其实,可以让前台自动获取后台的版本号数据,比如这样:
|
1 2 |
let info = Bundle.main.infoDictionary! version.text = "Version \(info["CFBundleShortVersionString"]!) (build \(info["CFBundleVersion"]!))" |
后台的版本号[……]
很多网络运维、或者站长需要通过 ssh 来管理服务器、vps,如果不凑巧,你和服务器之间相隔了一堵 GFW,那么由于 GFW 会分析 ssh 数据包,结果就是导致稍微慢一点的网络就会让命令卡一分钟。
GFW 现在完全有能力分析 ssh 流量特征,以判断你是在真的使用 ssh 配置服务器,还是使用它[……]
如何在 iOS 上写一款输入法?这个问题已经被很多人解答过了。你可以轻易通过 Google 找到一篇详细的教程。但是,在 macOS 上写一款输入法就没那么简单了。
好吧,严格来讲,是指用 Swift 在 macOS 上写一款输入法很难。主要的原因是 从来没有人做过这件事情 。
目前能够[……]
TextWrangler 是 Mac 上不可或缺的多功能文本编辑工具,内置优秀的代码高亮,还能支持正则表达式的搜索……总之,对于开发者来说,实在是人手必备。
不过,TextWrangler 对于 XML 就没有那么智能了——打开之后往往是长长的一行!
总之,解决办法很简单,我们给 Tex[……]