Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting #369

Open
wants to merge 24 commits into
base: dev
Choose a base branch
from
Open

Formatting #369

wants to merge 24 commits into from

Conversation

Kim-Dewelski
Copy link
Contributor

Added a formatting script to format the project, and crated a clang-format script using the LLVM formatting style. If we want another style it is a simple fix!

src/main.c Outdated
#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
#include "IconsForkAwesome.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes should not be moved past defines.


#define SE_MAX_CONTROL_POINTS 32
#define SE_REGION_NAME 0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make it not break aligned numbers like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right I will try to see if I can make it do that

src/main.c Outdated
uint32_t version_code;
uint8_t palettes[5*4];
uint32_t version_code;
uint8_t palettes[5 * 4];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • and / should not be wrapped in spaces (but + and - should be wrapped in spaces) to improve readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhm ok sounds like a good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang format does unfortunately not seem to support this (?)
is this a deal breaker? It seems to want to have spaces between most operators.

src/main.c Outdated
static bool se_draw_theme_region_tint(int region, float x, float y, float w, float h,uint32_t tint);
static bool se_draw_theme_region_tint_partial(int region, float x, float y, float w, float h, float w_ratio, float h_ratio, uint32_t tint);
static const char* se_get_pref_path(){
static bool se_load_theme_from_file(const char *filename);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't auto word wrap long lines.

src/main.c Outdated
dpi_scale = sapp_dpi_scale();
if(dpi_scale<=0)dpi_scale=1.;
dpi_scale*=1.10;
if (dpi_scale <= 0)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. if/while should not have spaces between "("
  2. if statements without {} should always be on the same line as their statement (it prevents bugs)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we always want {} to create a new line?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, leave it up to the programmer to put the new lines if they want it.

src/main.c Outdated
const utf8proc_uint8_t *str = (const utf8proc_uint8_t *)input_string;
while(str[0]){
while (str[0]) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no space between ) and {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't seem to be an option sadly

str += size;
if (codepoint_ref > SE_MAX_UNICODE_CODE_POINT)
continue;
;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did this extra semicolon come from?

src/main.c Outdated
static inline const char* se_localize_and_cache(const char* input_str){
const char * localized_string = se_localize(input_str);
static inline const char *se_localize_and_cache(const char *input_str) {
const char *localized_string = se_localize(input_str);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you configure the formatting to not touch the location of * in variable names?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dunno but I will try

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No sadly, it does not seem like it, but we can tell it to put pointers to the left, right or in the middle. Maybe I simply missed it in the docs because it does feel like it should be an option but it is not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it still format them even if you don't have a PointerAlignment field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can look into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope it defaults to right alignment if I do that.

const char* se_keycode_to_string(int keycode){
switch(keycode){
default: return "Unknown";
case SAPP_KEYCODE_SPACE: return "SPACE";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to not break up these case labels and the returns onto separate lines.
They are laid out like this to allow block edits.

src/gba_bios.h Outdated
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't format this file

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't format this file

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't format this file

src/main.c Outdated
"Toggle Full Screen"
};
const static char *se_keybind_names[SE_NUM_KEYBINDS] = {
"A",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only be 2 spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want a tab width of 2 spaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix that

// Utilize a watchdog channel to detect if the audio context has encountered an error
// and restart it if a problem occurred.
int audio_watchdog_timer;
int audio_watchdog_triggered;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing here is a bit long

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spacing is long in order to have alignment, we could add newlines between the lines to alleviate that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

things like this may happen a bit everywhere though so declarations are aligned, it is sadly impossible as far as I can see to give it a sort of threshold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants