Skip to content
This repository has been archived by the owner on Aug 14, 2022. It is now read-only.

Add support for cross-platform and Windows PDF viewers #48

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Current wish list, in a semi-prioritized order.
- [ ] BibTeX autocompletion support.
- [x] Open PDF automatically.
- [x] Configurable.
- [ ] Support for other distributions, besides OS X.
- [x] Support for other distributions, besides OS X.
- [ ] Support for compilers other than latexmk.
- [ ] Add support for non-PDF typesetting (e.g. dvi).
- [ ] Project management.
Expand Down
13 changes: 10 additions & 3 deletions lib/latex.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,16 @@ module.exports =
require './openers/skim-opener'
else
require './openers/preview-opener'

return new OpenerImpl() if OpenerImpl?
console.info 'Opening PDF files is not yet supported on your platform.' unless atom.inSpecMode()
when 'win32'
if fs.existsSync(atom.config.get('latex.sumatraPath'))
require './openers/sumatra-opener'
unless OpenerImpl?
if atom.packages.resolvePackagePath('pdf-view')?
OpenerImpl = require './openers/atompdf-opener'
else
console.info 'No PDF opener found. For cross-platform viewing, install the pdf-view package.' unless atom.inSpecMode()
return
return new OpenerImpl()

moveResult: (result, filePath) ->
sourceDir = path.dirname(filePath)
Expand Down
14 changes: 14 additions & 0 deletions lib/openers/atompdf-opener.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Opener = require '../opener'

module.exports =
class AtomPdfOpener extends Opener
open: (filePath, texPath, lineNumber, callback) ->
# Opens PDF in a new pane -- requires pdf-view module
openPanes = atom.workspace.getPaneItems()
for pane in openPanes
if pane.filePath == filePath
# File is already open in another pane
return
pane = atom.workspace.getActivePane()
newPane = pane.split('horizontal', 'after')
atom.workspace.openURIInPane(filePath, newPane)
14 changes: 14 additions & 0 deletions lib/openers/sumatra-opener.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
child_process = require 'child_process'
Opener = require '../opener'

module.exports =
class SumatraOpener extends Opener
open: (filePath, texPath, lineNumber, callback) ->
sumatraPath = atom.config.get('latex.sumatraPath')
args = [
'-forward-search'
texPath
lineNumber
filePath
]
child_process.execFile(sumatraPath, args)