add resizer

This commit is contained in:
Xuan Sang LE
2018-01-31 18:19:02 +01:00
parent b44ef3ce0e
commit 69849db99a
13 changed files with 171 additions and 10 deletions

View File

@ -20,6 +20,12 @@ class NotePad extends this.OS.GUI.BaseApplication
@.editor.completers.push { getCompletions: ( editor, session, pos, prefix, callback ) -> }
@.editor.getSession().setUseWrapMode true
@fileview.contextmenuHandler = (e, m) ->
m.set "items", me.contextMenu()
m.set "onmenuselect", (evt) ->
me.contextAction evt
m.show e
@mlist = @find "modelist"
@modes = ace.require "ace/ext/modelist"
ldata = []
@ -78,6 +84,9 @@ class NotePad extends this.OS.GUI.BaseApplication
@fileview.set "onfileopen", (e) ->
return if e.type is "dir"
me.open e.path.asFileHandler()
@subscribe "VFS", (d) ->
p = (me.fileview.get "path").asFileHandler()
me.chdir p.path if d.data.file.hash() is p.hash() or d.data.file.parent().hash() is p.hash()
@location.set "onlistselect", (e) ->
me.chdir e.data.path
@location.set "items", ( i for i in @systemsetting.VFS.mountpoints when i.type isnt "app" )
@ -107,6 +116,48 @@ class NotePad extends this.OS.GUI.BaseApplication
file.cache = d or ""
me.newtab file
contextMenu: () ->
[
{ text: "New file", dataid: "#{@name}-mkf" },
{ text: "New folder", dataid: "#{@name}-mkd" },
{ text: "Delete", dataid: "#{@name}-rm" }
{ text: "Refresh", dataid: "#{@name}-refresh" }
]
contextAction: (e) ->
me = @
file = @fileview.get "selectedFile"
dir = if file then file.path.asFileHandler() else (@fileview.get "path").asFileHandler()
dir = dir.parent().asFileHandler() if file and file.type isnt "dir"
switch e.item.data.dataid
when "#{@name}-mkd"
@openDialog "PromptDialog",
(d) ->
dir.mk d, (r) ->
me.error "Fail to create #{d}: #{r.error}" if r.error
, "New folder"
when "#{@name}-mkf"
@openDialog "PromptDialog",
(d) ->
fp = "#{dir.path}/#{d}".asFileHandler()
fp.write "", (r) ->
me.error "Fail to create #{d}: #{r.error}" if r.error
, "New file"
when "#{@name}-rm"
return unless file
@openDialog "YesNoDialog",
(d) ->
return unless d
file.path.asFileHandler()
.remove (r) ->
me.error "Fail to delete #{file.filename}: #{r.error}" if r.error
, "Delete" ,
{ iconclass: "fa fa-question-circle", text: "Do you really want to delete: #{file.filename} ?" }
when "#{@name}-refresh"
@.chdir ( @fileview.get "path" )
save: (file) ->
me = @
file.write (file.getb64 "text/plain"), (d) ->

View File

@ -6,7 +6,11 @@ afx-app-window[data-id="notepad"] afx-list-view {
afx-app-window[data-id="notepad"] afx-list-view div.list-container{
z-index: 10;
}
afx-app-window[data-id="notepad"] afx-resizer{
z-index: 11;
background-color: transparent;
border-right: 1px solid #a6a6a6;
}
afx-app-window[data-id="notepad"] span[data-id="editorstat"]{
padding:5px;
display: inline-block;
@ -29,7 +33,7 @@ afx-tab-container[data-id="tabarea"] afx-list-view li {
afx-tab-container[data-id="tabarea"] afx-list-view{
padding:0;
margin: 0;
border-left: 1px solid #a6a6a6;
border-left: 0;
border-bottom: 1px solid #a6a6a6;
}
/*afx-tab-container[data-id="tabarea"] afx-list-view i.closable:before{

View File

@ -1,9 +1,10 @@
<afx-app-window apptitle="" width="600" height="400" data-id="notepad">
<afx-hbox>
<afx-vbox data-width = "175" data-id = "sidebar">
<afx-vbox data-width = "172" data-id = "sidebar" min-width="172">
<afx-list-view data-id = "location" dropdown = "true" data-height= "30" width = "150"></afx-list-view>
<afx-file-view data-id = "fileview" view='tree' status = false></afx-file-view>
</afx-vbox>
<afx-resizer data-width = "3" ></afx-resizer>
<afx-vbox>
<afx-tab-container data-id="tabarea" data-height="26" closable = true></afx-tab-container>
<div data-id="datarea"></div>