Re: Shian Lee's Unicode/Utf8 editor, "edu.ex" Tricks and Tips
- Posted by Senator
Mar 01, 2018
-- more JAPI GUI fun code for edu.ex
-- the following code allows the user to open a new file or existing file
-- in a new window by using the keystrokes ESC N
-- or open an new or existing file in the current window using
-- using keystrokes ESC n
-- An existing file can be opened in a new window
-- using the keystrokes ESC O
-- or open and existing file in the current window
-- using the keystrokes ESC o
include japi.e
procedure new_file(boolean NewFile)
sequence answer
if modified and last_use() then
while TRUE do
set_top_line("")
putsu("save changes to " & file_name & '?')
answer = key_gets("yn", {})
if find('y', answer) then
save_file(file_name)
exit
elsif find('n', answer) then
exit
end if
end while
end if
save_state()
if j_start() then
if NewFile then
-- open new file: new_file(TRUE)
-- j_fileselect allows user to type in a new file name
-- or select an existing file from an unsorted file
-- list
answer = j_fileselect(j_frame(""), "Select File", "*.e*")
else
-- open existing file: new_file(FALSE)
-- j_filedialog allow user to only open an existing file
-- from a sorted file list
answer = j_filedialog(j_frame(""),"Open File","*.e*")
end if
j_quit()
else
set_top_line("new file name (Esc=List): ")
answer = delete_trailing_white(key_gets("", file_history))
end if
if length(answer) != 0 then
file_name = answer
stop = TRUE
else
new_file_from_list() -- (Shian)
end if
end procedure
procedure get_escape(boolean help)
~
-- comment out the current command = key_gets~ line
-- and add the following line:
command = key_gets("hcqswnNoOedfrlmvj", {}) & ''
~
-- comment out the current elsif command[1] = 'n' line
-- and add the following lines:
elsif command[1] = 'n' or command[1] = 'N' then
-- new file in new or current window
if command[1] = 'N' then
-- new file in new window
clone_window()
end if
-- open a new file in current window
new_file(TRUE)
elsif command[1] = 'o' or command[1] = 'O' then
-- open and existing file in new or current window
if command[1] = 'O' then
-- open an existing file in new window
clone_window()
end if
-- open an existing file in current window
new_file(FALSE)
Not Categorized, Please Help
|
|