Merge pull request #490 from dayllenger/master

Highlighting in readme and coding style pages #443
This commit is contained in:
Vadim Lopatin 2017-10-16 11:22:46 +03:00 committed by GitHub
commit dbbad64649
2 changed files with 206 additions and 208 deletions

View File

@ -16,28 +16,28 @@ Method and property names: camelCase with lowercase first letter, e.g.: `textAli
Private and protected class and struct fields: \_camelCase prepended with underscore, e.g. `_windowWidth`.
Signal names: camelCase.
Enum member names: currently, 3 styles are used: JAVA_LIKE, CamelCase and camelCase. TODO: make it consistent?
```D
class MyClass {
private int _magicNumber;
@property int magicNumber() { return _magicNumber; }
}
```
Spaces
------
Always put space after comma or semicolon if there are more items in the same line.
```D
update(x, y, isAnimating(this));
auto list = [1, 2, 3, 4, 5];
```
Usually there is no space after opening or before closing `[]` and `()`.
Spaces may be added to improve readability when there is a sequence brackets of the same type.
```D
auto y = (x * x + ( ((a - b) + c) ) * 2);
```
Use spaces before and after == != && || + - * / etc.
@ -45,17 +45,19 @@ Brackets
--------
Curly braces for `if`, `switch`, `for`, `foreach` - preferable placed on the same lines as keyword:
```D
if (a == b) {
//
} else {
//
}
foreach (item; list) {
writeln(item);
}
```
Cases in switch should be indented:
```D
switch(action.id) {
case 1:
processAction(1);
@ -63,23 +65,23 @@ Cases in switch should be indented:
default:
break;
}
```
For classes and structs opening { can be either at end of line or in a new line).
```D
class Foo {
}
class Bar : Foo
{
}
For methods { can be either at end of line.
```
For methods { should be at the end of line.
Short methods (e.g. property getters) may be written in one line.
```D
void invalidate() {
//
}
int length() { return _list.length; }
```

106
README.md
View File

@ -128,10 +128,10 @@ Important notice
If build of your app is failed due to dlangui or its dependencies, probably you have not upgraded dependencies.
Try following:
```sh
dub upgrade --force-remove
dub build --force
```
As well, sometimes removing of dub.json.selections can help.
@ -146,11 +146,11 @@ Win32 builds
Build and run demo app using DUB:
```sh
git clone --recursive https://github.com/buggins/dlangui.git
cd dlangui/examples/example1
dub run --build=release
```
To develop using Visual-D or MonoD, open dlangui.sln using Visual D (or dlangui-monod.sln for MonoD)
@ -158,13 +158,13 @@ To develop using Visual-D or MonoD, open dlangui.sln using Visual D (or dlangui-
To avoid showing console window add win_app.def file to your package source directory and add line to your dub.json.
win_app.def:
```json
"sourceFiles": ["$PACKAGE_DIR/src/win_app.def"]
```
dub.json:
```json
"sourceFiles-windows": ["$PACKAGE_DIR/src/win_app.def"],
```
Mac OSX development using Mono-D
--------------------------------
@ -178,17 +178,17 @@ Native Cocoa backend - work is in progress.
In some directory, e.g. ~/src/d/ :
Clone DlangUI repository
```sh
git clone --recursive https://github.com/buggins/dlangui.git
```
Enter dlangui directory
```sh
cd dlangui
```
Open solution file with Mono-D
```
dlangui-monod-osx.sln
```
Linux development using Mono-D
@ -200,17 +200,17 @@ Required libraries: libsdl2, x11, libfreetype, libfontconfig and OpenGL.
Clone DlangUI repository
```sh
git clone https://github.com/buggins/dlangui.git
```
Enter dlangui directory
```sh
cd dlangui
```
Open solution file with Mono-D
```
dlangui-monod-linux.sln
```
Try running examples: helloworld, example1, tetris, dmledit, spreadsheet, opengl
Configurations Debug, Release, Unittest build SDL2+OpenGL versions of apps.
@ -258,17 +258,17 @@ Install GIT, DUB, DMD, MonoDevelop with Mono-D plugin.
Clone DlangUI repository
```sh
git clone https://github.com/buggins/dlangui.git
```
Enter dlangui directory
```sh
cd dlangui
```
Open solution file with Mono-D
```
dlangui-monod-windows.sln
```
Try running examples: helloworld, example1, tetris, dmledit, spreadsheet, opengl
Configurations Debug, Release, Unittest build SDL2+OpenGL versions of apps.
@ -316,21 +316,21 @@ Install GIT, DUB, DMD, MS Visual Studio (e.g. Community 2013) + VisualD plugin
Clone DlangUI repository
```sh
git clone --recursive https://github.com/buggins/dlangui.git
```
For DlangIDE development, close dlangide project on the same directory level as dlangui is cloned:
```sh
git clone --recursive https://github.com/buggins/dlangide.git
```
Enter dlangui directory
```sh
cd dlangui
```
Open solution file with Visual-D
```
dlangui-msvc.sln
```
Try running examples: helloworld, example1, tetris, dmledit, spreadsheet, opengl
Configurations Debug, Release, Unittest build SDL2+OpenGL versions of apps.
@ -384,19 +384,19 @@ Linux builds (DUB)
libsdl2, libfreetype, libfontconfig
E.g. in Ubuntu, you can use following command to enable SDL2 backend builds:
```sh
sudo apt-get install libsdl2-dev
```
In runtime, .so for following libraries are being loaded (binary packages required):
```
freetype, opengl, fontconfig
```
Build and run on Linux using DUB:
```sh
cd examples/example1
dub run dlangui:example1
```
Other platforms
@ -418,7 +418,7 @@ Third party components used
Hello World
--------------------------------------------------------------
```D
// myproject.d
import dlangui;
mixin APP_ENTRY_POINT;
@ -434,11 +434,11 @@ Hello World
// run message loop
return Platform.instance.enterMessageLoop();
}
```
Sample dub.json:
--------------------------------
```json
{
"name": "myproject",
"description": "sample DLangUI project",
@ -450,7 +450,7 @@ Sample dub.json:
"dlangui": "~master"
}
}
```
Hello World using DML
--------------------------------------------------------------
@ -460,9 +460,7 @@ DlangUI supports creation of widgets from markup.
DML - DlangUI Markup Language - similar to QML.
Example of complex UI easy created from text:
```D
module app;
import dlangui;
@ -531,18 +529,16 @@ Example of complex UI easy created from text:
// run message loop
return Platform.instance.enterMessageLoop();
}
```
There is DMLEdit sample app in DlangUI/examples directory.
You can run it with dub:
```sh
dub run dlangui:dmledit
It allows to edit QML text and see how it will look like when loaded into app (F5 refreshes view).
```
It allows to edit DML text and see how it will look like when loaded into app (F5 refreshes view).
Syntax highlight, bracket matching, go to error and other useful features are implemented.
@ -561,8 +557,8 @@ DCD integration: go to definition and autocompletion for D source code.
Project page: [https://github.com/buggins/dlangide](https://github.com/buggins/dlangide)
How to build and run using DUB:
```sh
git clone https://github.com/buggins/dlangide.git
cd dlangide
dub run
```