[apps/code] Added exceptions handling in toolbox

This commit is contained in:
M4x1m3
2020-07-06 12:45:47 +02:00
parent 73688343a0
commit c4363103f6
8 changed files with 24 additions and 2 deletions

View File

@@ -441,12 +441,20 @@ const ToolboxMessageTree fileChildren[] {
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandFileWritelines, I18n::Message::PythonFileWritelines, false, I18n::Message::PythonCommandFileWritelinesWithoutArg),
};
const ToolboxMessageTree exceptionsChildren[] = {
ToolboxMessageTree::Leaf(I18n::Message::TryExcept1ErrorWithArg, I18n::Message::Default, false, I18n::Message::TryExcept1Error),
ToolboxMessageTree::Leaf(I18n::Message::TryExcept1ErrorElseWithArg, I18n::Message::Default, false, I18n::Message::TryExcept1ErrorElse),
ToolboxMessageTree::Leaf(I18n::Message::TryExcept2ErrorWithArg, I18n::Message::Default, false, I18n::Message::TryExcept2Error),
ToolboxMessageTree::Leaf(I18n::Message::WithInstructionWithArg, I18n::Message::Default, false, I18n::Message::WithInstruction),
};
const ToolboxMessageTree menu[] = {
ToolboxMessageTree::Node(I18n::Message::LoopsAndTests, loopsAndTestsChildren),
ToolboxMessageTree::Node(I18n::Message::Modules, modulesChildren),
ToolboxMessageTree::Node(I18n::Message::Catalog, catalogChildren),
ToolboxMessageTree::Node(I18n::Message::Functions, functionsChildren),
ToolboxMessageTree::Node(I18n::Message::Files, fileChildren)
ToolboxMessageTree::Node(I18n::Message::Files, fileChildren),
ToolboxMessageTree::Node(I18n::Message::Exceptions, exceptionsChildren)
};
const ToolboxMessageTree toolboxModel = ToolboxMessageTree::Node(I18n::Message::Toolbox, menu);
@@ -472,7 +480,7 @@ bool PythonToolbox::handleEvent(Ion::Events::Event event) {
}
KDCoordinate PythonToolbox::rowHeight(int j) {
if (typeAtLocation(0, j) == Toolbox::LeafCellType && m_messageTreeModel->label() == I18n::Message::IfStatementMenu) {
if (typeAtLocation(0, j) == Toolbox::LeafCellType && (m_messageTreeModel->label() == I18n::Message::IfStatementMenu || m_messageTreeModel->label() == I18n::Message::Exceptions)) {
/* To get the exact height needed for each cell, we have to compute its
* text size, which means scan the text char by char to look for '\n'
* chars. This is very costly and ruins the speed performance when

View File

@@ -3,3 +3,4 @@ Catalog = "Katalog"
Modules = "Module"
LoopsAndTests = "Schleifen und Tests"
Files = "Dateien"
Exceptions = "Ausnahmen"

View File

@@ -3,3 +3,4 @@ Catalog = "Catalog"
Modules = "Modules"
LoopsAndTests = "Loops and tests"
Files = "Files"
Exceptions = "Exceptions"

View File

@@ -3,3 +3,4 @@ Catalog = "Catalog"
Modules = "Modules"
LoopsAndTests = "Loops and tests"
Files = "Files"
Exceptions = "Exceptions"

View File

@@ -3,3 +3,4 @@ Catalog = "Catalogue"
Modules = "Modules"
LoopsAndTests = "Boucles et tests"
Files = "Fichiers"
Exceptions = "Exceptions"

View File

@@ -3,3 +3,4 @@ Catalog = "Katalógus"
Modules = "Modulok"
LoopsAndTests = "Hurkok és tesztek"
Files = "Fájlok"
Exceptions = "Kivételek"

View File

@@ -3,3 +3,4 @@ Catalog = "Catalog"
Modules = "Modules"
LoopsAndTests = "Loops and tests"
Files = "Files"
Exceptions = "Exceptions"

View File

@@ -44,6 +44,14 @@ ForInRange2ArgsLoop = "for i in range(\x11,):\n "
ForInRange2ArgsLoopWithArg = "for i in range(start, stop):\n instruction"
ForInRange1ArgLoop = "for i in range(\x11):\n "
ForInRange1ArgLoopWithArg = "for i in range(size):\n instruction"
TryExcept1Error = "try:\n \nexcept \x11:\n "
TryExcept1ErrorWithArg = "try:\n instruction\nexcept Error:\n reaction"
TryExcept1ErrorElse = "try:\n \nexcept \x11:\n \nelse:\n "
TryExcept1ErrorElseWithArg = "try:\n instruction\nexcept Error:\n reaction\nelse:\n clean"
TryExcept2Error = "try:\n \nexcept (\x11):\n "
TryExcept2ErrorWithArg = "try:\n instruction\nexcept (Error1, Error2):\n reaction"
WithInstruction = "with \x11 as :\n "
WithInstructionWithArg = "with expression as target:\n instructions"
PythonCommandDef = "def \x11():\n "
PythonCommandDefWithArg = "def function(x):"
PythonCommandReturn = "return "