Skip to content

Commit

Permalink
ExplorerCreateFile: implemented encoding ui #60
Browse files Browse the repository at this point in the history
  • Loading branch information
ewerybody committed Feb 9, 2022
1 parent a6399d3 commit efa432b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ExplorerCreateFile/a2_local_element_file_list.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import a2ahk
import a2ctrl
from a2qt import QtWidgets
from a2element import DrawCtrl, EditCtrl
Expand Down Expand Up @@ -40,8 +41,9 @@ def __init__(self, *args):
)

type_combo = a2combo.A2Combo(self)
type_combo.addItems(a2ahk.ENCODINGS)
self.editor.add_data_label_widget(
'encoding', type_combo, type_combo.setCurrentText, default_value=0, label='Encoding'
'encoding', type_combo, type_combo.setCurrentIndex, default_value=0, label='Encoding'
)

ask_check = QtWidgets.QCheckBox('Ask for file name', self)
Expand Down
5 changes: 4 additions & 1 deletion ExplorerCreateFile/explorer_create_file.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ explorer_create_file_handler(menu_name) {

file_path := path_join(explorer_get_path(), file_name)

static ahk_encodings := ["UTF-8", "UTF-8-RAW", "UTF-16", "UTF-16-RAW"]
encoding := ahk_encodings[data["encoding"] + 1]

if FileExist(file_path) {
MsgBox, 48, File Already Exists, There is already a file with that name here!
} else {
content := data["content"]
FileAppend , %content%, %file_path%
FileAppend , %content%, %file_path%, %encoding%

Send, F5
sleep 1000
Expand Down

0 comments on commit efa432b

Please sign in to comment.