Skip to content

Commit

Permalink
Add Settings menuItem; Fix cannot edit lunar.cfg in Lunar bug; Enhanc…
Browse files Browse the repository at this point in the history
…e python doc gen script
  • Loading branch information
jie-meng committed Jan 18, 2018
1 parent 7b43e53 commit f094052
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 24 deletions.
1 change: 1 addition & 0 deletions Lunar.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<file>res/project_path.png</file>
<file>res/documents.png</file>
<file>res/locate.png</file>
<file>res/settings.png</file>
<file>res/app.ico</file>
</qresource>
</RCC>
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,21 @@ On MacOS
- Run `./luaexec deploy_on_mac.lua` on terminal to make Lunar.dmg (Follow command tips to give correct information)
- Install Lunar from Lunar.dmg to `/Applications`
- Add `export PATH=$PATH:/Applications/Lunar.app/Contents/MacOS` to your environment. (Then you can start Lunar from your terminal in current directory by typing command 'luna')
- Go to `/Application/Lunar.app/Content/MacOS` on terminal, run `luaexec install_luaexeclib.lua` to install luaexec extend libs.

Final step of all platforms

- Open Lunar from command line. (For Linux and Windows, input `Lunar` then press `Enter`. for MacOS input `luna` then press `Enter`)

- Click Menu: `File -> Lunar settings`. Open script `tools/update_lunar_plugins.lua`. Press F5 to Run it (Make sure you have svn command line installed). It will update all plugins and tools to the latest.

- Enjoy it!

### Notes ###

- 2018.01.18

V1.9.2 Fix cannot edit and save lunar.cfg in Lunar bug. Support goto Lunar path from menu.

- 2018.01.12

V1.9.1 Support plugins and tools auto update: Use tools/update_lunar_plugins.lua
Expand Down
13 changes: 8 additions & 5 deletions publish/apis/python/pydoc_gen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,11 @@ else
table.insert(modules, '__builtin__')
end

local pydoclibs = 'pydoclibs' .. python_version

-- Add pydoc libs
if util.isPathFile('pydoc_libs') then
local content = util.readTextFile('pydoc_libs')
if util.isPathFile(pydoclibs) then
local content = util.readTextFile(pydoclibs)
local libs = util.strSplit(content, '\n')
for _, v in ipairs(libs) do
local lib = util.strTrim(v)
Expand All @@ -347,7 +349,7 @@ if util.strContains(util.platformInfo(), 'windows', false) then
pydoc_gen_cmd = 'python -m pydoc'
end

local gen_root_dir = util.currentPath() .. '/' .. 'pydoc_gen'
local gen_root_dir = util.currentPath() .. '/' .. 'pydoc_gen' .. python_version
if not util.isPathDir(gen_root_dir) then
util.mkDir(gen_root_dir)
end
Expand Down Expand Up @@ -375,7 +377,8 @@ for _, v in ipairs(gen_docs) do
end
table.sort(tb)

print('\nGenerate pydoc_index.api')
util.writeTextFile('./pydoc_index.api', util.strJoin(tb, '\n'))
local pydoc_index = string.format('pydoc_index%s.api', python_version)
print('\nGenerate ' .. pydoc_index)
util.writeTextFile(gen_root_dir .. '/' .. pydoc_index, util.strJoin(tb, '\n'))

print('\nDone!')
4 changes: 2 additions & 2 deletions publish/extension.lua
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function parseFileType(filename)
-- python3
type = "python",
auto_complete_type = 1,
api = "apis/python",
api = "apis/python/keywords.api,apis/python/monkeyrunner.api,apis/python/pydoc_gen3",
executor = python3 .. " -u",
plugin_goto = "plugins/goto_python3.lua",
plugin_parse_api = "plugins/parse_supplement_api_python3.lua",
Expand All @@ -217,7 +217,7 @@ function parseFileType(filename)
-- python2
--type = "python",
--auto_complete_type = 1,
--api = "apis/python",
--api = "apis/python/keywords.api,apis/python/monkeyrunner.api,apis/python/pydoc_gen",
--executor = "python -u",
--plugin_goto = "plugins/goto_python.lua",
--plugin_parse_api = "plugins/parse_supplement_api_python.lua",
Expand Down
2 changes: 1 addition & 1 deletion publish/plugins/parse_supplement_api_python3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function parsePydocGenApi(apis, imports)
local api_trimmer = {}
for module_name, module in pairs(imports) do
local app_path, _ = util.splitPathname(util.appPath())
local pydoc_gen_path = app_path .. '/apis/python/pydoc_gen'
local pydoc_gen_path = app_path .. '/apis/python/pydoc_gen3'
if util.isPathFile(pydoc_gen_path .. '/' .. module_name) then
if module:isFromImport() then
local f = io.open(pydoc_gen_path .. '/' .. module_name, "r")
Expand Down
13 changes: 12 additions & 1 deletion replace_current_lunar_on_mac.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@

print('copy lunar.cfg')
os.execute('cp /Applications/Lunar.app/Contents/MacOS/lunar.cfg Lunar.app/Contents/MacOS/')

if util.isPathFile('/Applications/Lunar.app/Contents/MacOS/apis/python/pydoclibs') then
print('copy pydoclibs')
os.execute('cp /Applications/Lunar.app/Contents/MacOS/apis/python/pydoclibs Lunar.app/Contents/MacOS/apis/python/')
end

if util.isPathFile('/Applications/Lunar.app/Contents/MacOS/apis/python/pydoclibs3') then
print('copy pydoclibs3')
os.execute('cp /Applications/Lunar.app/Contents/MacOS/apis/python/pydoclibs3 Lunar.app/Contents/MacOS/apis/python/')
end

print('rm /Applications/Lunar.app')
os.execute('rm -rf /Applications/Lunar.app')

print('mv Lunar.app to /Applications')
os.execute('mv Lunar.app /Applications')

Expand Down
Binary file added res/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/gui/aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void AboutDialog::init()

void AboutDialog::initGui()
{
plabel_version_ = new QLabel(tr("Version: 1.9.1"));
plabel_version_ = new QLabel(tr("Version: 1.9.2"));
plabel_email_ = new QLabel(tr("Email: [email protected]"));

QVBoxLayout* pcenter_layout = new QVBoxLayout;
Expand Down
12 changes: 12 additions & 0 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ MainWindow::MainWindow(QWidget* parent)
pfile_goto_prev_action_(NULL),
pfile_recent_docs_action_(NULL),
pfile_recent_project_path_action_(NULL),
pfile_settings_action_(NULL),
pedit_select_cursor_word_action_(NULL),
pedit_find_action_(NULL),
pedit_search_action_(NULL),
Expand Down Expand Up @@ -278,6 +279,11 @@ void MainWindow::initActions()
pfile_recent_project_path_action_->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_P);
pfile_recent_project_path_action_->setIcon(QIcon(tr(":/res/project_path.png")));

pfile_settings_action_ = new QAction(tr("Lunar settings"), this);
pfile_settings_action_->setStatusTip(tr("Go to Lunar config directory. You can edit config, make use of tools or create new plugins."));
pfile_settings_action_->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Y);
pfile_settings_action_->setIcon(QIcon(tr(":/res/settings.png")));

pedit_select_cursor_word_action_ = new QAction(tr("Select cursor word"), this);
pedit_select_cursor_word_action_->setStatusTip(tr("Select cursor word of current document."));
pedit_select_cursor_word_action_->setShortcut(Qt::CTRL + Qt::Key_M);
Expand Down Expand Up @@ -386,6 +392,7 @@ void MainWindow::initMenubar()
pfile_menu->addAction(pfile_goto_prev_action_);
pfile_menu->addAction(pfile_recent_docs_action_);
pfile_menu->addAction(pfile_recent_project_path_action_);
pfile_menu->addAction(pfile_settings_action_);

QMenu* pedit_menu = menuBar()->addMenu(tr("&Edit"));
pedit_menu->addAction(pedit_select_cursor_word_action_);
Expand Down Expand Up @@ -426,6 +433,7 @@ void MainWindow::initToolbar()
ptoolbar->addAction(pfile_goto_next_action_);
ptoolbar->addAction(pfile_recent_docs_action_);
ptoolbar->addAction(pfile_recent_project_path_action_);
ptoolbar->addAction(pfile_settings_action_);
ptoolbar->addAction(prun_run_action_);
ptoolbar->addAction(prun_run_recent_action_);
ptoolbar->addAction(prun_stop_action_);
Expand Down Expand Up @@ -479,6 +487,10 @@ void MainWindow::initConnections()
connect(pfile_goto_prev_action_, SIGNAL(triggered()), this, SLOT(fileGotoPrev()));
connect(pfile_recent_project_path_action_, SIGNAL(triggered()), this, SLOT(recentProjectPath()));
connect(pfile_recent_docs_action_, SIGNAL(triggered()), this, SLOT(recentDocs()));
connect(pfile_settings_action_, &QAction::triggered, [this]()
{
resetCurrentPath(StdStringToQString(LunarGlobal::getInstance().getAppPath()));
});

connect(pedit_select_cursor_word_action_, SIGNAL(triggered()), this, SLOT(editSelectCursorWord()));
connect(pedit_find_action_, SIGNAL(triggered()), this, SLOT(editFind()));
Expand Down
1 change: 1 addition & 0 deletions src/gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ private Q_SLOTS:
QAction* pfile_goto_prev_action_;
QAction* pfile_recent_docs_action_;
QAction* pfile_recent_project_path_action_;
QAction* pfile_settings_action_;
QAction* pedit_select_cursor_word_action_;
QAction* pedit_find_action_;
QAction* pedit_search_action_;
Expand Down
31 changes: 19 additions & 12 deletions src/lunarcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,29 +238,36 @@ void LunarGlobal::removeRecentRunDoc(const std::string& doc)

void LunarGlobal::quit()
{
readCfg(false);
writeCfg();
}

void LunarGlobal::readCfg()
void LunarGlobal::readCfg(bool read_all)
{
TextCfg text_cfg(getAppPath() + "/" + kCfg);

//These files cannot be changed in App
log_sock_port_ = text_cfg.getValue("Log.SockPort", 9966);
is_log_enable_ = text_cfg.getValue<bool>("Log.Enable", false);
autocompletion_threshold_ = text_cfg.getValue("AutoCompletion.Threshold", 2);
autocompletion_wordtip_ = text_cfg.getValue("AutoCompletion.WordTip", 1);
string font_type = text_cfg.getValue("Font.Type", string("Monaco"));
int font_size = text_cfg.getValue("Font.Size", 12);
font_ = QFont(StdStringToQString(font_type), font_size);
mainwindow_width_ = text_cfg.getValue("MainWindow.Width", 800);
mainwindow_height_ = text_cfg.getValue("MainWindow.Height", 600);
extension_func_parsefiletype_ = text_cfg.getValue("Extension.Func.ParseFileType", "parseFileType");
extension_func_filefilter_ = text_cfg.getValue("Extension.Func.FileFilter", "fileFilter");
extension_tools_path_ = text_cfg.getValue("ExtensionToolsPath", "extension_tools");
extension_func_is_legal_file_ = text_cfg.getValue("Extension.Func.IsLegalFile", "isLegalFile");
extension_func_find_files_ = text_cfg.getValue("Extension.Func.FindFiles", "findFiles");
log_sock_port_ = text_cfg.getValue("Log.SockPort", 9966);
is_log_enable_ = text_cfg.getValue<bool>("Log.Enable", false);
recent_project_path_ = text_cfg.getValue("Path.RecentProject", "");
recent_project_path_cnt_ = text_cfg.getValue("Path.RecentProject.Count", 30);

if (read_all)
{
//These files can be changed in App
string font_type = text_cfg.getValue("Font.Type", string("Monaco"));
int font_size = text_cfg.getValue("Font.Size", 12);
font_ = QFont(StdStringToQString(font_type), font_size);
mainwindow_width_ = text_cfg.getValue("MainWindow.Width", 800);
mainwindow_height_ = text_cfg.getValue("MainWindow.Height", 600);
recent_project_path_ = text_cfg.getValue("Path.RecentProject", "");
recent_project_path_cnt_ = text_cfg.getValue("Path.RecentProject.Count", 30);
}
}

void LunarGlobal::writeCfg()
Expand All @@ -269,10 +276,10 @@ void LunarGlobal::writeCfg()

text_cfg.setValue("Font.Type", QStringToStdString(getFont().family()));
text_cfg.setValue("Font.Size", getFont().pointSize());
text_cfg.setValue("AutoCompletion.Threshold", autocompletion_threshold_);
text_cfg.setValue("AutoCompletion.WordTip", autocompletion_wordtip_);
text_cfg.setValue("MainWindow.Width", mainwindow_width_);
text_cfg.setValue("MainWindow.Height", mainwindow_height_);
text_cfg.setValue("AutoCompletion.Threshold", autocompletion_threshold_);
text_cfg.setValue("AutoCompletion.WordTip", autocompletion_wordtip_);
text_cfg.setValue("Extension.Func.ParseFileType", extension_func_parsefiletype_);
text_cfg.setValue("Extension.Func.FileFilter", extension_func_filefilter_);
text_cfg.setValue("Extension.Func.IsLegalFile", extension_func_is_legal_file_);
Expand Down
2 changes: 1 addition & 1 deletion src/lunarcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class LunarGlobal
SINGLETON(LunarGlobal)
void init(int argc, char* argv[]);
void quit();
void readCfg();
void readCfg(bool read_all = true);
void writeCfg();
inline std::string getAppPath() const { return app_path_; }
inline std::string getAppName() const { return app_name_; }
Expand Down

0 comments on commit f094052

Please sign in to comment.