Skip to content

Commit e11420c

Browse files
authored
Merge pull request #21 from vision-05/dev
Dev
2 parents 0cd88cd + e8b4c51 commit e11420c

File tree

11 files changed

+146
-98
lines changed

11 files changed

+146
-98
lines changed

bettercode/.bettercode/.edn

Lines changed: 0 additions & 1 deletion
This file was deleted.
81 Bytes
Loading
81 Bytes
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{:text-color "#e6e6e6ff", :line-no-color "#999999ff", :background-color "#333333ff", :highlight-color "#334D4DFF", :border-color "#4d4d4dff", :button-hover-color "#808080ff", :scroll-color "#666666ff"}

bettercode/.bettercode/meta.edn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{:theme-path "/home/tim/betterCode/bettercode/.bettercode/synth-conf.edn", :plugins {}}
1+
{:theme-path "/home/tim/betterCode/bettercode/.bettercode/dark-grey.edn", :plugins {}}

bettercode/src/bettercode/core.clj

Lines changed: 16 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212
[bettercode.elements]
1313
[bettercode.css]
1414
[bettercode.events]
15-
[bettercode.utilelements])
16-
(:import [javafx.application Platform]))
15+
[bettercode.utilelements]
16+
[bettercode.images]
17+
[bettercode.stages])
18+
(:import [javafx.application Platform]
19+
[javafx.scene.image Image]))
1720

1821
(def protocol
1922
(gloss/compile-frame
@@ -36,88 +39,14 @@
3639

3740
(defn app [{:keys [fx/context tclient]}]
3841
{:fx/type fx/ext-many
39-
:desc [{:fx/type :stage
40-
:title "BetterCode"
41-
:showing true
42-
:width 768
43-
:height 1080
44-
:min-width 768
45-
:min-height 1140
46-
:resizable true
47-
:scene {:fx/type :scene
48-
:fill ((fx/sub-val context :colors) :background-color)
49-
:stylesheets [(::css/url (fx/sub-val context :style-sheet))]
50-
:root {:fx/type :v-box
51-
:children [{:fx/type :menu-bar
52-
:max-height 10 ;somehow make the height actually work
53-
:style-class "root-menu-bar"
54-
:menus [{:fx/type :menu
55-
:text "file"
56-
:style-class "root-menu-bar-item"
57-
:items [{:fx/type :menu-item
58-
:style-class "root-menu-bar-item-sub-item"
59-
:text "open"
60-
:on-action {:event/type :open-file-explorer
61-
:tclient tclient}}
62-
{:fx/type :menu-item
63-
:style-class "root-menu-bar-item-sub-item"
64-
:text "save"
65-
:on-action {:event/type :save-file
66-
:tclient tclient}}
67-
{:fx/type :menu-item
68-
:style-class "root-menu-bar-item-sub-item"
69-
:text "close file"
70-
:on-action {:event/type :close-file
71-
:tclient tclient}}]}
72-
{:fx/type :menu
73-
:text "theme"
74-
:style-class "root-menu-bar-item"
75-
:items [{:fx/type :menu-item
76-
:style-class "root-menu-bar-item-sub-item"
77-
:text "new theme"
78-
:on-action {:event/type :open-theme-creator}}
79-
{:fx/type :menu-item
80-
:style-class "root-menu-bar-item-sub-item"
81-
:text "existing theme"
82-
:on-action {:event/type :open-theme-selector}}]}]}
83-
{:fx/type bettercode.elements/editor-pane
84-
:tclient tclient
85-
:text ""
86-
:file-path "BetterCode"
87-
:style-class "root"}]}}}
88-
{:fx/type :stage
89-
:title "Files"
90-
:showing (fx/sub-val context :file-explorer-show)
91-
:width 500
92-
:height 350
93-
:resizable false
94-
:always-on-top true
95-
:modality :application-modal
96-
:scene {:fx/type :scene
97-
:fill ((fx/sub-val context :colors) :background-color)
98-
:stylesheets [(::css/url (fx/sub-val context :style-sheet))]
99-
:root {:fx/type bettercode.utilelements/file-window
100-
:tclient tclient}}}
101-
{:fx/type :stage
102-
:title "Theme"
103-
:showing (fx/sub-val context :theme-creator-show)
104-
:width 700
105-
:height 380
106-
:resizable false
107-
:scene {:fx/type :scene
108-
:fill ((fx/sub-val context :colors) :background-color)
109-
:stylesheets [(::css/url (fx/sub-val context :style-sheet))]
110-
:root {:fx/type bettercode.utilelements/theme-creator}}}
111-
{:fx/type :stage
112-
:title "Theme Picker"
113-
:showing (fx/sub-val context :theme-picker-show)
114-
:width 700
115-
:height 380
116-
:resizable false
117-
:scene {:fx/type :scene
118-
:fill ((fx/sub-val context :colors) :background-color)
119-
:stylesheets [(::css/url (fx/sub-val context :style-sheet))]
120-
:root {:fx/type bettercode.utilelements/themes-view}}}]})
42+
:desc [{:fx/type bettercode.stages/main-app
43+
:tclient tclient}
44+
{:fx/type bettercode.stages/file-explorer
45+
:tclient tclient}
46+
{:fx/type bettercode.stages/theme-creator
47+
:tclient tclient}
48+
{:fx/type bettercode.stages/theme-picker
49+
:tclient tclient}]})
12150

12251
(defn -main [hostname & args]
12352
(Platform/setImplicitExit true)
@@ -144,10 +73,12 @@
14473
:anchor-pos 0
14574
:style-sheet bettercode.css/style
14675
:colors bettercode.css/colors
76+
:images {:file @(fx/on-fx-thread (Image. bettercode.images/file-icon))
77+
:folder @(fx/on-fx-thread (Image. bettercode.images/folder-icon))}
14778
:themes (bettercode.meta/get-themes)}
14879
#(cache/lru-cache-factory % :threshold 4096)))]
14980
(fx/create-app *context
15081
:event-handler bettercode.events/event-handler
15182
:desc-fn (fn [_]
15283
{:fx/type app
153-
:tclient c}))))
84+
:tclient c}))))

bettercode/src/bettercode/elements.clj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
{:fx/type :text-field
88
:min-height 32
99
:max-height 32
10-
:min-width 740
1110
:editable false
1211
:alignment :center
1312
:text file-path
@@ -38,7 +37,7 @@
3837

3938
(defn status-row [{:keys [fx/context]}]
4039
{:fx/type :h-box
41-
:min-width 768
40+
:pref-width 768
4241
:padding 14
4342
:children [{:fx/type status-bar
4443
:file-path (fx/sub-val context :file-path)
@@ -47,7 +46,6 @@
4746
(defn editor-row [{:keys [fx/context tclient]}]
4847
{:fx/type :h-box
4948
:pref-width 768
50-
:min-width 768
5149
:padding 14
5250
:spacing 28
5351
:children [{:fx/type line-numbers
@@ -60,8 +58,6 @@
6058
(defn editor-pane [{:keys [fx/context tclient]}]
6159
{:fx/type :v-box
6260
:pref-width 768
63-
:min-width 768
64-
:min-height 1080
6561
:children [{:fx/type status-row
6662
:v-box/hgrow :always}
6763
{:fx/type editor-row
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(ns bettercode.images
2+
(:require [clojure.java.io :as io]))
3+
4+
(def file-icon (io/input-stream ".bettercode/assets/icons/file.png"))
5+
(def folder-icon (io/input-stream ".bettercode/assets/icons/folder.png"))
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
(ns bettercode.stages
2+
(:require [cljfx.api :as fx]
3+
[cljfx.css :as css]))
4+
5+
(defn main-app [{:keys [fx/context tclient]}]
6+
{:fx/type :stage
7+
:title "BetterCode"
8+
:showing true
9+
:width 768
10+
:height 1080
11+
:resizable true
12+
:scene {:fx/type :scene
13+
:fill ((fx/sub-val context :colors) :background-color)
14+
:stylesheets [(::css/url (fx/sub-val context :style-sheet))]
15+
:root {:fx/type :v-box
16+
:children [{:fx/type :menu-bar
17+
:max-height 10 ;somehow make the height actually work
18+
:style-class "root-menu-bar"
19+
:menus [{:fx/type :menu
20+
:text "file"
21+
:style-class "root-menu-bar-item"
22+
:items [{:fx/type :menu-item
23+
:style-class "root-menu-bar-item-sub-item"
24+
:text "open"
25+
:on-action {:event/type :open-file-explorer
26+
:tclient tclient}}
27+
{:fx/type :menu-item
28+
:style-class "root-menu-bar-item-sub-item"
29+
:text "save"
30+
:on-action {:event/type :save-file
31+
:tclient tclient}}
32+
{:fx/type :menu-item
33+
:style-class "root-menu-bar-item-sub-item"
34+
:text "close file"
35+
:on-action {:event/type :close-file
36+
:tclient tclient}}]}
37+
{:fx/type :menu
38+
:text "theme"
39+
:style-class "root-menu-bar-item"
40+
:items [{:fx/type :menu-item
41+
:style-class "root-menu-bar-item-sub-item"
42+
:text "new theme"
43+
:on-action {:event/type :open-theme-creator}}
44+
{:fx/type :menu-item
45+
:style-class "root-menu-bar-item-sub-item"
46+
:text "edit theme"}
47+
{:fx/type :menu-item
48+
:style-class "root-menu-bar-item-sub-item"
49+
:text "existing theme"
50+
:on-action {:event/type :open-theme-selector}}]}]}
51+
{:fx/type bettercode.elements/editor-pane
52+
:tclient tclient
53+
:text ""
54+
:file-path "BetterCode"
55+
:style-class "root"}]}}})
56+
57+
(defn file-explorer [{:keys [fx/context tclient]}]
58+
{:fx/type :stage
59+
:title (fx/sub-val context :cur-path)
60+
:showing (fx/sub-val context :file-explorer-show)
61+
:width 500
62+
:height 350
63+
:resizable false
64+
:always-on-top true
65+
:modality :application-modal
66+
:scene {:fx/type :scene
67+
:fill ((fx/sub-val context :colors) :background-color)
68+
:stylesheets [(::css/url (fx/sub-val context :style-sheet))]
69+
:root {:fx/type bettercode.utilelements/file-window
70+
:tclient tclient}}})
71+
72+
(defn theme-creator [{:keys [fx/context tclient]}]
73+
{:fx/type :stage
74+
:title "Theme"
75+
:showing (fx/sub-val context :theme-creator-show)
76+
:width 700
77+
:height 380
78+
:resizable false
79+
:scene {:fx/type :scene
80+
:fill ((fx/sub-val context :colors) :background-color)
81+
:stylesheets [(::css/url (fx/sub-val context :style-sheet))]
82+
:root {:fx/type bettercode.utilelements/theme-creator}}})
83+
84+
(defn theme-picker [{:keys [fx/context tclient]}]
85+
{:fx/type :stage
86+
:title "Theme Picker"
87+
:showing (fx/sub-val context :theme-picker-show)
88+
:width 700
89+
:height 380
90+
:resizable false
91+
:scene {:fx/type :scene
92+
:fill ((fx/sub-val context :colors) :background-color)
93+
:stylesheets [(::css/url (fx/sub-val context :style-sheet))]
94+
:root {:fx/type bettercode.utilelements/themes-view}}})
95+

bettercodeserver/server-spec.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# bettercode server specification
2+
## Intro:
3+
The bettercode server communicates over regular TCP sockets with data encoded in edn format. Each message includes an integer (32 bit) size of the message prepending the actual UTF-8 encoded message. This must be used or you will get garbage data. The format of data must take an edn vector (`[]`) with the message/command as the first item and any arguments in order as the rest. As an example one command could be `["insert-text" "/home/foo/bar.txt" 0 "hello"]`
4+
5+
6+
7+
## Commands:
8+
### `"open-file"`
9+
This command opens a file in the buffer, and takes one argument of the file name. Example code to call: `["open-file "/home/foo/bar.txt"]`. Note that paths must be absolute paths (to keep the map of files flat). This command sends back a UTF-8 encoded string of the file contents.
10+
11+
### `"close-file"`
12+
This command closes a file in the buffer (by removing the content without saving). Example code to call: `["close-file" "/home/foo/bar.txt"]`. Again pass absolute paths.
13+
14+
### `"save-file"`
15+
This command saves a file from the buffer, again only taking the filename argument. Example code to call: `["save-file" "/home/foo/bar.txt"]`
16+
17+
### `"insert-text"`
18+
This command will insert a string or characters into the specified filename's content. You must specify the full path, the index and the string or character to insert. Example code to call: `["insert-text" "/home/foo/bar.txt" 2 "foo"]`
19+
20+
### `"remove-text"`
21+
This command will delete a string from a file contents in the buffer, by passing the full path, start and end of the deletion. Example code to call: `["remove-text" "/home/foo/bar.txt" 0 4]`
22+
23+
### `"get-dir"`
24+
This command fetches the files and directories inside the specified path supplied. This will send back a vector of (paths) files followed by the directories, with the string either `"FIL: "` or `"DIR: "` prepended to the path. Example code to call: `["get-dir"]` (no arguments fetches the current working directory), `["get-dir" "/home/foo"]` (gets the contents of `"/home/foo"`). Example return value can be `["FIL: /home/foo/bar.txt" "DIR: /home/foo/baz"]`

0 commit comments

Comments
 (0)