Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows #261

Open
wants to merge 76 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
5772c9f
Windows build
robert-nix Jun 1, 2016
f6b8528
Windows process execution
refi64 Aug 24, 2016
a67a388
Make process termination work
refi64 Aug 24, 2016
6f61ce1
Remove aux.moon (for now, at least)
refi64 Aug 24, 2016
dfc31cb
Update theme fonts to have Windows-friendly versions
refi64 Aug 24, 2016
eda9cdd
Update .gitignore
refi64 Aug 24, 2016
4a4a842
Make icons work
refi64 Aug 24, 2016
26dc5c3
Clean up some debugging aids
refi64 Aug 24, 2016
588dd69
On Windows, printing a message will leave it in the buffer until the …
refi64 Aug 24, 2016
0e91553
Tweak Windows default fonts
refi64 Aug 24, 2016
4222bd9
Fix tmpfile on Windows
refi64 Aug 24, 2016
5509fe7
Fix a LOT of test failures related to howl.io.File and Windows
refi64 Aug 24, 2016
bce797f
Fix a minor bug in File.etag
refi64 Aug 24, 2016
306976f
More spec fixes
refi64 Aug 24, 2016
bf1d7f3
Some cleanup
refi64 Aug 24, 2016
87f82a5
I AM AN IDIOT.
refi64 Aug 24, 2016
8bd1c80
Typo fix
refi64 Aug 24, 2016
8ba523c
Test fixes
refi64 Aug 24, 2016
9b65e03
More test fixes
refi64 Aug 24, 2016
05a84ab
Fix several path_spec test failures
refi64 Aug 24, 2016
0f09ac6
Fix a bug in File.is_absolute and more paths specs
refi64 Aug 24, 2016
20d2c4b
Fix a bug in OutputStream under Windows
refi64 Aug 24, 2016
d698bb6
Some fixes for process signals
refi64 Aug 24, 2016
376aa90
Process fixes
refi64 Aug 24, 2016
0864b60
Fix the sandboxed loader specs
refi64 Aug 24, 2016
5a68550
Fix project_spec under Windows
refi64 Aug 25, 2016
7f59fb2
Fix buffer_spec on Windows
refi64 Aug 25, 2016
b7b0638
Fixes to file selector interactions and specs
refi64 Aug 25, 2016
7f12ca1
Make file opening a bit more natural under Windows
refi64 Aug 25, 2016
443639b
More file selection on Windows
refi64 Aug 25, 2016
f4fcd0a
Windows specs
refi64 Aug 25, 2016
017566d
Simply tempfile code
refi64 Aug 25, 2016
b8d269b
More file selection fixes
refi64 Aug 25, 2016
7eb58c3
Finish fixing the file_selection specs
refi64 Aug 25, 2016
173ad8c
Hidden file reorg & make bundle_spec pass on Windows
refi64 Aug 25, 2016
38796e1
Un-break stuff
refi64 Aug 25, 2016
e0617cb
Shut up, linter
refi64 Aug 25, 2016
9cd8d6c
Update Makefile for MSYS2
refi64 Aug 26, 2016
843a404
More process fixes
refi64 Aug 26, 2016
ccc8bb8
More spec fixes
refi64 Aug 30, 2016
7c628a0
Fix scrollbar on an empty file
refi64 Aug 30, 2016
11fe38d
Process spec fixes
refi64 Sep 28, 2016
9e1f472
More spec fixes
refi64 Sep 28, 2016
cc28ed6
PROCESS. SPECS. WORK.
refi64 Sep 28, 2016
5e32023
Fix glib specs
refi64 Sep 28, 2016
4d1437d
Fix the definition of g_object_new
refi64 Sep 29, 2016
40be07b
gio test fixes
refi64 Sep 29, 2016
6dff5ca
More spec fixes
refi64 Sep 29, 2016
c7260e0
More spec fixes
refi64 Sep 29, 2016
941a91f
Cleanup
refi64 Sep 29, 2016
9894693
Linter
refi64 Sep 29, 2016
fd7f577
Mrgrgr...
refi64 Sep 29, 2016
285242e
*facepalm*
refi64 Sep 29, 2016
734e348
Linux fixes
refi64 Sep 29, 2016
5647ae0
Fixes
refi64 Sep 29, 2016
277b252
Fixes
refi64 Sep 29, 2016
41fccbe
More spec fixes
refi64 Sep 29, 2016
f48895d
More spec fixes
refi64 Sep 29, 2016
e1b48c9
Docs
refi64 Sep 29, 2016
44c5029
Cleanup
refi64 Sep 30, 2016
b4a12a7
Null termination
refi64 Sep 30, 2016
d9f072d
Move g_usleep to cdefs
refi64 Sep 30, 2016
537e967
Fixes & more cleanup
refi64 Sep 30, 2016
e800c94
Fix path to cmd.exe
refi64 Sep 30, 2016
67afdb6
Write font loading failure to stderr
refi64 Sep 30, 2016
ff37594
Cleanup
refi64 Nov 5, 2016
2536cd7
Move some platform-specific code to howl.sys.platform
refi64 Nov 6, 2016
2dba2b2
Linter fixes
refi64 Nov 6, 2016
6b4ae52
Oops
refi64 Nov 6, 2016
81186cb
boring stuffz
refi64 Apr 28, 2017
67bf2fd
Add 'make windist'
refi64 Apr 28, 2017
c1e4c98
Rename ljglibs.aux -> ljglibs.util
refi64 Apr 28, 2017
decaa9a
Installer stuff
refi64 Apr 28, 2017
21f5742
*facepalm
refi64 Apr 28, 2017
f94c148
Windows docs
refi64 Apr 28, 2017
32a24f2
Merge branch 'master' of https://github.com/howl-editor/howl into win…
refi64 Jul 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
src/deps/*/*
src/*.o
src/howl
src/howl.exe
*.bc
*.bak
site/build/
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ how to install Howl from source.
based system).
- `C compiler`: Howl has a very small C core itself, and it embeds
dependencies written in C.
- If you're using Windows, you *need* to build Howl inside of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could/should we add a specific README with installation instructions on Windows? I'm thinking of basic steps from start to finish.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be in a readme (e.g. README.windows.md), or do you think it would be better as a page on the site (e.g. getit.windows.html), as a parallel to getit.html?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a separate page on the site would be best, we could just reference to that from the README.

[MSYS2](https://msys2.github.io/)'s MinGW32 shell.

### Build && install

Expand Down
34 changes: 19 additions & 15 deletions bundles/git/spec/git_spec.moon
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import bundle, config, VC from howl
import File from howl.io
import Spy from howl.spec

echo = if jit.os == 'Windows'
"#{howl.sys.env.WD}echo.exe"
else
'/bin/echo'

describe 'Git bundle', ->
setup -> bundle.load_by_name 'git'
teardown -> bundle.unload 'git'
Expand All @@ -27,8 +32,7 @@ describe 'Git bundle', ->
assert.equal instance.root, dir

it 'returns nil if no git root was found', ->
File.with_tmpfile (file) ->
assert.is_nil git_vc.find file
assert.is_nil git_vc.find howl.io.File echo

describe 'A Git instance', ->
root = nil
Expand All @@ -52,7 +56,7 @@ describe 'Git bundle', ->
assert.same list1, list2

it 'returns a list of git files, including untracked', (done) ->
howl_async ->
proc_async ->
assert_same_files git\files!, {}
file = root / 'new.lua'
file\touch!
Expand All @@ -67,7 +71,7 @@ describe 'Git bundle', ->
file2 = root / 'another.lua'
file2\touch!
assert_same_files git\files!, { file2, file }
done!
proc_done done

describe 'diff([file])', ->
local file
Expand All @@ -79,37 +83,37 @@ describe 'Git bundle', ->
os.execute "cd #{root} && git commit -q -m 'rev1' #{file}"

it 'returns nil if <file> has not changed', (done) ->
howl_async ->
proc_async ->
assert.is_nil git\diff file
done!
proc_done done

it 'returns a string containing the diff if <file> has changed', (done) ->
howl_async ->
proc_async ->
file.contents ..= 'line 2\n'
diff = git\diff file
assert.includes diff, file.basename
assert.includes diff, '+line 2'
done!
proc_done done

it 'returns a diff for the entire directory if file is not specified', (done) ->
howl_async ->
proc_async ->
file.contents ..= 'line 2\n'
diff = git\diff!
assert.includes diff, file.basename
assert.includes diff, '+line 2'
done!
proc_done done

describe 'run(...)', ->
it 'runs git in the root dir with the given arguments and returns the output', (done) ->
howl_async ->
proc_async ->
assert.includes git\run('config', '--local', '-l'), "Howl Spec"
done!
proc_done done

it 'uses the executable in variable `git_path` if specified', (done) ->
howl_async ->
config.git_path = '/bin/echo'
proc_async ->
config.git_path = echo
status, out = pcall git.run, git, 'using echo'
config.git_path = nil
assert status, out
assert.includes out, "using echo"
done!
proc_done done
2 changes: 1 addition & 1 deletion bundles/howl-themes/solarized_light/solarized_light.moon
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ return {
font:
bold: true
size: 'large'
family: 'Purisa,Latin Modern Sans'
family: 'Purisa,Comic Sans,Latin Modern Sans,Lucida Sans Unicode'

definition: color: yellow
function: color: blue
Expand Down
2 changes: 1 addition & 1 deletion bundles/howl-themes/steinom/steinom.moon
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ return {
font:
bold: true
size: 'large'
family: 'Purisa,Latin Modern Sans'
family: 'Purisa,Comic Sans,Latin Modern Sans,Lucida Sans Unicode'

definition: color: yellow

Expand Down
2 changes: 1 addition & 1 deletion bundles/howl-themes/tomorrow_night_blue/tm_night_blue.moon
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ return {
font:
bold: true
size: 'large'
family: 'Purisa,Latin Modern Sans'
family: 'Purisa,Comic Sans,Latin Modern Sans,Lucida Sans Unicode'

definition: color: yellow

Expand Down
7 changes: 6 additions & 1 deletion lib/aullar/view.moon
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,14 @@ View = {

if opts.vertical
page_size = @lines_showing - 1
upper = @buffer.nr_lines
if page_size == 0
-- GtkRange docs mention that page_size is normally >0 for GtkScrollbar
upper = 2
page_size = 1
adjustment = @vertical_scrollbar.adjustment
if adjustment
adjustment\configure @first_visible_line, 1, @buffer.nr_lines, 1, page_size, page_size
adjustment\configure @first_visible_line, 1, upper, 1, page_size, page_size

if opts.horizontal
max_width = 0
Expand Down
9 changes: 0 additions & 9 deletions lib/howl/aux.moon

This file was deleted.

3 changes: 3 additions & 0 deletions lib/howl/cdefs/init.moon
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ int sig_PWR;
int sig_SYS;
]]

if ffi.os == 'Windows'
require 'howl.cdefs.windows'

return {
const_char_p: ffi.typeof 'const char *'
char_p: ffi.typeof 'char *'
Expand Down
21 changes: 21 additions & 0 deletions lib/howl/cdefs/windows.moon
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- Copyright 2016 The Howl Developers
-- License: MIT (see LICENSE.md at the top-level directory of the distribution)

ffi = require 'ffi'

ffi.cdef [[
typedef void* HANDLE;
typedef void* PVOID;
typedef int DWORD;
typedef int BOOL;
typedef char* LPTSTR;
typedef const char* LPCTSTR;

DWORD GetProcessId(HANDLE process);
HANDLE _get_osfhandle(int fd);
BOOL TerminateProcess(HANDLE process, unsigned int exitcode);
int AddFontResourceExA(LPCTSTR lpszFilename, DWORD fl, PVOID pdv);
BOOL SetFileAttributesA(LPCTSTR file, DWORD attrs);

int fr_private;
]]
2 changes: 1 addition & 1 deletion lib/howl/commands/app_commands.moon
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ command.register
-----------------------------------------------------------------------

launch_cmd = (working_directory, cmd) ->
shell = howl.sys.env.SHELL or '/bin/sh'
shell = howl.sys.env.SHELL
p = Process {
:cmd,
:shell,
Expand Down
21 changes: 19 additions & 2 deletions lib/howl/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Where options can be any of:
]=]

local path_separator = jit.os == 'Windows' and '\\' or '/'
local path_prefix = jit.os == 'Windows' and '\\\\.\\' or ''
app_root = path_prefix .. app_root

local function parse_args(argv)
local options = {
Expand Down Expand Up @@ -162,12 +164,27 @@ local function main(args)
set_package_path('lib', 'lib/ext', 'lib/ext/moonscript')
require 'howl.moonscript_support'
table.insert(package.loaders, 2, bytecode_loader())
require 'howl.cdefs.fontconfig'
ffi.C.FcConfigAppFontAddDir(nil, table.concat({app_root, 'fonts'}, path_separator))
require 'ljglibs.cdefs.glib'

howl = auto_module('howl')
require('howl.globals')

local font_dir = table.concat({app_root, 'fonts'}, path_separator)
if ffi.os == 'Windows' then
require 'howl.cdefs.windows'
local fonts = howl.io.File(font_dir).children
for _, font in ipairs(fonts) do
local loaded = ffi.C.AddFontResourceExA(font.path, ffi.C.fr_private, nil)
if loaded == 0 then
io.stderr:write('failed to load font ', font.path, '\n')
io.stderr:flush()
end
end
else
require 'howl.cdefs.fontconfig'
ffi.C.FcConfigAppFontAddDir(nil, font_dir)
end

_G.log = require('howl.log')
local args = parse_args(argv)

Expand Down
15 changes: 11 additions & 4 deletions lib/howl/interactions/file_selection.moon
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ class FileSelector
parent or= File.home_dir

path = @command_line\pop_spillover!
-- Make / work on Windows.
path = path\gsub '/', File.separator

if path.is_empty
path = tostring(parent) .. '/'
path = tostring(parent) .. File.separator
else
trailing = path\ends_with('/') and '/' or ''
trailing = path\ends_with(File.separator) and File.separator or ''
path = tostring parent / path
if not path\ends_with '/'
if not path\ends_with File.separator
path ..= trailing

directory, unmatched = get_dir_and_leftover path
Expand Down Expand Up @@ -93,7 +95,12 @@ class FileSelector
on_update: (text) =>
return if @submitting

path = @directory.path .. '/' .. text
-- This allows one to use / as a directory separator, even on Windows.
text = text\gsub '/', File.separator
path = if File.is_absolute text
text
else
@directory.path .. File.separator .. text
directory, text = get_dir_and_leftover path

if directory != @directory
Expand Down
19 changes: 14 additions & 5 deletions lib/howl/io/file.moon
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ GFileInfo = require 'ljglibs.gio.file_info'
glib = require 'ljglibs.glib'
import PropertyObject from howl.util.moon
append = table.insert
ffi = require 'ffi'

file_types = {
[tonumber GFileInfo.TYPE_DIRECTORY]: 'directory',
Expand All @@ -16,15 +17,23 @@ file_types = {
[tonumber GFileInfo.TYPE_UNKNOWN]: 'unknown',
}

platform_tmpname = ->
-- os.tmpname is broken on Windows and returns a filename prefixed with \.
-- This causes a lot of "Access denied"-related errors.
filename = assert os.tmpname!
-- Remove the prefix \.
filename = filename\sub 2 if ffi.os == 'Windows'
filename

class File extends PropertyObject

tmpfile: ->
file = File assert os.tmpname!
file.touch if not file.exists
file = File platform_tmpname!
file\touch! if not file.exists
file

tmpdir: ->
with File os.tmpname!
with File platform_tmpname!
\delete! if .exists
\mkdir!

Expand All @@ -35,7 +44,7 @@ class File extends PropertyObject
error err if not status

is_absolute: (path) ->
(path\match('^/') or path\match('^%a:\\\\')) != nil
(path\match('^/') or path\match('^%a:\\')) != nil

expand_path: (path) ->
res = path\gsub "~#{File.separator}", File.home_dir.path .. File.separator
Expand Down Expand Up @@ -79,7 +88,7 @@ class File extends PropertyObject
@property size: get: => @_info!.size
@property exists: get: => @gfile.exists
@property readable: get: => @exists and @_info('access')\get_attribute_boolean 'access::can-read'
@property etag: get: => @exists and @_info('etag').etag
@property etag: get: => @exists and @_info('etag').etag or nil
@property modified_at: get: => @exists and @_info('time')\get_attribute_uint64 'time::modified'
@property short_path: get: => @path\gsub "^#{File.home_dir.path}", '~'

Expand Down
9 changes: 7 additions & 2 deletions lib/howl/io/input_stream.moon
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@

dispatch = howl.dispatch
glib = require 'ljglibs.glib'
{:UnixInputStream} = require 'ljglibs.gio'
{:Win32InputStream, :UnixInputStream} = require 'ljglibs.gio'
{:PropertyObject} = howl.util.moon
append = table.insert
ffi = require 'ffi'

class InputStream extends PropertyObject
new: (@stream, @priority = glib.PRIORITY_LOW) =>
@stream = UnixInputStream(@stream) if type(@stream) == 'number'
if type(@stream) == 'number'
if ffi.os == 'Windows'
@stream = Win32InputStream ffi.C._get_osfhandle @stream
else
@stream = UnixInputStream @stream
super!

@property is_closed: get: => @stream.is_closed
Expand Down
8 changes: 6 additions & 2 deletions lib/howl/io/output_stream.moon
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
-- License: MIT (see LICENSE.md at the top-level directory of the distribution)

dispatch = howl.dispatch
{:UnixOutputStream} = require 'ljglibs.gio'
{:Win32OutputStream, :UnixOutputStream} = require 'ljglibs.gio'
{:PropertyObject} = howl.util.moon
ffi = require 'ffi'

class OutputStream extends PropertyObject
new: (fd) =>
@stream = UnixOutputStream fd
if ffi.os == 'Windows'
@stream = Win32OutputStream ffi.C._get_osfhandle fd
else
@stream = UnixOutputStream fd
super!

@property is_closed: get: => @stream.is_closed
Expand Down
Loading