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

Remove logging #257

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import org.jetbrains.jewel.foundation.state.CommonStateBitMask.Pressed
import org.jetbrains.jewel.foundation.state.CommonStateBitMask.Selected
import org.jetbrains.jewel.foundation.state.FocusableComponentState
import org.jetbrains.jewel.foundation.state.SelectableComponentState
import org.jetbrains.jewel.foundation.utils.Log
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds

Expand Down Expand Up @@ -315,8 +314,6 @@ private fun Tree.Element<*>.flattenTree(state: TreeState): MutableList<Tree.Elem
state.openNodes -= buildSet { getAllSubNodes(this@flattenTree) }
}
}
Log.w("the node is open, loading children for $id")
Log.w("children size: ${children?.size}")
open(true)
children?.forEach { child -> orderedChildren.addAll(child.flattenTree(state)) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.jetbrains.jewel.foundation.lazy.tree

import androidx.compose.ui.input.key.KeyEvent
import androidx.compose.ui.input.key.KeyEventType
import androidx.compose.ui.input.key.key
import androidx.compose.ui.input.key.type
import androidx.compose.ui.input.pointer.PointerEvent
import androidx.compose.ui.input.pointer.isCtrlPressed
Expand All @@ -17,7 +16,6 @@ import org.jetbrains.jewel.foundation.lazy.SelectableColumnOnKeyEvent
import org.jetbrains.jewel.foundation.lazy.SelectableLazyListKey
import org.jetbrains.jewel.foundation.lazy.SelectableLazyListState
import org.jetbrains.jewel.foundation.lazy.SelectionMode
import org.jetbrains.jewel.foundation.utils.Log
import org.jetbrains.skiko.hostOs

public interface KeyActions {
Expand Down Expand Up @@ -72,22 +70,18 @@ public open class DefaultSelectableLazyColumnEventAction : PointerEventActions {
when {
pointerEvent.keyboardModifiers.isContiguousSelectionKeyPressed &&
pointerEvent.keyboardModifiers.isCtrlPressed -> {
Log.i("ctrl and shift pressed on click")
// do nothing
}

pointerEvent.keyboardModifiers.isContiguousSelectionKeyPressed -> {
Log.i("shift pressed on click")
onExtendSelectionToKey(key, allKeys, selectableLazyListState, selectionMode)
}

pointerEvent.keyboardModifiers.isMultiSelectionKeyPressed -> {
Log.i("ctrl pressed on click")
toggleKeySelection(key, allKeys, selectableLazyListState)
}

else -> {
Log.i("single click")
selectableLazyListState.selectedKeys = listOf(key)
selectableLazyListState.lastActiveItemIndex = allKeys.indexOfFirst { it.key == key }
}
Expand Down Expand Up @@ -161,15 +155,13 @@ public class DefaultTreeViewPointerEventAction(
when {
pointerEvent.keyboardModifiers.isContiguousSelectionKeyPressed &&
pointerEvent.keyboardModifiers.isCtrlPressed -> {
Log.t("ctrl and shift pressed on click")
}

pointerEvent.keyboardModifiers.isContiguousSelectionKeyPressed -> {
super.onExtendSelectionToKey(key, allKeys, selectableLazyListState, selectionMode)
}

pointerEvent.keyboardModifiers.isMultiSelectionKeyPressed -> {
Log.t("multi selection pressed")
selectableLazyListState.lastKeyEventUsedMouse = false
super.toggleKeySelection(key, allKeys, selectableLazyListState)
}
Expand Down Expand Up @@ -199,7 +191,6 @@ public class DefaultTreeViewPointerEventAction(
}
onElementDoubleClick(item)
elementClickedTmpHolder = null
Log.d("doubleClicked!")
} else {
elementClickedTmpHolder = item.id
// is a single click
Expand All @@ -208,8 +199,6 @@ public class DefaultTreeViewPointerEventAction(
delay(doubleClickTimeDelayMillis)
if (elementClickedTmpHolder == item.id) elementClickedTmpHolder = null
}

Log.d("singleClicked!")
}
}
}
Expand Down Expand Up @@ -237,7 +226,6 @@ public class DefaultTreeViewKeyActions(
val keyEvent = this
with(keybindings) {
with(actions) {
Log.d(keyEvent.key.keyCode.toString())
if (selectionMode == SelectionMode.None) return@lambda false
when {
isSelectParent -> onSelectParent(keys, state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import org.jetbrains.jewel.foundation.lazy.SelectableLazyListState
import org.jetbrains.jewel.foundation.lazy.SelectableScope
import org.jetbrains.jewel.foundation.utils.Log

@Composable
public fun rememberTreeState(
Expand All @@ -27,13 +26,11 @@ public class TreeState(
public var openNodes: Set<Any> by mutableStateOf<Set<Any>>(emptySet())

public fun toggleNode(nodeId: Any) {
Log.d("toggleNode $nodeId")
if (nodeId in openNodes) {
openNodes -= nodeId
} else {
openNodes += nodeId
}
Log.d("open nodes ${openNodes.map { it.toString() }}")
}

public fun openNodes(nodes: List<Any>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,3 @@ internal interface Logger {
log(LogLevel.Trace, LogLevel.Trace.color + msg + resetColor())
}
}

// TODO remove and replace with real logger
@Deprecated("Use a real logger instead")
internal object Log : Logger {

override var currentLogLevel: LogLevel = LogLevel.Off

override fun log(level: LogLevel, msg: String) {
if (currentLogLevel.ordinal <= level.ordinal) println(msg)
}
}